Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: AnimationChannel

[24:7] extends: FxObj

Wraps FXGL's AnimationChannel (com.almasb.fxgl.texture.AnimationChannel), the configuration object that describes one cycle of a sprite-sheet animation (e.g. WALK_LEFT 4 frames at 0.5s total). Used together with AnimatedTexture to drive sprite animations. Three constructor forms cover the common cases:

  1. (Image, durationSeconds, numFrames) - single-row sheet split horizontally into numFrames equal cells.
  2. (Image, framesPerRow, frameW, frameH, durationSeconds, startFrame, endFrame) - explicit grid spec for multi-row sheets.
  3. (Image, durationSeconds, framesPerRow, animChannelDataList)
  • multiple sub-cycles (e.g. WALK_LEFT + WALK_RIGHT) inside the same sheet.

Methods

  • AnimationChannel ()

    Empty default constructor; populated by adopt or one of the factory helpers.

  • adopt (object Ajo)

    Wraps an existing AnimationChannel AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an AnimationChannel.
    • @r A new wrapper.
  • fromSingleRow (object ImageObj, double DurationSeconds, int NumFrames)

    Builds an AnimationChannel for a single-row sprite sheet split horizontally into NumFrames equal cells.

    • @p ImageObj is a fx.Image wrapper.
    • @p DurationSeconds is the total cycle time in seconds.
    • @p NumFrames is the number of horizontal cells.
    • @r A new AnimationChannel wrapper.
  • fromGrid (object ImageObj, int FramesPerRow, int FrameWidth, int FrameHeight, double DurationSeconds, int StartFrame, int EndFrame)

    Builds an AnimationChannel from a multi-row sprite sheet with the supplied grid spec and frame range.

    • @p ImageObj is a fx.Image wrapper.
    • @p FramesPerRow is the cells per row in the sheet.
    • @p FrameWidth is the cell width in pixels.
    • @p FrameHeight is the cell height in pixels.
    • @p DurationSeconds is the total cycle time in seconds.
    • @p StartFrame is the inclusive first cell index.
    • @p EndFrame is the inclusive last cell index.
    • @r A new AnimationChannel wrapper.
  • isLastFrame (int Frame)

    Returns whether the given frame index is the last in the cycle.

  • getFrameData (int Frame)

    Returns the FrameData AJO for the given frame index.

  • getFrameWidth (int Frame)

    Returns the frame width in pixels for the given frame.

  • getFrameHeight (int Frame)

    Returns the frame height in pixels for the given frame.

  • frameAfter (int Frame)

    Returns the next-frame index, wrapping to 0 after the last.

  • getImage ()

    Returns the source Image as an AJO.

  • getFrameImage (int FrameIndex)

    Returns the cropped Image for the given frame index. Useful for previewing individual frames in UI.