Wednesday 15 June 2011

Jump to Main Screen of Game in Cocos2d iphone -


I started development in cocos2d iphone a few months ago. Now I'm going to finish my game, and I got trapped in one place. And I know that this is the coding issue.

First I want to explain the main screen. When the game starts, there are some animations that take approximately 7 seconds and then my play button appears, then I click on it and the game starts.

Now I want to implement a button, when I click on that button, the visual transit will be done and then directly without animation I can see my main menu.

So basically I do not want the user to wait for the animation to be completed first. I want to play them directly.

Any guidelines or signs will be appreciated.

I have applied to the demo code in which I have added three different buttons. Each button will move to the same orbit view, but each time it presses the button, it will display different scanners.

This is a HelloWorldLayer.h

  #import "cocos2d.h" @ Interface HelloWaldlayer: CClear {} / gives a CCScen in which HelloWaldlayer as the only child (+ CCScene *) View: (int) level; + (ID) nodeWithGameLevel: (int) level; - (id) initWithGameLevel: (int) level; @end   

HelloWorldLayer.m class

  @implementation HelloWorldLayer + (CCScene *) View: (int) whichLevel {/ / 'View' is an autoriallic object CCScen * View = [CCScene node]; // 'Layer' is an autoriz object, HelloWorldLayer * layer = [HelloWaldlayer nodewidth game level: JellyVell]; // Add the layer as a child view as a view [view addChild: layer]; // Return return view return; } - (id) initWithGameLevel: (int) level {if ((self = [super init])) {printf ("level:% d", level); If (level == 1) {// complete code for the scene with animation} and if (level == 2) {// code for the sequence without action} and if (level == 3) {// any Other view that you want} CCMenuItemImage * item1 = [CCMenuItemImage ItemWithNormalImage: @ "Icon-72.png" Selected Image: @ "icon-72.png" Goal: Self Selector: @Selector (goToMainMenu)]; CCMenuItemImage * item2 = [CCMenuItemImage itemWithNormalImage: @ "Icon-72.png" Selected Image: @ "icon-72.png" Goal: Self Selector: @Selector (goToRestartMenu)]; CCMenuItemImage * item3 = [CCMenuItemImage ItemWithNormalImage: @ "Icon-72.png" Selected Image: @ "Icon-72.png" Goal: Self Selector: @Selector (goToMainPage); Ccmenu * menu = [cc menu menu attributes: Item 1, Item 2, Item 3, Zero]; [Self composite: menu]; [Menu alignItemsVertically]; } Healthy return; } + (Id) nodewit game level: (int) level {return [[all allocation] initWithGameLevel: level] autorelease]; } - (Zero) instead of goToMainMenu {[CCCCitator Share Director]: Scein: [CCTR TransferFirm Transit: 1.0 View: [HelloWireLayer View: 1] With Collar: CCHHite]]; } - (void) goToRestartMenu {[CCCCitre Shared Director] Replaced: Sentin: [CCTR settingsFan transit deadline: 1.0View: [Hello WorldLayer View: 2] With Color: CCHHETE]]; } - (empty) GoToMainPage instead of {{CCCCCcator Share Director}: Scein: [CCTRCsIFFED TranscriptionWidth: 1.0 Season: [Hello WorldLayer View: 3] with Collar: CCHHETE]]; }    

No comments:

Post a Comment