I'm trying to make enemies explode when they are hit by my bullet class, I have it on the player when it is killed, but I use a delay technique to go through the sprites of the animation this is fine for dying but using this for enemies means that the game gets delayed every time I shoot someone, here is the code;
ex1-10 are the frames for the explosion.
Any help would be appreciated such as a way to make the delay only happen to the object instead of the entire game.
Thank you in advanced.
public void eat()
{
Actor food = getOneIntersectingObject(bullet.class);
if(food !=null)
{
setImage("ex1.png");
Greenfoot.delay(4);
setImage("ex2.png");
Greenfoot.delay(4);
setImage("ex3.png");
Greenfoot.delay(4);
setImage("ex4.png");
Greenfoot.delay(4);
setImage("ex5.png");
Greenfoot.delay(4);
setImage("ex6.png");
Greenfoot.delay(4);
setImage("ex7.png");
Greenfoot.delay(4);
setImage("ex8.png");
Greenfoot.delay(4);
setImage("ex9.png");
Greenfoot.delay(4);
setImage("ex10.png");
Greenfoot.delay(4);
getWorld().removeObject(food);
getWorld().removeObject(this);
}
}


