v2.2.0: fixed further issues with mob sprite sorting =S
This commit is contained in:
@@ -896,12 +896,18 @@ public class GameScene extends PixelScene {
|
|||||||
scene.mobs.sort(new Comparator() {
|
scene.mobs.sort(new Comparator() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Object a, Object b) {
|
public int compare(Object a, Object b) {
|
||||||
|
//elements that aren't CharSprites go to the end of the list
|
||||||
if (a instanceof CharSprite && b instanceof CharSprite) {
|
if (a instanceof CharSprite && b instanceof CharSprite) {
|
||||||
return (int) Math.signum((((CharSprite) a).y + ((CharSprite) a).height())
|
return (int) Math.signum((((CharSprite) a).y + ((CharSprite) a).height())
|
||||||
- (((CharSprite) b).y + ((CharSprite) b).height()));
|
- (((CharSprite) b).y + ((CharSprite) b).height()));
|
||||||
}
|
} else if (a instanceof CharSprite){
|
||||||
|
return -1;
|
||||||
|
} else if (b instanceof CharSprite){
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user