This site requires JavaScript, please enable it in your browser!
Greenfoot back
GaijinVagabond
GaijinVagabond wrote ...

2018/7/25

Having issues with setImage()

GaijinVagabond GaijinVagabond

2018/7/25

#
So in the scenario the actor throws a fireball, when he does so his image switches to change his pose as if he really threw it. My issue is that when the key is pressed he throws the fireball and the image switches as planned...but then it doesn't switch back.
Agent40 Agent40

2018/7/25

#
You could just set up a timer to change the image back after a short amount of time.
 // In Constructor
private boolean Fireball = false;
private int TFireball = 0;
...

if (Greenfoot.isKeyDown("[inset key]"))
{
      setImage("[image name]"); // different code needed for directional based firing
      Fireball = true;
}
if (Fireball == true)
{
      TFireball++; // Or TFireball = TFireball + 1;
      if (TFireball >= 5) // Mess around with this integer to change how long the image stays for
      {
            Fireball = false;
            TFireball = 0;
      }
}
GaijinVagabond GaijinVagabond

2018/7/25

#
thanks that works great
You need to login to post a reply.