Cocos2d应用程序中的NSTimer [英] NSTimer in Cocos2d Application
问题描述
在Cocos2d文档中,写到使用NSTimer不是一个好主意。为什么不推荐使用NSTimer。我知道有一个Cocos2d的schedule方法。
In Cocos2d documents it is written that it is not a good idea to use NSTimer. Why is it not recommended to use NSTimer. I know there is a schedule method of Cocos2d.
推荐答案
尝试不使用Cocoa的NSTimer。而应使用cocos2d自己的调度程序。
如果使用cocos2d调度程序,您将有:
Try NOT to use Cocoa’s NSTimer. Instead use cocos2d’s own scheduler. If you use cocos2d scheduler, you will have:
- 自动暂停/恢复。
- 当
CCLayer(CCScene,CCSprite,CCNode)
进入阶段时,定时器将为
- 自动激活,当
离开舞台时, - 自动停用。您的
目标/选择器将以
delta时间调用
从这里(旧的链接)
http: //www.cocos2d-iphone.org/wiki/doku.php/prog_guide:best_practices已更新连结
http:// ec2-50-16-191-191 .compute-1.amazonaws.com / wiki / doku.php / prog_guide:best_practices我会添加你添加一些不必要的开销。如果你有很多计时器可能是一个很大的开销。
I would add you are adding some unwanted overhead too. If you have a lot of timers that could be a good bit of overhead.
这篇关于Cocos2d应用程序中的NSTimer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 自动激活,当