views:

40

answers:

1

I want to restart the current scene i am on. I thought of using replaceScene and replace it with itself. Is that ok to do ?

Level2Scene *scene = [Level2Scene node];
[[CCDirector sharedDirector] replaceScene:scene];

Level2Scene is the current scene I am in.

Thanks Abhinav

+1  A: 

Using replaceScene: is a good way to restart the level, if levels are represented by scenes. Just make sure that if you have any global state (stored outside of the scene) that you reset that, too.

Colin Gislason
Thanks Colin. I have layers added as child to this scene. That shouldn't be a problem right?
AbhinavVinay
No, everything contained in the scene is replaced as long as you are using a new scene object like you are in the example you gave.
Colin Gislason