Re: NSTimer questions
Re: NSTimer questions
- Subject: Re: NSTimer questions
- From: Daniel Todd Currie <email@hidden>
- Date: Wed, 22 Sep 2004 18:11:06 -0700
A quick solution is to base your animation cycle on a timer, but
actually update the drawing based on the clock time, rather than the
timer. That way, if a timer takes twice as long as expected to fire,
your drawing will essentially skip a frame and stay on schedule (which
it should probably do anyway, if the run loop is so bogged down that
the timer is late).
-- DTC
On 2004 Sep 22, at 05: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).
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.
Is there any way I can do screen updates safely away from the main
thread or what path should I take? I see the load on the computer only
ticks in at less than 10% when running the application, so there
should be plenty to borrow from.
/Christoffer
_______________________________________________
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
_______________________________________________
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