v0.8.0: tweaked lifecycle managment, actor thread is now allowed to end
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.WelcomeScene;
|
||||
import com.watabou.noosa.Game;
|
||||
@@ -224,7 +225,13 @@ public class ShatteredPixelDungeon extends Game {
|
||||
updateDisplaySize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy(){
|
||||
super.destroy();
|
||||
GameScene.endActorThread();
|
||||
}
|
||||
|
||||
public void updateDisplaySize(){
|
||||
platform.updateDisplaySize();
|
||||
}
|
||||
|
||||
@@ -204,6 +204,8 @@ public abstract class Actor implements Bundlable {
|
||||
return current != null;
|
||||
}
|
||||
|
||||
public static boolean keepActorThreadAlive = true;
|
||||
|
||||
public static void process() {
|
||||
|
||||
boolean doNext;
|
||||
@@ -284,7 +286,7 @@ public abstract class Actor implements Bundlable {
|
||||
}
|
||||
}
|
||||
|
||||
} while (true);
|
||||
} while (keepActorThreadAlive);
|
||||
}
|
||||
|
||||
public static void add( Actor actor ) {
|
||||
|
||||
@@ -505,6 +505,13 @@ public class GameScene extends PixelScene {
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public static void endActorThread(){
|
||||
if (actorThread.isAlive()){
|
||||
Actor.keepActorThreadAlive = false;
|
||||
actorThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPause() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user