i want the image to switch to one explosive sprite to another explosive sprite right after then remove itself from the world, when a different object strikes with this one and triggers the effects.
Any help is great,
thanks
public void act() { if(!destroyed) { //put your normal act() method here... } else { explode(); } } private void explode() { frame++; if(frame == 1) setImage(yourFirstSprite); else if(frame == 4) setImage(yourSecondSprite); //you can have as many frames to the animation as you like. else if(frame == 7) setImage(yourThirdSprite); else if(frame == 10) //remove self after the explosion animation is over getWorld().removeObject(this); }
else if(frame == 7) setImage(yourThirdSprite);
setImage("castle.png");
{ Actor collided; collided = getOneIntersectingObject(ball.class); if (collided!=null) { frame++; if(frame == 1) setImage("sprite1.png"); else if(frame == 3) setImage("sprite2.png"); else if(frame == 5) setImage("sprite3.png"); else if(frame == 7) setImage("sprite4.png"); else if(frame == 9) setImage("sprite5.png"); else if(frame == 11) getWorld().removeObject(this); }
private int frame = 0; private boolean destroyed = false; public void act() ... private void explode() ...
Actor collided; collided = getOneIntersectingObject(ball.class); if (collided!=null) destroyed = true;
if (!destroyed && getOneIntersectingObject(ball.class) != null) destroyed = true; if (destroyed) { explode(); return; } // The code for when not destroyed goes here
if (!=destroyed && getOneIntersectingObject(ball.class) != null) destroyed = true;