Sharanya K M
Sharanya K M

Reputation: 1805

How to restart a scene in cocos2d using UIViewController

I have to restart a scene created in cocos2d using a defined UIViewController. How can i do this? Please let me know how i can do this.

Upvotes: 0

Views: 531

Answers (1)

Morion
Morion

Reputation: 10860

you can try to call something like

- (void) restart
{
    [[CCDirector sharedDirector] replaceScene:[[self class] node]];
}

i think, it will work, but it is not good. IMHO, much better is to use smth like this

- (void) restart
{
    // remove all your content
    [self removeAllChildrenWithCleanup];

    // reinitialize your instances

    // re-add content again
    [self addContent];
}

Upvotes: 3

Related Questions