Class AnimatedClipImage

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.Image
com.csse3200.game.ui.AnimatedClipImage
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout

public class AnimatedClipImage extends com.badlogic.gdx.scenes.scene2d.ui.Image
An Image that plays a frame-by-frame animation built from a sequence of textures stored under the game assets folder.

Frames are loaded via Gdx.files.internal(...) using a folder + pattern scheme provided by TutorialClip, then managed by ResourceService. The actor advances the animation on each act(float) call and updates its drawable accordingly.

Usage


 TutorialClip clip = new TutorialClip();
 clip.folder = "tutorial/intro";
 clip.pattern = "frame_%03d.png"; // frame_001.png, frame_002.png, ...
 clip.frameCount = 60;
 clip.fps = 24f;
 clip.loop = true;

 AnimatedClipImage img = new AnimatedClipImage(clip);
 stage.addActor(img);
 

Lifecycle: Call disposeAssets() or rely on remove() to free textures when the actor is no longer needed.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an animated image from the frames described by the given TutorialClip.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    act(float delta)
    Advances the animation time and updates the displayed frame.
    void
    Unloads any textures loaded for this image from the ResourceService.
    boolean
    Removes this actor from its parent and frees associated textures.

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Image

    draw, getAlign, getDrawable, getImageHeight, getImageWidth, getImageX, getImageY, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, layout, setAlign, setDrawable, setDrawable, setScaling, toString

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget

    getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront

    Methods inherited from class java.lang.Object

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

    • AnimatedClipImage

      public AnimatedClipImage(TutorialClip clip)
      Creates an animated image from the frames described by the given TutorialClip.

      This constructor validates that all frame files exist under the internal assets folder. It loads textures through ResourceService, sets linear filtering, constructs the Animation, and initialises the drawable to the first frame.

      Parameters:
      clip - clip metadata including folder, filename pattern, frame count, fps and loop flag
      Throws:
      com.badlogic.gdx.utils.GdxRuntimeException - if any frame is missing or any texture fails to load
  • Method Details

    • act

      public void act(float delta)
      Advances the animation time and updates the displayed frame.
      Overrides:
      act in class com.badlogic.gdx.scenes.scene2d.Actor
      Parameters:
      delta - time elapsed since the last frame in seconds
    • disposeAssets

      public void disposeAssets()
      Unloads any textures loaded for this image from the ResourceService.

      After disposal, this instance should not be used unless the assets are reloaded.

    • remove

      public boolean remove()
      Removes this actor from its parent and frees associated textures.
      Overrides:
      remove in class com.badlogic.gdx.scenes.scene2d.Actor
      Returns:
      true if the actor was removed
      See Also: