Skip to content

Commit

Permalink
Add camera zoom tweening
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrain committed Apr 20, 2020
1 parent 3d93ca2 commit 06716fc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public void update(float delta) {
lastShake.set(shake);
}

@Override
public float getZoomModeValue() {
return zoomModeValue;
}

@Override
public void setDistanceStoppingThreshold(float distanceThreshold) {
this.distanceThreshold = distanceThreshold;
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.6.30

* add camera zoom tweening

# Version 0.6.29

* add additional constructors to `AnimationSpritesheet`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum ZoomMode {
TO_HEIGHT;
}

float getZoomModeValue();

/**
* Sets a new threshold to where the camera should stop tracking.
* The distance also takes camera zoom into account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class GameCameraTween implements TweenAccessor<GameCamera> {

public static final int DEFAULT_ZOOM_FACTOR = 1;
public static final int TARGET_TRACKING_SPEED = 2;
public static final int ZOOM_WIDTH = 3;
public static final int ZOOM_HEIGHT = 4;

@Override
public int getValues(GameCamera target, int tweenType, float[] returnValues) {
Expand All @@ -17,6 +19,11 @@ public int getValues(GameCamera target, int tweenType, float[] returnValues) {
case TARGET_TRACKING_SPEED:
returnValues[0] = target.getTargetTrackingSpeed();
return 1;
case ZOOM_WIDTH:
case ZOOM_HEIGHT:
returnValues[0] = target.getZoomModeValue();
return 1;

}
return 0;
}
Expand All @@ -30,6 +37,12 @@ public void setValues(GameCamera target, int tweenType, float[] newValues) {
case TARGET_TRACKING_SPEED:
target.setTargetTrackingSpeed(newValues[0]);
break;
case ZOOM_WIDTH:
target.setZoom(newValues[0], GameCamera.ZoomMode.TO_WIDTH);
break;
case ZOOM_HEIGHT:
target.setZoom(newValues[0], GameCamera.ZoomMode.TO_HEIGHT);
break;
}
}
}

0 comments on commit 06716fc

Please sign in to comment.