The officially recommended way to implement timers in a FlashPunk game is to override Entity.update() in various places and to either: 1) rely on a fixed timestep, or 2) rely on FP.elapsed.
I’m just starting to learn FlashPunk, and there may be more to the story than what I’m seeing, but I’m a little concerned about implementing timers this way. For one thing, you can’t ever really rely on a specified pace at runtime - lag spikes and such can always interfere with that.
Alright, so why not use FP.elapsed for either kind of timestep, as an extra precaution? Because it appears to round things off just a little, which can cause things to become inaccurate over time. Generally, when implementing a timer, it would probably be much better to check either the time on the computer, the number of milliseconds since the swf first started running, or something else to that effect.
Which makes me wonder about using flash.utils.getTimer(), but where would you put it? I don’t want to code this in an unclean way or inefficient way, which would rule out creating a static class with a property for this that keeps getting accessed everywhere. FlashPunk is heavily centered around Entity.update(), so I wouldn’t want to interfere with the rhyme and reason of usig the update() function.
Etc. Maybe somebody knows more about FP.elapsed and can explain that it’s actually quite reliable? Or maybe another solution would be better? I glanced at one post where something to do with tweening was mentioned, but I’m a little inexperienced specifically with game development, so I’m trying to take care of this now and learn about tweening a little further down the road. Thank you.