In my game I'm trying to add power-ups. I have imported the SimpleTimer class so that I can ensure that the duration of the power-up is only five seconds, but the timer starts as soon as I compile the world, and even if the latter if statement is true, the power-up remains active.
Okay, I've realised that every act() the powerUpTimer will be marked if any power-ups are active, so that's one problem removed. But why does it start when I compile it, and not when I get a power-up?
public void applyPowers() { if (pointBoostActive == true || allRedActive == true || invincibilityActive == true || timeSlowActive == true) { powerUpTimer.mark(); } if(powerUpTimer.millisElapsed() >= 5000) { pointBoostActive = false; allRedActive = false; invincibilityActive = false; timeSlowActive = false; } }