q5play
    Preparing search index...

    Class Visual

    A Visual object stores an image or animation(s) which can be displayed with respect to the camera.

    Hierarchy (View Summary)

    Index
    vx vy x y
    vx: number

    Horizontal velocity of the visual.

    vy: number

    Vertical velocity of the visual.

    x: number

    Horizontal position of the visual.

    y: number

    Vertical position of the visual.

    • Adds an animation to the Sprite or Visual.

      Parameters

      • spriteSheetURL: string

        the URL of the sprite sheet image

      • frameCount: number

        the number of frames in the sprite sheet

      Returns Promise<void>

      A promise that fulfills when the animation is loaded

    • Adds an animation to the Sprite or Visual.

      Parameters

      • spriteSheetURL: string

        the URL of the sprite sheet image

      • frameCount: number

        the number of frames in the sprite sheet

      • frameSize: string

        the size of each frame in the sprite sheet in the format "WIDTHxHEIGHT" (example: "32x32")

      Returns Promise<void>

      A promise that fulfills when the animation is loaded

    • Adds an animation to the Sprite or Visual.

      Parameters

      • firstFrameURL: string

        the URL of the first animation frame

      • lastFrameIdx: string

        the index of the last animation frame, must be given as a string

      Returns Promise<void>

      A promise that fulfills when the animation is loaded

    • Add multiple animations to the Sprite or Visual.

      Parameters

      • atlases: {}

        an object with animation names as keys and an animation or animation atlas as values

      Returns Promise<void>

      A promise that fulfills when the animations are loaded

    • Add multiple animations to the Sprite or Visual.

      Parameters

      • spriteSheetURL: string

        the URL of the sprite sheet image

      • atlases: {}

        an object with animation names as keys and an animation or animation atlas as values

      Returns Promise<void>

      A promise that fulfills when the animations are loaded

    • Add multiple animations to the Sprite or Visual.

      Parameters

      • spriteSheetURL: string

        the URL of the sprite sheet image

      • frameSize: string

        the size of each frame in the sprite sheet in the format "WIDTHxHEIGHT" (example: "32x32")

      • atlases: {}

        an object with animation names as keys and an animation or animation atlas as values

      Returns Promise<void>

      A promise that fulfills when the animations are loaded

    • Changes the sprite's animation. Use addAni to define the animation(s) first.

      Parameters

      • name: string

        the name of the animation to switch to

      Returns void

    • Plays an animation.

      You can put special modifier characters before the name:

      • "!" plays it backwards
      • ">" or "<" horizontally flips it
      • "^" vertically flips it

      Parameters

      • name: string

        the name of the animation to play

      Returns Promise<void>

      A promise that fulfills when the animation completes

    • Plays a sequence of animations.

      You can put special modifier characters before each ani name:

      • "!" plays it backwards
      • ">" or "<" horizontally flips it
      • "^" vertically flips it

      You can put sequence modifiers at the end of the sequence:

      • "**" loops it indefinitely
      • ";;" stops it on the last ani's last frame

      Parameters

      • ...sequence: string[]

        the names of animations

      Returns Promise<void>

      A promise that fulfills when the sequence completes