【发布时间】:2011-08-08 03:14:55
【问题描述】:
我正在通过在 JApplet 中制作一个小游戏来学习 Java。 我的精灵动画有点问题。
代码如下:
this.sprite.setBounds(0,0,20,17);
this.sprite.setIcon(this.rangerDown);
for(int i = 0; i< 16;i++)
{
this.sprite.setBounds(this.sprite.getX(), this.sprite.getY()+1, 20, 17);
this.sprite.update(this.sprite.getGraphics());
try{
Thread.currentThread().sleep(100);
}catch(InterruptedException e){
}
}
它在动画过程中留下了一些闪烁。动画结束后,闪烁消失了,但有点难看……我想我错过了一些步骤。 我使用这种方法是因为它现在可以提供更好的结果,但如果可能的话,我希望不使用 AWT,而是使用 Swing。
任何想法如何摆脱闪烁?
感谢阅读。
Screenshoot(无法发布图片,抱歉)。
【问题讨论】: