PDA

View Full Version : AS3 - framerate independent game



pi3rc3
February 14th, 2007, 07:24 PM
im trying to switch my game, that is using onEnterFrame to update the game, over to a timer based update so it will be frame rate independent. how is something like this achieved?

senocular
February 14th, 2007, 07:37 PM
Timer class.

flash.utils.Timer (http://livedocs.macromedia.com/flex/201/langref/flash/utils/Timer.html)

pi3rc3
February 14th, 2007, 08:24 PM
so say i want my game to run 30 fps i would just set a timer to fire off every 33 miliseconds?

Dazzer
February 15th, 2007, 09:26 AM
Well, yes, but!

Timer is still dependent on Framerate, as such, your Timer will trigger AS CLOSE AS POSSIBLE to the frame. Since it cannot do anything between frames.