Package de.tum.cit.fop.maze.Drawing
Class Drawable
java.lang.Object
de.tum.cit.fop.maze.Drawing.Drawable
Handles drawing and animation management for game objects.
It maintains the state of the current animation and renders it to the batch.
-
Constructor Summary
ConstructorsConstructorDescriptionDrawable(AnimationType animationType) Creates a new Drawable instance with a specified initial animation. -
Method Summary
Modifier and TypeMethodDescriptionvoidanimate(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.voidchangeAnimation(AnimationType animationType) Changes the current animation to a new type.floatGets the current animation time.com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>Gets the current animation object.static voidInitializes the static texture map with animations from the game instance.voidsetAnimationTime(float animationTime) Sets the animation time manually.voidupdate(float delta) Updates the animation state.
-
Constructor Details
-
Drawable
Creates a new Drawable instance with a specified initial animation.- Parameters:
animationType- The initial animation type.
-
-
Method Details
-
initializeTextureMap
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
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.
-