I am making changes to the shooting game in the tutorial. I have created my own explosion .png's called "Explode" and "blank". I want to be able to run the explosion graphic over the Player sprite for only about 3 seconds after a collision. I've written some code but it doesn't work. How do I do this?
Here is my code:
protected static Texture image;
protected static Texture aniImage1;
protected static boolean shotOnScreen;
protected static boolean beenDestroyed;
protected static Animo explode;
private long time;
private long endTime;
public static void init(){
if (image!=null){
return;
}
image = new Texture("images/player.png", 255, 255, 255);
new Mask(image);
explode = new Animo();
aniImage1 = new Texture("images/Explode.PNG", 255, 255, 255);
explode.add(aniImage1);
aniImage1 = new Texture("images/blank.png", 255, 255, 255);
explode.add(aniImage1);
explode.setSpeed(100000000);
explode.start();
}
...
public void explodeAnimo(){
animo = explode;
time = explode.getTime();
endTime = time + 1000000;
while ((endTime) > time){
time = explode.getTime();
}
if (endTime <= time)
explode.stop();
}
...
public void onCollision(){
explodeAnimo();
}