Cocos2d Tips: Transitioning between game screens

Let’s learn how to create menu for a cocos2d game and how to move between a menu, the game scene, a level complete scene etc. Eventually your game will grow and you will have to create a clear structure to keep everything organized. As you can see, as with any app, the AppDelegate is the first object called. As such, it is the entry point to your game and will call the very first scene of your game. This means the first scene should probably the main menu which welcomes the user to the game and presents him with options. As you can see from the Cocos2d tips “Creating a… Read More

Continue Reading

Cocos2d Tips: Creating a Menu

You can create a menu by creating label items or image items and passing them to a CCMenu object. A typical MainMenuScene.m file might look like this: -(void)playScene:(CCMenuItemFont*)itemPassedIn { if ([itemPassedIn tag] == 1) { [[GameManager sharedGameManager] runSceneWithID:kIntroScene]; } else if ([itemPassedIn tag] == 2) { [[GameManager sharedGameManager] runSceneWithID:kSecondScene]; } else if ([itemPassedIn tag] == 3) { [[GameManager sharedGameManager] runSceneWithID:kThirdScene]; } else { CCLOG(@”Unexpected item. Tag was: %d”, [itemPassedIn tag]); } } -(void)displayMainMenu { CGSize screenSize = [CCDirector sharedDirector].winSize; if (sceneSelectMenu != nil) { [sceneSelectMenu removeFromParentAndCleanup:YES]; } // Main Menu CCMenuItemImage *playGameButton = [CCMenuItemImage itemWithNormalImage:@”TapMeToPlay.png” selectedImage:@”TapMeToPlay.png” disabledImage:nil target:self selector:@selector(displaySceneSelection)]; CCMenuItemImage *optionsButton = [CCMenuItemImage itemFromNormalImage:@”someImage.png” selectedImage:@”someImage.png” disabledImage:nil target:self selector:@selector(showOptions)]; mainMenu =… Read More

Continue Reading