Cocos2D project with many scenes does not release memory properly

后端 未结 2 1542
一生所求
一生所求 2021-02-06 13:12

I\'ve got a great problem and I don\'t understand very well why occurs. This is the case:

  • Have a great project in Cocos2D with 10 scenes. Each scenes is a page of
2条回答
  •  北海茫月
    2021-02-06 13:56

    After months of working, I learned the most important lesson on Cocos2D. The retain increase by one when you put any CCNode object on a CCArray or NSArray or NSDictionary... This means you must release the objects from this objects before the CCLayer or CCScene dealloc.

    You must put a [array removeAllObjects] or [dictionary release] on the - (void) cleanup and after all your objects has removed, then put a [super cleanup];

    In the meantime, on - (void) onExit you must remove all scheduler from the instance. Not only a scheduler itself. Remember to stopAllActions on any CCNode. But, carefully, because stoping actions from CCNodes (Sprites or something) must be on cleanup, before any removeAllObjects.

    And remember: if CCLayer or CCScene does not remove properly, SimpleAudioEngine not will release the audio too.

提交回复
热议问题