• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimer questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer questions


  • Subject: Re: NSTimer questions
  • From: j o a r <email@hidden>
  • Date: Wed, 22 Sep 2004 14:38:51 +0200

Hej,

On 2004-09-22, at 14.19, Christoffer Lerno wrote:

I'm trying to reliably tick a NSTimer to drive animation.

However, on my iBook I notice I occasionally hickups.

Further investigation reveals that if I set a desired fps at 60, I might have that drop as low as 5 fps at times. (I give you times in fps because it is simpler that way, 5 fps actually means the delay for that frame was 0.2 seconds instead of 1/60th of a second which was the desired delay between firing of the timer.

The actual drawing isn't the problem (I timed that) - it's the timer which occasionally misses by as much as 200 ms.
I am suspecting that the accuracy of the timer is very dependent on what's happening in the run loop (like keyboard input and the like).

Timers will only fire when their thread is not busy. In other words, if you want the timer to fire at 60 Hz, you need to make sure that the stuff you do in response to the timer (or anything else that you do in that thread) takes upp less than 1/60 s.


However I have read that putting the whole thing in a different thread might be to invite all sorts of pain and suffering.
It would be tempting to move all animation and updates into a separate thread since it would make the game independent of interaction with menu-bar and the like. I'm pretty used to running threads in Java with the synchronizing of methods that entails, but I don't know what I need to watch out for when working with cocoa.

Please start with reading TF(ine)M, list archives, tutorials, et.c. This might be a starting point:


<http://developer.apple.com/documentation/Cocoa/Conceptual/ Multithreading/Multithreading.html>

j o a r

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTimer questions
      • From: Christoffer Lerno <email@hidden>
References: 
 >NSTimer questions (From: Christoffer Lerno <email@hidden>)

  • Prev by Date: Re: NSTimer questions
  • Next by Date: Re: Newbie question: how to release an object that has been autoreleased
  • Previous by thread: Re: NSTimer questions
  • Next by thread: Re: NSTimer questions
  • Index(es):
    • Date
    • Thread