AndEngine – TimerHandler

While programming with AndEngine, TimerHandler provided me a means to control when certain elements of my game should occur.

This was especially useful when I wanted something to be done repeatedly after a certain amount of time.

///This function sets up a TimeHandler.
private void mTimeHandler()
TimerHandler xTimerHandler;

//This specific timer is set to go off 10 seconds
//after the function is called.
//The “true” parameter resets the timer so that it
//will continually go off EVERY 10 seconds.
registerUpdateHandler(xTimerHandler = new TimerHandler(10.0f, true, new ITimerCallback()

//Everything in here is what you want to occur once the timer is goes off.
public void onTimePassed(final TimerHandler zTimerHandler)
//DO SOMETHING AMAZING or simply necessary.