NSTimer Running always or somtimes

Sage
Posts: 1,403
Joined: 2005.07
Post: #1
Im making a grid based game and im wating to animate the characters move for a short time after a key is pressed, should I start an NSTimer each time a key is pressed or have one always running?

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #2
Completely up to you. You'd get the same effect either way. Personally, I'd leave a timer running all the time, because I'd only have to set it up once, and would most likely use it for other things in the future. If you fire off a new timer each time you need one, you'll probably waste less CPU time, but the amount that it would use in the first place is so small that this is irrelevant.

So, do whichever seems the most logical to you.

- Alex Diener
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #3
I would personally keep one running the whole time too, NSTimer takes up very little processing power and create and dealloc it over and over again seems like a headache you dont need to put yourself through. But either way will work just fine.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #4
It not me with the headache, it my computer and it doesnt seem to mind.
I guess I better try the other one though, seeing as it does seem like the better option, thanks guys.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Using NSTimer in SDL Loop. Talyn 7 4,323 Oct 7, 2008 09:40 PM
Last Post: OneSadCookie
  NSTimer / animation framerate question MonitorFlickers 5 5,233 Dec 4, 2005 01:10 PM
Last Post: MonitorFlickers
  Cocoa Event Loop/NSTimer revisited Fenris 6 5,468 Oct 29, 2005 11:27 PM
Last Post: maaaaark
  NSTimer/NSAffineTransform Coin 6 3,999 Feb 4, 2005 06:23 PM
Last Post: Coin