I'm making a japplet and stuck with an 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){
}
}
There is no animation: nothing happens during the cycle, the repaint () method seems to work only after the sprite has stopped moving.
I would like to use only Swing for this, any ideas on how to proceed?
Thanks for reading.
source
share