gpt4 book ai didi

ios - 改变场景cocos2d

转载 作者:行者123 更新时间:2023-11-28 22:11:52 28 4
gpt4 key购买 nike

我正在尝试从 gamePlayscene 更改为 GameOverScene,但是当模拟器尝试更改场景时,模拟器停止但我没有在日志中收到任何消息。

GameOverScene.h

@interface GameOverScene : CCScene {
GameOverScene *scene;
//screen size
float winWidth;
float winHeight;

//Game vars
int score;

//Facebook vars
FBSession* session;
NSString *messageStr;
NSString *userid;
}

+ (GameOverScene *)scene;
- (id)init;

@end

GameOverScene.m

@implementation GameOverScene {


}


+ (GameOverScene *)scene
{


return [[self alloc] init];


}

// -----------------------------------------------------------------------

- (id)init
{
if( (self=[super init] )) {
NSLog(@"define tamanho da tela");
winWidth = self.contentSize.width;
winHeight = self.contentSize.height;



NSLog(@"define botao");
// Facebook login button
CCButton *fbLoginButton = [CCButton buttonWithTitle:@"Login with FB" fontName:@"Verdana-Bold" fontSize:30.0f];
fbLoginButton.position = ccp(winWidth/2, winHeight/2);
[fbLoginButton setTarget:self selector:@selector(fbLoginClicked:)];
[self addChild:fbLoginButton];

}

}

我这样调用 GameOverScene:

 [[CCDirector sharedDirector] replaceScene:[GameOverScene scene]
withTransition:[CCTransition transitionFadeWithDuration:1.0f]];

最佳答案

在 if block 之后的 -(id)init 方法中放置“return self”。

关于ios - 改变场景cocos2d,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22725012/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com