开发者

cocos2d scene retaining issue

There is a scene in my application which has only two labels and a menu item. When I load this scene using replaceScene method it stays for 3-4 seconds and then gets disappeared or released. I want to keep it until cancel button is pressed. How can I do it? code is:

@implementation MyLayer

+ (id)myScene {

    CCScene *aScene = [开发者_运维技巧CCScene node];
    MYLayer *myLayer = [MyLayer node];
    [aScene addChild:myLayer];

    return aScene;  
}
- (id) init {

    if (self = [super init]) {
           //labels and menu here    
    }
    return self;
}

And I am calling it from another scene like this:

[[CCDirector sharedDirector] replaceScene: [MyLayer myScene]];


Maybe the problem is that it's your first scene. Then you should use runWithScene method of CCDirector.


did you try replacing that scene with a "empty" init function to see if it still releases itself? It might be because of the amount of textures you are putting into memory

I did have sort of similar problems before because the images used in the new scene is too big and got auto purged by my app delegate, thus returning me an empty scene sometimes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜