Prev | Current Page 1004 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Ask any
game developer, and they ??™ ll tell you that it ??™ s okay to hoard as much of a machine ??™ s resources as you can,
within reason of course. While deferring control of a thread to the operating system may be good
practice when GUI programming, which is what you are effectively doing with the delay method, this
isn ??™ t the right code of conduct when developing games. The reason for this is that it ??™ s an unreliable
method. You never really know if the operating system will return with due haste to your application,
which can make things seem sluggish and unplayable.
The way to avoid this issue is to use a Timer object. Timers are very simple things, but they allow you to
calculate the amount of time that has passed, and with such knowledge, you can personally manage
whether to execute a sequence of events, or not.
One would normally create a Timer object for a repetitive procedure that needs to recur every so many
milliseconds. This may be different for many processes within a game, so multiple Timer s can come into
play at once.


Pages:
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016