Hi after everytime something is destroyed in my game i create a new object of an explosion animation done by the use of a thread class inside my surface view thread. After destroying multiple ships in a short period of time the app exits the activity. Why is this?
explosion ex = new explosion(x,y);
ex.start();
and
class explosion extends Thread implements Runnable{
private long startTime;
private int num = 0;
private int x;
private int y;
public explosion(int mx, int my){
x = mx;
y = my;
startTime = System.currentTimeMillis();
}
public void run(){
while(num < 3){
long millis = System.currentTimeMillis();
canvas.drawBitmap(explosions.get(num),x,y,null);
if(millis - startTime > 50){
startTime = System.currentTimeMillis();
num++;
Log.d("Explosion","Animate");
}
}
Log.d("Explosion","End Thread");
}
};
Copied from developer.android…
I believe this line is causing you to crash…
This link details the steps to update UI on another thread:
http://developer.android.com/resources/articles/painless-threading.html