0
我使用下面的代码来动画化一个图像,它的工作正常,但动画图像看起来很少跳跃,而不是平滑移动(它看起来像移动,但不是很光滑,它会停止一段时间)Can任何人在代码中发现问题?Android图像移动动画问题
class AnimationLoop implements Runnable
{
public void run()
{
while(true)
{
while(running)
{
try
{
Thread.sleep(30);
}
catch(InterruptedException ex) {}
}
}
counter+=1;
updatePosition(0);
main.postInvalidate(); //main is type panel
}
private synchronized void updatePosition(int index) {
mYPositions[index]-=2; // animate from bottom to top
mXPositions[index]-=2;
}
@Override
protected void onDraw(Canvas canvas)
{
canvas.drawBitmap(balloonSet.get(0), mXPositions[0], mYPositions[0],null);
}
我仍然可以看到..其像跳跃.. – vnshetty
我已经添加了答案的链接。希望能帮助到你。 – Ronnie