v0.6.0: fixed the game making a new thread with each new gamescene
This commit is contained in:
parent
34b2f9dc1f
commit
af5e55db41
|
@ -22,8 +22,8 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.actors;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
|
@ -210,11 +210,14 @@ public abstract class Actor implements Bundlable {
|
|||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
acting = null; //continue
|
||||
}
|
||||
}
|
||||
|
||||
doNext = acting.act();
|
||||
|
||||
doNext = !Thread.interrupted()
|
||||
&& acting != null
|
||||
&& acting.act();
|
||||
|
||||
if (doNext && !Dungeon.hero.isAlive()) {
|
||||
doNext = false;
|
||||
current = null;
|
||||
|
@ -228,7 +231,7 @@ public abstract class Actor implements Bundlable {
|
|||
try {
|
||||
Thread.currentThread().wait();
|
||||
} catch (InterruptedException e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
//continue, should just hit wait again
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,6 +419,12 @@ public class GameScene extends PixelScene {
|
|||
scene = null;
|
||||
Badges.saveGlobal();
|
||||
|
||||
if (actorThread.isAlive()){
|
||||
synchronized (actorThread) {
|
||||
actorThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
|
@ -432,7 +438,7 @@ public class GameScene extends PixelScene {
|
|||
}
|
||||
}
|
||||
|
||||
private final Thread t = new Thread() {
|
||||
private static final Thread actorThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Actor.process();
|
||||
|
@ -450,13 +456,13 @@ public class GameScene extends PixelScene {
|
|||
if (!freezeEmitters) water.offset( 0, -5 * Game.elapsed );
|
||||
|
||||
if (!Actor.processing() && Dungeon.hero.isAlive()) {
|
||||
if (!t.isAlive()) {
|
||||
if (!actorThread.isAlive()) {
|
||||
//if cpu time is limited, game should prefer drawing the current frame
|
||||
t.setPriority(Thread.NORM_PRIORITY - 1);
|
||||
t.start();
|
||||
actorThread.setPriority(Thread.NORM_PRIORITY - 1);
|
||||
actorThread.start();
|
||||
} else {
|
||||
synchronized (t) {
|
||||
t.notify();
|
||||
synchronized (actorThread) {
|
||||
actorThread.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user