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
Modifier and TypeClassDescriptionstatic enum
All directions that the animations support. -
Field Summary
Modifier 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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.abstract com.badlogic.gdx.graphics.g2d.TextureRegion
getFrame
(float rotation, boolean isMoving, float frameTime, int holding) static WalkAnimator.Direction
rotationToDirection
(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.Direction
the 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
- TheTexture
containing all the frames of the animation.value
- Variant of the spritesheet (0 -> walk, 1 -> hold one item, 2 -> hold crate)
-