Skip to content

Commit

Permalink
Make "flipAnimation" accessible from outside the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-wilke committed Dec 1, 2020
1 parent ed94b50 commit 649ceea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public AnimationController(final Spritesheet sprite, final boolean loop) {
this(new Animation(sprite, loop, Resources.spritesheets().getCustomKeyFrameDurations(sprite)));
}

public static Animation flipAnimation(Animation anim, String newSpriteName) {
final BufferedImage flippedImage = Imaging.flipSpritesHorizontally(anim.getSpritesheet());
Spritesheet flippedSpritesheet = Resources.spritesheets().load(flippedImage, newSpriteName, anim.getSpritesheet().getSpriteWidth(), anim.getSpritesheet().getSpriteHeight());
return new Animation(flippedSpritesheet, anim.isLooping(), anim.getKeyFrameDurations());
}

@Override
public void add(final Animation animation) {
if (animation == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,4 @@ private void init(boolean useFlippedSpritesAsFallback) {
this.customDeathAnimations = new String[0];
}
}

private Animation flipAnimation(Animation anim, String newSpriteName) {
final BufferedImage flippedImage = Imaging.flipSpritesHorizontally(anim.getSpritesheet());
Spritesheet flippedSpritesheet = Resources.spritesheets().load(flippedImage, newSpriteName, anim.getSpritesheet().getSpriteWidth(), anim.getSpritesheet().getSpriteHeight());
return new Animation(flippedSpritesheet, true, anim.getKeyFrameDurations());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public interface IAnimationController extends IUpdateable {
* The name of the {@code Animation} to be played.
*
* @see AnimationListener#played(Animation)
* @see #getCurrent()
*/
public void play(final String animationName);

Expand Down

0 comments on commit 649ceea

Please sign in to comment.