Class WalkAnimator
java.lang.Object
com.devcharles.piazzapanic.utility.WalkAnimator
- Direct Known Subclasses:
CookAnimator,CustomerAnimator
Abstract class that helps with setting up animations for characters in the
game.
To use, initialise each directional animation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAll directions that the animations support. -
Field Summary
FieldsModifier and TypeFieldDescriptionTuple Representing the dimensions of the spritesheet to be used.private static HashMap<Integer,WalkAnimator.Direction> private static int[]protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>>protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>>protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>>protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddTextures(com.badlogic.gdx.graphics.Texture currentSheet, int value) Generate Animations from aTexture, override this if you want to parse the texture spritesheet differently.abstract com.badlogic.gdx.graphics.g2d.TextureRegiongetFrame(float rotation, boolean isMoving, float frameTime, int holding) static WalkAnimator.DirectionrotationToDirection(float rotation) Approximate the Box2D rotation to the nearest mapped value.
-
Field Details
-
walkRight
protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> walkRight -
walkLeft
protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> walkLeft -
walkUp
protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> walkUp -
walkDown
protected ArrayList<com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> walkDown -
dimensions
Tuple Representing the dimensions of the spritesheet to be used. The values represent columns and rows, respectively. -
directionMap
-
directions
private static int[] directions
-
-
Constructor Details
-
WalkAnimator
public WalkAnimator()
-
-
Method Details
-
getFrame
public abstract com.badlogic.gdx.graphics.g2d.TextureRegion getFrame(float rotation, boolean isMoving, float frameTime, int holding) - Parameters:
rotation- box2d body rotationisMoving- whether the entity is moving or notframeTime- elapsed time for the animationholding- how many items the character is holding- Returns:
- A texture region to draw, and a rotation used for rendering the region.
-
rotationToDirection
Approximate the Box2D rotation to the nearest mapped value.- Parameters:
rotation- body rotation in degrees.- Returns:
WalkAnimator.Directionthe character should be facing in.
-
addTextures
protected void addTextures(com.badlogic.gdx.graphics.Texture currentSheet, int value) Generate Animations from aTexture, override this if you want to parse the texture spritesheet differently.- Parameters:
currentSheet- TheTexturecontaining all the frames of the animation.value- Variant of the spritesheet (0 -> walk, 1 -> hold one item, 2 -> hold crate)
-