call init() function of layer everytime you switchTo: that layer

Forums Programming cocos2d support (graphics engine) call init() function of layer everytime you switchTo: that layer

This topic contains 0 replies, has 1 voice, and was last updated by  dozeone 2 years, 3 months ago.

Viewing 1 post (of 1 total)
Author Posts
Author Posts
January 10, 2012 at 7:15 pm #238314

dozeone
Participant
@dozeone

I n my code the main menu starts the game by:

[(CCLayerMultiplex*)parent_ switchTo:1];

and the game over screen:

[(CCLayerMultiplex*)parent_ switchTo:2];

and then it switches back to the main menu.

However when i then jump back to layer 1 (the game) a second time, (it should be restarted by calling the init function again) all the sprite movements are just stopped and the score is not reseted.

is there any similar to viewDidAppear or something like that i need to use?

-(id) init{

if( ! [super init] )

return nil;

self.isTouchEnabled = YES;

self.isAccelerometerEnabled = YES;

self.score=0;

self.life=100;

self.fuel=1000;

....

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.