v2.2.0: char sprites are now drawn in order from top to bottom
This commit is contained in:
@@ -25,6 +25,8 @@ import com.watabou.utils.Random;
|
|||||||
import com.watabou.utils.Reflection;
|
import com.watabou.utils.Reflection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class Group extends Gizmo {
|
public class Group extends Gizmo {
|
||||||
|
|
||||||
@@ -310,4 +312,8 @@ public class Group extends Gizmo {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void sort(Comparator c){
|
||||||
|
Collections.sort(members, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ import com.watabou.utils.RectF;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class GameScene extends PixelScene {
|
public class GameScene extends PixelScene {
|
||||||
@@ -885,6 +886,22 @@ public class GameScene extends PixelScene {
|
|||||||
sprite.visible = Dungeon.level.heroFOV[mob.pos];
|
sprite.visible = Dungeon.level.heroFOV[mob.pos];
|
||||||
mobs.add( sprite );
|
mobs.add( sprite );
|
||||||
sprite.link( mob );
|
sprite.link( mob );
|
||||||
|
sortMobSprites();
|
||||||
|
}
|
||||||
|
|
||||||
|
//ensures that mob sprites are drawn in the correct order, in case of overlap
|
||||||
|
public static void sortMobSprites(){
|
||||||
|
if (scene != null){
|
||||||
|
scene.mobs.sort(new Comparator() {
|
||||||
|
@Override
|
||||||
|
public int compare(Object a, Object b) {
|
||||||
|
if (a instanceof CharSprite && b instanceof CharSprite){
|
||||||
|
return ((CharSprite) a).ch.pos - ((CharSprite) b).ch.pos;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void prompt( String text ) {
|
private synchronized void prompt( String text ) {
|
||||||
|
|||||||
@@ -724,6 +724,7 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
|||||||
motion = null;
|
motion = null;
|
||||||
ch.onMotionComplete();
|
ch.onMotionComplete();
|
||||||
|
|
||||||
|
GameScene.sortMobSprites();
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user