【发布时间】:2011-12-17 10:43:30
【问题描述】:
读了这么多之后,我可以看到在更换场景时我应该怎么做有很多想念的理解。 在 dealloc 方法上,我是否必须释放我所有的计时器?还是 cocos2d 呢??
我在启动时有 3 个计时器:
[self schedule: @selector(contact:)];
[self schedule:@selector(tick:)];
[self schedule: @selector(randomsActions:) interval:0.1];
在我将场景替换为菜单(replaceScene)之前,我会这样做:
[self unschedule:@selector(randomsActions:)] ; //stop timer
[self unschedule:@selector(contact:)] ; //stop timer
[self unschedule:@selector(contact:)] ; //stop timer
但它崩溃了。(我见过有人说我不必取消他们的计划?)
所以我在我的 dealloc 中尝试了这个:
[[CCScheduler sharedScheduler] unscheduleAllSelectorsForTarget: self];
第二次也崩溃(在课堂上崩溃:CCScheduler.m)
在我的 dealloc 中我也放了这个:(我需要吗???)
删除_contactListener;
[自我删除AllChildrenWithCleanup: 是];
删除世界;
世界 = NULL;
[超级释放];
这里发生了什么? 有人可以告诉我在替换场景时应该在 dealloc 中做什么吗? 我应该怎么处理我的计时器???
谢谢。
【问题讨论】:
标签: cocos2d-iphone