FlixelAnimateRig
View sourceclass
org.flixelgdx.animation.FlixelAnimateRig
Immutable, pre-resolved multi-part rig for an Adobe Animate texture-atlas character. Built by FlixelAnimateRigLoader and consumed by FlixelAnimateSprite. The same rig structure represents both nested symbol timelines (Better Texture Atlas style) and flat document timelines that place ASI instances directly on the stage timeline.
Data shape
The rig is a dictionary of named clips (for example "Idle", "Left"). Each clip holds an array of keyframes, one per visible frame of the animation. Each keyframe holds an ordered array of parts, which are the individual bitmap slices that must be drawn in back-to-front order to produce the final composited image for that moment in time.
Each Part stores:
- An integer index into FlixelAnimateRig.atlas selecting which bitmap slice to draw.
- A fully baked
Affine2that already contains (a) the FlashMXorM3Dmatrix chain from the root symbol or stage down to the leaf bitmap, (b) a Y-axis flip that converts Adobe Animate's Y-down bitmap space into libGDX's Y-up texture-region space, and (c) an anchor translation that shifts the whole rig so the anchor-clip bounding box starts at(0, 0).
Because every matrix is baked at load time, the per-frame draw path is reduced to one translate, one scale, and one affine concatenation per visible bitmap.
Anchor space
The anchor clip defines the bounding box used to size the sprite's hitbox: parts are pre-shifted so the union of their rectangles on anchor-clip frame 0 fits exactly inside (0, 0) to (anchorWidth, anchorHeight). All other clips are baked in the same coordinate space, so switching clips does not move the rig relative to the sprite's hitbox.
Merging multiple atlases
A rig can grow at runtime by merging additional Adobe Animate exports through FlixelAnimateRigLoader.append(...). Appended atlases share the original rig's anchor space (preserved on the rig as FlixelAnimateRig.anchorMinX / FlixelAnimateRig.anchorMinY / FlixelAnimateRig.anchorHeight), so a character's body stays visually pinned to the same world position when game code switches between, say, an "idle" atlas and a separate "miss" atlas. Frames from the appended atlas are appended to FlixelAnimateRig.atlas and the appended clip names are added to FlixelAnimateRig.clips, with later entries overwriting earlier ones on name collisions.
Fields
atlas
The shared atlas regions indexed by Part.atlasIndex. This is the same list installed on the owning FlixelSprite through FlixelSprite.applySparrowAtlas, so callers may look up a region either way.
clips
Map of clip name (for example "Idle") to its baked Clip.
anchorClipName
Name of the clip whose frame-zero bounding box defines the rig's anchor-space rectangle. Usually the string "Idle" if present, otherwise the first clip from the loaded data (for example the default clip synthesized when an export has no label layer).
anchorWidth
Width in pixels of the anchor-clip bounding box. Used to size the owning sprite's hitbox.
anchorHeight
Height in pixels of the anchor-clip bounding box. Used to size the owning sprite's hitbox.
Methods
getClip(String)
Looks up a clip by its label-layer name (for example "Idle", "Left Miss").
Parameters:
| Name | Description |
|---|---|
name | The clip name, matching the "N" field on the label layer of Animation.json. Must not be null. |
Returns: The Clip, or null if no clip with that name exists in this rig.
getClips()
Returns the live map of clip name to Clip. Callers must treat the returned map as read-only; mutating it invalidates the rig.
Returns: The internal clip map. Never null.
Part
class
org.flixelgdx.animation.FlixelAnimateRig.Part
A single bitmap draw call inside a Keyframe. Immutable at runtime: the affine is filled once by the loader and only read afterwards, so instances are safe to share.
Fields
atlasIndex
Index into FlixelAnimateRig.atlas. Always in range when the rig was built successfully.
local
The composed affine to pass to SpriteBatch.draw(...) (after the sprite's world translate and scale are applied on top).
Mathematically this is anchorShift * flipRig * P_flash * flipBitmap, where P_flash is the product of MX matrices walked from the root symbol down to the leaf bitmap.
Keyframe
class
org.flixelgdx.animation.FlixelAnimateRig.Keyframe
A single visible frame of a clip. Parts are stored in back-to-front draw order: the first element is drawn first (appears behind), the last element is drawn last (appears on top). The loader has already applied Flash's "first layer in the list is on top" z-order convention by iterating layers in reverse before filling this array.
Fields
parts
Per-bitmap draw list, in back-to-front order. Never contains null.
Clip
class
org.flixelgdx.animation.FlixelAnimateRig.Clip
A named animation clip, for example "Idle" or "Left Miss". Each index into FlixelAnimateRig.keyframes corresponds to one tick of the main timeline at the authoring frame rate stored on the parent FlixelAnimateRig's owner.
Fields
name
The clip's label-layer name. Matches the key used in FlixelAnimateRig.getClip(String).
keyframes
Per-tick keyframes. Length equals the label-layer DU (duration) for this clip.