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.
Asked
Active
Viewed 1,246 times
1 Answers
5
Try NOT to use Cocoa’s NSTimer. Instead use cocos2d’s own scheduler. If you use cocos2d scheduler, you will have:
- automatic pause/resume.
- when the
CCLayer (CCScene, CCSprite, CCNode)
enters the stage the timer will be
- automatically activated, and when it leaves the stage it will be
- automatically deactivated. Your target/selector will be called with a delta time
from here (old broken link) http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:best_practices
updated link 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.

madmik3
- 6,975
- 3
- 38
- 60
-
1@madmik2 Thanks! I just replaced one of my timers with schedule method. Now, I have only one NSTimer in my application. Thanks for your input! – azamsharp Mar 07 '11 at 21:23