PokéRogue
    Preparing search index...

    A Frame based Animation.

    Animations in Phaser consist of a sequence of AnimationFrame objects, which are managed by this class, along with properties that impact playback, such as the animation's frame rate or delay.

    This class contains all of the properties and methods needed to handle playback of the animation directly to an AnimationState instance, which is owned by a Sprite, or similar Game Object.

    You don't typically create an instance of this class directly, but instead go via either the AnimationManager or the AnimationState and use their create methods, depending on if you need a global animation, or local to a specific Sprite.

    Index
    • Parameters

      • manager: AnimationManager

        A reference to the global Animation Manager

      • key: string

        The unique identifying string for this animation.

      • config: Animation

        The Animation configuration.

      Returns Animation

    delay: number

    The delay in ms before the playback will begin.

    duration: number

    How long the animation should play for, in milliseconds. If the frameRate property has been set then it overrides this value, otherwise the frameRate is derived from duration.

    frameRate: number

    The frame rate of playback in frames per second (default 24 if duration is null)

    frames: AnimationFrame[]

    An array of AnimationFrame objects that make up this animation.

    hideOnComplete: boolean

    Should the GameObject's visible property be set to false when the animation finishes?

    key: string

    The unique identifying string for this animation.

    A reference to the global Animation Manager.

    msPerFrame: number

    How many ms per frame, not including frame-specific modifiers.

    paused: boolean

    Global pause. All Game Objects using this Animation instance are impacted by this property.

    randomFrame: boolean

    Start playback of this animation from a random frame?

    repeat: number

    Number of times to repeat the animation. Set to -1 to repeat forever.

    repeatDelay: number

    The delay in ms before a repeat play starts.

    showBeforeDelay: boolean

    If the animation has a delay set, before playback will begin, this controls when the first frame is set on the Sprite. If this property is 'false' then the frame is set only after the delay has expired. This is the default behavior.

    showOnStart: boolean

    Should the GameObject's visible property be set to true when the animation starts to play?

    skipMissedFrames: boolean

    Skip frames if the time lags, or always advance anyway?

    type: string

    A frame-based animation (as opposed to a bone-based animation).

    yoyo: boolean

    Should the animation yoyo (reverse back down to the start) before repeating?

    • Add frames to the end of the animation.

      Parameters

      • config: string | AnimationFrame[]

        Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.

      Returns this

      This Animation object.

    • Inserts one or more frames into the animation at the specified index.

      Parameters

      • index: number

        The index to insert the frame at within the animation.

      • config: string | AnimationFrame[]

        Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.

      Returns this

      This Animation object.

    • Calculates the duration, frame rate and msPerFrame values.

      Parameters

      • target: Animation

        The target to set the values on.

      • totalFrames: number

        The total number of frames in the animation.

      • Optionalduration: number

        The duration to calculate the frame rate from. Pass null if you wish to set the frameRate instead.

      • OptionalframeRate: number

        The frame rate to calculate the duration from.

      Returns void

    • Check if the given frame index is valid.

      Parameters

      • index: number

        The index to be checked.

      Returns boolean

      true if the index is valid, otherwise false.

    • Destroys this Animation instance. It will remove all event listeners, remove this animation and its key from the global Animation Manager, and then destroy all Animation Frames in turn.

      Returns void

    • Called internally when this Animation first starts to play. Sets the accumulator and nextTick properties.

      Parameters

      • state: AnimationState

        The Animation State belonging to the Game Object invoking this call.

      Returns void

    • Returns the AnimationFrame at the provided index

      Parameters

      • index: number

        The index in the AnimationFrame array

      Returns AnimationFrame

      The frame at the index provided from the animation sequence

    • Returns the frame closest to the given progress value between 0 and 1.

      Parameters

      • value: number

        A value between 0 and 1.

      Returns AnimationFrame

      The frame closest to the given progress value.

    • Creates AnimationFrame instances based on the given frame data.

      Parameters

      • textureManager: TextureManager

        A reference to the global Texture Manager.

      • frames: string | AnimationFrame[]

        Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.

      • OptionaldefaultTextureKey: string

        The key to use if no key is set in the frame configuration object.

      Returns AnimationFrame[]

      An array of newly created AnimationFrame instances.

    • Returns the last frame in this animation.undefined

      Returns AnimationFrame

      The last Animation Frame.

    • Called internally. Sets the accumulator and nextTick values of the current Animation.

      Parameters

      • state: AnimationState

        The Animation State belonging to the Game Object invoking this call.

      Returns void

    • Gets the total number of frames in this animation.undefined

      Returns number

      The total number of frames in this animation.

    • Advance the animation frame.

      Parameters

      Returns void

    • Pauses playback of this Animation. The paused state is set immediately.undefined

      Returns this

      This Animation object.

    • Called internally when the Animation is playing backwards. Sets the previous frame, causing a yoyo, repeat, complete or update, accordingly.

      Parameters

      • state: AnimationState

        The Animation State belonging to the Game Object invoking this call.

      Returns void

    • Removes the given AnimationFrame from this Animation instance. This is a global action. Any Game Object using this Animation will be impacted by this change.

      Parameters

      Returns this

      This Animation object.

    • Removes a frame from the AnimationFrame array at the provided index and updates the animation accordingly.

      Parameters

      • index: number

        The index in the AnimationFrame array

      Returns this

      This Animation object.

    • Called internally during playback. Forces the animation to repeat, provided there are enough counts left in the repeat counter.

      Parameters

      • state: AnimationState

        The Animation State belonging to the Game Object invoking this call.

      Returns void

    • Resumes playback of this Animation. The paused state is reset immediately.undefined

      Returns this

      This Animation object.

    • Converts the animation data to JSON.undefined

      Returns JSONAnimation

      The resulting JSONAnimation formatted object.

    • Called internally whenever frames are added to, or removed from, this Animation.undefined

      Returns this

      This Animation object.