Rqgg Page 1/2

quidnuncoceanΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 4 χρόνια και 5 μήνες)

151 εμφανίσεις

Restart Current scene in cocos2d
Asked by
on 2013-04-14T20:22:40-04:00
I am wondering what is the proper way to restart the current scene in cocos2d since I can´t get it
working properly. I am using the following code to restart the actual scene, but only a black screen

CCScene *currentScene = [CCDirector sharedDirector].runningScene; CCScene *newScene =
[[[currentScene class] alloc] init]; [[CCDirector sharedDirector] replaceScene:[CCTransitionFade
transitionWithDuration:0.7f scene:newScene]];
Note: I don´t know if this has something to do with
the fact (I guess not) that this code is run from a CClayer subclass that is in charge of managing the
pause menus and stuff.


Best Answer
Answer by
on 2013-04-14T21:09:23-04:00
I suppose it has something to do with that manual alloc. In most cases, it's better to call cocos2d
static constructors, and let it handle the memory management for you. This is what I do.-

MyClassScene *newScene = [MyClassScene node]; [[CCDirector sharedDirector]
replaceScene:[CCTransitionFade transitionWithDuration:kTransitionTime scene:newScene
withColor:ccc3(255, 255, 255)]];
Hope it helps.

Apr 14th, 2013
Week 15, 2013
April, 2013
ccTouchBegan doesnt work-iOS
Boundary for sprites in cocos2d?
IOS, ARC, Property: (readwrite, nonatomic) vs (radwrite, retain, nonatomic)
What is the best way to draw a large number of lines using openGL and cocos2D?
The best practice for retrieving level editor data from an ios device
IOS Game - Life Regeneration
Box2d and Cocos2d with faked 3d view
Cocos2d-x and CocosBuilder multi-resolution for ios and android
How to stop runAction in cocos2d
sprite sheets in native app (NOT cocos2d)
View Online
Page 1/2
Restart Current scene in cocos2d
Page 2/2