Class WalkAnimator

java.lang.Object
com.devcharles.piazzapanic.utility.WalkAnimator
Direct Known Subclasses:
CookAnimator, CustomerAnimator

public abstract class WalkAnimator extends Object
Abstract class that helps with setting up animations for characters in the game. To use, initialise each directional animation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    All directions that the animations support.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Pair<Integer,Integer>
    Tuple Representing the dimensions of the spritesheet to be used.
     
    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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addTextures(com.badlogic.gdx.graphics.Texture currentSheet, int value)
    Generate Animations from a Texture, 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)
     
    rotationToDirection(float rotation)
    Approximate the Box2D rotation to the nearest mapped value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      private static final Pair<Integer,Integer> dimensions
      Tuple Representing the dimensions of the spritesheet to be used. The values represent columns and rows, respectively.
    • directionMap

      private static HashMap<Integer,WalkAnimator.Direction> 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 rotation
      isMoving - whether the entity is moving or not
      frameTime - elapsed time for the animation
      holding - how many items the character is holding
      Returns:
      A texture region to draw, and a rotation used for rendering the region.
    • rotationToDirection

      public static WalkAnimator.Direction rotationToDirection(float rotation)
      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 a Texture, override this if you want to parse the texture spritesheet differently.
      Parameters:
      currentSheet - The Texture containing all the frames of the animation.
      value - Variant of the spritesheet (0 -> walk, 1 -> hold one item, 2 -> hold crate)