0

我正在开发一个游戏,通过触摸在屏幕上拖放对象。我正在使用SurfaceView.

有时我需要制作动画以在用户播放时移动对象。

这是我的代码:

//raise it 
m = new MyLinearMoveAnimation(container1, Config.AXIS_Y, topLine, 2*Speed);
t = new Thread(m);
t.start();
while(delivering);
try {t.join();} catch (InterruptedException e1) {e1.printStackTrace();}
while(t.isAlive());

//move to destination column
m = new MyLinearMoveAnimation(container2, Config.AXIS_X, Config.IMAGE_X, 2*Speed);
t = new Thread(m);
t.start();
while(delivering);
try {t.join();} catch (InterruptedException e1) {e1.printStackTrace();}
while(t.isAlive());

这两个动画一个接一个地执行。我希望它们同时运行。我怎样才能做到这一点?

4

1 回答 1

-1

你可以在android中使用异步任务

http://developer.android.com/reference/android/os/AsyncTask.html

多亏了异步任务,您可以同时运行不同的任务,如果您在不同的异步任务中启动动画,它们将在同一时间执行

于 2013-04-09T12:03:44.837 回答