【发布时间】:2014-10-08 09:48:27
【问题描述】:
我正在使用 cocos2d-x 为 IOS 开发一款游戏。现在我正在尝试使用 Admob 实现插页式广告。我希望它们出现在我的 GameOver 场景中(就像我在其他游戏中看到的那样)。
有人知道怎么做吗?
这就是我的 GameOver 场景的样子:
//
// IntroScene.m
// Cocos2DSimpleGame
//
// Created by Martin Walsh on 18/01/2014.
// Copyright Razeware LLC 2014. All rights reserved.
//
// -----------------------------------------------------------------------
// Import the interfaces
#import "GameOverClass.h"
#import "HelloWorldScene.h"
#import "AppDelegate.h"
#import "GADInterstitial.h"
#import "GADInterstitialDelegate.h"
// -----------------------------------------------------------------------
#pragma mark - IntroScene
// -----------------------------------------------------------------------
@implementation GameOverClass
int score1;
Boolean newhighscore;
// -----------------------------------------------------------------------
#pragma mark - Create & Destroy
// -----------------------------------------------------------------------
+ (GameOverClass *)scene
{
return [[self alloc] init];
}
// -----------------------------------------------------------------------
- (id)init
{
// Apple recommend assigning self with supers return value
self = [super init];
if (!self) return(nil);
CCNodeColor *background = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0.1f green:0.7f blue:1.0f alpha:1.0f]];
[self addChild:background];
CCSprite *logo = [CCSprite spriteWithImageNamed:@"gameover.png"];
logo.position = CGPointMake(self.contentSize.width/2, self.contentSize.height - logo.contentSize.height);
logo.zOrder = 10;
[self addChild:logo];
/*
CCSprite *high = [CCSprite spriteWithImageNamed:@"highscore.png"];
high.position = ccp(0.5f, 0.75f);
high.zOrder = 10;
[self addChild:high];
*/
// Spinning scene button
CCButton *spinningButton = [CCButton buttonWithTitle:@"[ Try Again ]" fontName:@"Verdana-Bold" fontSize:18.0f];
spinningButton.positionType = CCPositionTypeNormalized;
spinningButton.position = ccp(0.5f, 0.35f);
spinningButton.zOrder = 10;
[spinningButton setLabelColor:[CCColor colorWithRed:1.0f green:0.7f blue:0.0f alpha:1.0f] forState:CCControlStateNormal];
[spinningButton setTarget:self selector:@selector(onSpinningClicked:)];
[self addChild:spinningButton];
【问题讨论】: