Class Drawable

java.lang.Object
de.tum.cit.fop.maze.Drawing.Drawable

public class Drawable extends Object
Handles drawing and animation management for game objects. It maintains the state of the current animation and renders it to the batch.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Drawable(AnimationType animationType)
    Creates a new Drawable instance with a specified initial animation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    animate(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.math.Vector2 spriteSizes)
    Draws the current animation frame to the batch.
    void
    Changes the current animation to a new type.
    float
    Gets the current animation time.
    com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>
    Gets the current animation object.
    static void
    Initializes the static texture map with animations from the game instance.
    void
    setAnimationTime(float animationTime)
    Sets the animation time manually.
    void
    update(float delta)
    Updates the animation state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Drawable

      public Drawable(AnimationType animationType)
      Creates a new Drawable instance with a specified initial animation.
      Parameters:
      animationType - The initial animation type.
  • Method Details

    • initializeTextureMap

      public static void initializeTextureMap(MazeRunnerGame game)
      Initializes the static texture map with animations from the game instance.
      Parameters:
      game - The MazeRunnerGame instance containing loaded assets.
    • getAnimationTime

      public float getAnimationTime()
      Gets the current animation time.
      Returns:
      The state time of the animation.
    • setAnimationTime

      public void setAnimationTime(float animationTime)
      Sets the animation time manually.
      Parameters:
      animationTime - The new state time.
    • update

      public void update(float delta)
      Updates the animation state.
      Parameters:
      delta - The time elapsed since the last frame.
    • changeAnimation

      public void changeAnimation(AnimationType animationType)
      Changes the current animation to a new type. Resets animation time if the type is different.
      Parameters:
      animationType - The new animation type to switch to.
    • animate

      public void animate(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.math.Vector2 spriteSizes)
      Draws the current animation frame to the batch.
      Parameters:
      batch - The SpriteBatch to draw to.
      position - The position to draw at.
      spriteSizes - The size of the drawn sprite.
    • getCurrentAnimation

      public com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion> getCurrentAnimation()
      Gets the current animation object.
      Returns:
      The current animation.