My problem today is when i was creating my game everything is working fine but (Its a space shooter game like Space Invaders)
But when i wanted the enemies to like explode when they die (Using sprites) i bumped on some problem.. I don't realy know how to make
the game wait one second before it switches to next sprite.. And i can't use Thread.sleep for this because that will freeze the whole game.. And i don't realy know how i would use the timer for this.
I would realy like some help please.. But i also whant to learn from this.
Here is the method for bullet coliding with the enemy:
public void collisionResponse(Entity exe){
health = health - 50;
if(health <= 0){
graphic = 1;
if(graphic == 1){
setGraphic(explosion);
//Thread.sleep(500);
graphic++;
}
if(graphic == 2){
setGraphic(explosion2);
//Thread.sleep(500);
graphic++;
}
if(graphic == 3){
setGraphic(explosion3);
//Thread.sleep(500);
graphic++;
}
if(graphic == 4){
setGraphic(explosion4);
//Thread.sleep(500);
graphic++;
}
if(graphic == 5){
setGraphic(explosion5);
//Thread.sleep(500);
this.destroy();
graphic = 0;
}
}
}
And where i did a comment like //Thread.sleep(500); Thats where i need the sleep or wait..
Thanks!


Sign In
Create Account


Back to top









