I have this method i create that adds a sprite to my andengine scene every second.
private void createSpriteSpawnTimeHandler(){
TimerHandler spriteTimerHandler;
float mEffectSpawnDelay = 1f;
spriteTimerHandler = new TimerHandler(mEffectSpawnDelay,true,new ITimerCallback(){
@Override
public void onTimePassed(TimerHandler pTimerHandler) {
addFace();
}
});
getEngine().registerUpdateHandler(spriteTimerHandler);
}
What i want to do is, for example
if(x <= b){
mEffectSpawnDelay = mEffectSpawnDely - .2f;
}
The problem i am running into is that when the variable is changed. I cant figure out a way to update the TimeHandler letting it know to change the mEffectSpawnDelay variable.
Any suggestions?
I have created this class just now for you. I think it should work, and you can change the interval between ticks as you wish. (Haven’t tested it, so you might need to make some small fixes. But it looks fine IMO.)
Use it this way:
If you ever want to change the interval, you should keep a reference to the timer. Anyways, to change interval use: