At 09:06 PM 8/23/2004, geoff wrote:
Hey,

I'd just like to ask if nilEvents are accurate for timing events
(animations/games). In my program, i made a rectangle move  every nilevent
but it wouldn't move very consistently.

Do nil events happen every event or just when there are no other events to
register?

You don't normally get a nilEvent unless you call EvtGetEvent() with a finite timeout value (something other than evtWaitForever) and the timeout expires. If you call EvtGetEvent() with a timeout of, say, 10 ticks, and it returns a nilEvent, you know that you're getting the event exactly 10 ticks after making the call.


The typical way of getting something to happen exactly when you want it to is:

First, figure out when you want the something to happen, in terms of "the tick count since the last reset". Typically, you'll start by calling TimGetTicks() to get the current time and add a suitable number of ticks to that to determine a time in the future. Record this time somewhere. Then, whenever your event loop calls EvtGetEvent(), first call TimGetTicks() and subtract that from the time when you want the something to happen. Use this difference as the timeout value in the EvtGetEvent() call. Do the something if and only if you get a nilEvent back from EvtGetEvent().

Greg Lutz
NearSpace, Inc.


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to