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

    Constructors

    Properties

    vx vy x y

    Accessors

    Methods

    Constructors

    Properties

    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.

    Accessors

    • get anis(): Anis

      Stores animations. Keys are the animation label, values are Ani objects

      Returns Anis

    Methods

    • 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

    • 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

    • Draws the visual on the canvas.

      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