Hello. First I’m sorry if my english sounds weird. I’m creating a small animation. There are multiple balls “bouncing” on Frame and if any of them hits a placed special ball, it will grow big and become another special ball (which means any of the rest ball can be special too by hitting any of two special things and repeat again). However a special ball’s lifespan is only 3 seconds. The Ball class extends Thread so it can call sleep(3000) and vanished after done. Ball isn’t the main class.
class Ball extends Thread{
public void run(){
try{
size = 100;
isSpecial = true;
this.sleep(3000);
isDone = true; //tell main class to remove this "ball"
}
catch (InterruptedException e){
System.err.println(e);
}
}
}
The main class puts every balls in an ArrayList. Main class uses Gudradrain’s template. Now I want to include Pause feature. When paused the canvas will draw another image and doesnt call update() method. The problem is the sleep(3000) on every ball is still counting so when we back to the animation, all special balls suddenly disappear. How to make all special balls sleep only on non-paused state? in other word, pause the ball’s sleep when enter pause state.
Thanks