Hello,
I tried to add a timer that does nothing if the boolean is false but activates if the boolean is true. But it doesn't work.
This is the code i've used:
The timer is set to 100 and it should start substracting till it reaches 0, and then reset the world. But it only subracts one.
I think i don't really know how booleans work yet :D
how do i fix my code?
Thanks.
private boolean startedResetTimer = false; private int resetTimer = 100;
public void hitEnemy()
{
if (isTouching(Enemy.class))
{
explode2();
startedResetTimer = true;
System.out.println("hit");
}//else startedResetTimer = false;
if (startedResetTimer == true)
{
System.out.println("timer started");
resetTimer--;
System.out.println(resetTimer);
}
if (resetTimer <= 0)
{
Greenfoot.setWorld(new Spielfeld());
}
}
