I'm trying to make my actor hit, pretty much. Here is the relevant code for him:
He switches to the first image (walt_back0hit.png) but doesn't switch back. The timer does not reset to 0, either. It just keeps counting. Why could it potentially be ignoring the second and third if statements?
Thank you for any help whatsoever!
boolean hasSpatula = false;
String [] forwards = new String [3];
String [] back = new String [3];
String [] right = new String [3];
String [] left = new String [3];
int direction = 0;
int timer = 0;
public void act()
{
isMoving();
setArmed();
if ( Greenfoot.isKeyDown("space") & hasSpatula == true )
{
if (direction == 1)
{
if (timer < 15)
{
setImage("walt_back0hit.png");
}
else if (timer > 15 & timer < 30)
{
setImage("walt_back0S.png");
}
else if (timer > 30)
{
timer = 0;
}
}
}
counter++;
timer++;
}
