2014-03-28 197 views
0

我試圖從gamePlayscene更改爲GameOverScene,但是當模擬器嘗試更改場景時,模擬器停止但我沒有在Log中收到任何消息。更改場景cocos2d

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]]; 
+0

您正在替換當前場景的相同場景。所以你永遠是當前的場景。 –

回答

2

放於 「迴歸自我」 - (ID )在if塊之後的init方法。