I'm working on a game where objects are dragged and dropped around the screen via touch. I'm doing this using a SurfaceView
.
Sometimes I need to make an animation to move an object while the user is playing.
This is my code:
//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());
These two animations are executed one after the other. I would like for them to both run at the same time. How can I do this?
you can use async task in android
http://developer.android.com/reference/android/os/AsyncTask.html
Thanks to async task you can run differents tasks at the same time, if you launch your animations in differents async task they 'll execute in the same tame