This following isn’t directed towards FlashPunk in particular, but is rather a general programming question.
Usually when I need to wait a certain amount of time before doing something, I use a simple if-statement to track the elapsed time:
If (timer > 0)
{
timer -= FP.elapsed
}
else
{
timer = 100 // reset timer
// ... do something
}
Is there any benefit of creating a dedicated class to handle timers (either an existing class such as FP’s Alarms or a custom class)? With FP’s alarms, I’d imagine it takes slightly more resources as the timer needs to be added to the tween list, then updated each frame. You’d also be called the “New” operator to create a new object versus creating a single Number variable. Thoughts?