0
votes

I'm trying to change from gamePlayscene to a GameOverScene, but when the simulator tries to changes the scene, the simulator stops but I don't receive any message in the Log.

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

    }

}

I'm calling the GameOverScene this way:

 [[CCDirector sharedDirector] replaceScene:[GameOverScene scene]
                               withTransition:[CCTransition transitionFadeWithDuration:1.0f]];
1
You are replace same scene of current scene. so you are always current scene. - Kirit Modi

1 Answers

2
votes

put "return self" in the -(id)init method after the if block.