Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set a scene as initial view controller cocos2d
    primarykey
    data
    text
    <p>I am not sure how to correctly display code in a thread so sorry about that in advance. So I have my App Delegate which calls </p> <p>[director_ pushScene: [IntroLayer scene]]; </p> <p>Then my introLayer does this:</p> <pre><code>-(void) makeTransition:(ccTime)dt { [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[MainMenu scene] withColor:ccBLUE]]; } </code></pre> <p>Then I have MainMenu.h and .m but they are pretty much empty except .m has:</p> <pre><code>@implementation MainMenu // Helper class method that creates a Scene with the GamePlay as the only child. +(CCScene *) scene { // 'scene' is an autorelease object. CCScene *scene = [CCScene node]; // 'layer' is an autorelease object. MainMenu *layer = [MainMenu node]; // add layer as a child to scene [scene addChild: layer]; // return the scene return scene; } @end </code></pre> <p>Then I have a storyboard which uses a navigation controller and I want the opening scene to be the main menu when i call the 'makeTransition' function. In my storyboard I have a Play button on this main menu. This play button is push segued to another view controller which is of class 'CCViewController'. I have CCViewController.m and .h and then i made a subclass from it called cocos2dViewController.m and .h. In my cocos2dViewController.m I call:</p> <pre><code>if(director.runningScene) [director replaceScene:[GamePlay scene]]; else [director pushScene:[GamePlay scene]]; </code></pre> <p>GamePlay.m and .h are where i define my whole game.</p> <p>So when I run it I get the launch screen and then it transitions with the color blue to a black screen. Is this because there is nothing in MainMenu.m? Also, (I think) I shouldn't need anything in MainMenu.m. I just need some way of making the MainMenu scene be the initial (main menu) scene of the storyboard. I feel that I am pretty close to getting this to work and any advice/knowledge you have to offer at this point or if you need any more info to diagnose the problem would again be greatly appreciated. Thanks! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload