1
\$\begingroup\$

My project is a cocos2d game project, but I added a UIViewController for the initial log in. The first scene is the splash logo, followed by the menu screen, but I need to pass to my UIViewController instead of my menu screen. I've tried lots of methods, but it keeps crashing.

-(id) init
{

    if( (self=[super init] )) 
    {
        CCSprite *sprBack = [CCSprite spriteWithFile:@"logo.png"];
        [sprBack setPosition:ccp(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)];
        [self addChild:sprBack];

        [self schedule:@selector(logoTimer:) interval:3];
    }

    return self;
}

-(void) logoTimer: (ccTime) dt
{

    [[CCDirector sharedDirector] replaceScene:
        [CCTransitionFade transitionWithDuration:0.5f scene:[TitleLayer node]]];
}

My UIViewController is called LoginViewController. I need to pass a scene like this:

[[CCDirector sharedDirector] replaceScene:
    [CCTransitionFade transitionWithDuration:0.5f scene:[loginviewcontroller node]]];

I tried a lot of methods, but unfortunately, nothing will gives me the correct solution.

Itvis worth mentioning that LoginViewController is not a Node. I have tried that method, but it geta stuck at the logo scene, with no page transition taking place.

-(void) logoTimer: (ccTime) dt
{
    UIViewController *cocos = [[LogoViewController alloc] init];
    [cocos.navigationController dismissViewControllerAnimated:YES completion:nil];
    [cocos.navigationController popViewControllerAnimated:YES];
}

How do I solve my problem?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.