I am making a JApplet and got stuck with a animation problem.
Here is my code :
this.sprite.setBounds(0,0,20,17);
this.sprite.setIcon(this.rangerDown);
for(int i = 0; i< 16;i++)
{
this.sprite.repaint();
this.sprite.setLocation(this.sprite.getX(), this.sprite.getY()+10);
try{
Thread.currentThread().sleep(100);
}catch(InterruptedException e){
}
}
With this, there is no animation : nothing happens during the loop, the repaint() method seems to only act once the sprite stopped moving.
I would like to use only Swing for this, any ideas of how to proceed ?
Thanks for reading.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…