1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
private Clock clock;
private Timer counter;
//la partie suivante marche nikel, qui s'encharge par l'affichage et la
//mouvement de la bombe
if ((keyState & FIRE_PRESSED) != 0) {
this.bomberbomb.setFrameSequence(gamedesign.Bomber_Bombseq);
this.bomberbomb.setPosition(spritebomber.getX(), spritebomber.getY());
this.bomberbomb.setVisible(true);
this.lm.insert(bomberbomb, 0);
this.bomb_bombertimer.forward();
// la partie suivante maintenant ne s#execute pas, on dirais qu'elle n'existe
//pas
this.clock = new Clock(3);
this.counter = new Timer();
counter.schedule(clock,0,1 );
while(this.stop == false)
{
if(clock.getTimeLeft() == 0) {
stop = true;
this.lm.remove(bomberbomb);
}
}
}
public class Clock extends TimerTask
{
int timeLeft;
public Clock(int maxTime) {
timeLeft = maxTime;
}
public void run() {
timeLeft--;
}
public int getTimeLeft() { return this.timeLeft; }
} |