v0.6.1b: fixed rare crashes caused by floating text
This commit is contained in:
parent
d71559e0cc
commit
70cce2c8b3
|
@ -42,7 +42,7 @@ public class FloatingText extends RenderedText {
|
||||||
|
|
||||||
private float cameraZoom = -1;
|
private float cameraZoom = -1;
|
||||||
|
|
||||||
private static SparseArray<ArrayList<FloatingText>> stacks = new SparseArray<ArrayList<FloatingText>>();
|
private static final SparseArray<ArrayList<FloatingText>> stacks = new SparseArray<ArrayList<FloatingText>>();
|
||||||
|
|
||||||
public FloatingText() {
|
public FloatingText() {
|
||||||
speed.y = - DISTANCE / LIFESPAN;
|
speed.y = - DISTANCE / LIFESPAN;
|
||||||
|
@ -65,7 +65,9 @@ public class FloatingText extends RenderedText {
|
||||||
@Override
|
@Override
|
||||||
public void kill() {
|
public void kill() {
|
||||||
if (key != -1) {
|
if (key != -1) {
|
||||||
stacks.get( key ).remove( this );
|
synchronized (stacks) {
|
||||||
|
stacks.get(key).remove(this);
|
||||||
|
}
|
||||||
key = -1;
|
key = -1;
|
||||||
}
|
}
|
||||||
super.kill();
|
super.kill();
|
||||||
|
@ -116,30 +118,32 @@ public class FloatingText extends RenderedText {
|
||||||
|
|
||||||
private static void push( FloatingText txt, int key ) {
|
private static void push( FloatingText txt, int key ) {
|
||||||
|
|
||||||
txt.key = key;
|
synchronized (stacks) {
|
||||||
|
txt.key = key;
|
||||||
|
|
||||||
ArrayList<FloatingText> stack = stacks.get( key );
|
ArrayList<FloatingText> stack = stacks.get(key);
|
||||||
if (stack == null) {
|
if (stack == null) {
|
||||||
stack = new ArrayList<FloatingText>();
|
stack = new ArrayList<FloatingText>();
|
||||||
stacks.put( key, stack );
|
stacks.put(key, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.size() > 0) {
|
if (stack.size() > 0) {
|
||||||
FloatingText below = txt;
|
FloatingText below = txt;
|
||||||
int aboveIndex = stack.size() - 1;
|
int aboveIndex = stack.size() - 1;
|
||||||
while (aboveIndex >= 0) {
|
while (aboveIndex >= 0) {
|
||||||
FloatingText above = stack.get( aboveIndex );
|
FloatingText above = stack.get(aboveIndex);
|
||||||
if (above.y + above.height() > below.y) {
|
if (above.y + above.height() > below.y) {
|
||||||
above.y = below.y - above.height();
|
above.y = below.y - above.height();
|
||||||
|
|
||||||
below = above;
|
below = above;
|
||||||
aboveIndex--;
|
aboveIndex--;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stack.add( txt );
|
stack.add(txt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user