Skip to content

Commit

Permalink
Fix editing animations being queued
Browse files Browse the repository at this point in the history
  • Loading branch information
suluke committed May 10, 2014
1 parent 7456d77 commit 3c9cbef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/de/croggle/game/event/BoardEventMessenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void notifyEat(ColoredAlligator eater,
InternalBoardObject eatenFamily, int eatenPositionInParent) {
for (BoardEventListener listener : listeners) {
listener.onEat(eater, eatenFamily, eatenPositionInParent);
;
}
}

Expand All @@ -99,7 +98,6 @@ public void notifyAgedAlligatorVanishes(AgedAlligator alligator,
public void notifyBoardRebuilt(Board board) {
for (BoardEventListener listener : listeners) {
listener.onBoardRebuilt(board);
;
}
}

Expand Down Expand Up @@ -133,7 +131,6 @@ public void notifyAlligatorAged(ColoredAlligator colored, AgedAlligator aged) {
public void notifyObjectPlaced(InternalBoardObject placed) {
for (BoardEventListener listener : listeners) {
listener.onObjectPlaced(placed);
;
}
}

Expand Down
20 changes: 16 additions & 4 deletions src/de/croggle/ui/renderer/BoardActorBoardChangeAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public void onEat(final ColoredAlligator eater,
final float eaterHeight = eaterActor.getHeight();
final float eaterScaleX = eaterActor.getScaleX();
final float eaterScaleY = eaterActor.getScaleY();
final float moveDuration = moveToEaterAnimationDuration
* speedFactor;
final float moveDuration = moveToEaterAnimationDuration * speedFactor;
final float openJawDuration = openJawAnimationDuration * speedFactor;
eaterActor.setOrigin(eaterWidth / 2, eaterHeight / 2);
// don't forget this animation when summing up durations later
Expand Down Expand Up @@ -301,6 +300,19 @@ private void applyDeltasAnimated(List<ActorDelta> deltas) {
registerAnimationActions(duration, actions.toArray(new Action[0]));
}

private void applyDeltasAnimatedImmediately(List<ActorDelta> deltas) {
final List<ActorDelta> created = filterCreated(deltas, true);
Action action;
for (ActorDelta delta : deltas) {
action = applyDeltaAnimated(delta);
action.getActor().addAction(action);
}
final List<Action> creations = applyCreationDeltas(created);
for (Action creation : creations) {
creation.getActor().addAction(creation);
}
}

private Action applyDeltaAnimated(ActorDelta delta) {
final float repositionDuration = repositionAnimationDuration
* speedFactor;
Expand Down Expand Up @@ -438,7 +450,7 @@ public void onObjectMoved(InternalBoardObject moved) {

void fixLayout() {
List<ActorDelta> deltas = b.getLayout().getDeltasToFix();
applyDeltasAnimated(deltas);
applyDeltasAnimatedImmediately(deltas);
Pool<ActorDelta> deltaPool = b.getLayout().getDeltaPool();
for (ActorDelta delta : deltas) {
deltaPool.free(delta);
Expand Down Expand Up @@ -504,7 +516,7 @@ public void setAnimationsFinishedLitener(AnimationsFinishedListener listener) {

public void setAnimationSpeed(float speed) {
this.speedFactor = 1 / speed; // invert, since speed=2 means half the
// time
// time
}

private static class RecolorAction extends Action {
Expand Down

0 comments on commit 3c9cbef

Please sign in to comment.