I have created one level in cocos2d and i have a pause button on screen . clicking on pause screen it will open Menu ( Resume, Restart, Settings) . i want that when i click on restart menu my level will start from start. what i have tried i have remove that layer class and called it again but it didnt work. i tried to replaceScene . it didnt work either. how can i achieve that?
I have tried this and it works.
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] pushScene:[HelloWorldLayer node]];
But is it write that i am calling pushScene over and over.? will it effect my game. coz till now i am now removing that HelloWorldLayer that i want to restart again.
You have to use replaceScene. With pushScene the app will eventually run out of memory as previous scenes are not deallocating.
Be sure to create a new scene (as in your code sample), do not try to call replaceScene with the already running scene, that will fail.
You should also verify that your scene deallocates after replaceScene. Set a breakpoint in the dealloc method. If it does not deallocate, this means the scene is leaking and that can lead to all kinds of strange issues.