API

Class SpriteManager

Class used to manage multiple sprites on the same spritesheet

Hierarchy (View Summary)

Implements

Index
  • Creates a new sprite manager

    Parameters

    • name: string

      defines the manager's name

    • imgUrl: string

      defines the sprite sheet url

    • capacity: number

      defines the maximum allowed number of sprites

    • cellSize: any

      defines the size of a sprite cell

    • scene: Scene

      defines the hosting scene

    • epsilon: number = 0.01

      defines the epsilon value to align texture (0.01 by default)

    • samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE

      defines the sampling mode to use with spritesheet

    • fromPacked: boolean = false

      set to false; do not alter

    • spriteJSON: string | null = null

      null otherwise a JSON object defining sprite sheet data; do not alter

    • Optionaloptions: SpriteManagerOptions

      options used to create the SpriteManager instance

    Returns SpriteManager

doNotSerialize: boolean = false

Specifies if the sprite manager should be serialized

isPickable: boolean = false

Gets or sets a boolean indicating if the sprites are pickable

layerMask: number = 0x0fffffff

Gets or sets camera layer mask

metadata: any = null

Gets or sets an object used to store user defined information for the sprite manager

name: string

defines the manager's name

onDisposeObservable: Observable<SpriteManager> = ...

An event triggered when the manager is disposed.

renderingGroupId: number = 0

Gets or sets the rendering group id (0 by default)

snippetId: string

Snippet ID if the manager was created from the snippet server

sprites: Sprite[] = []

Gets the list of sprites

uniqueId: number

Gets or sets the unique id of the sprite

CreateFromSnippetAsync: (
    snippetId: string,
    scene: Scene,
    rootUrl?: string,
) => Promise<SpriteManager> = SpriteManager.ParseFromSnippetAsync

Creates a sprite manager from a snippet saved by the sprite editor

Type Declaration

    • (snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>
    • Creates a sprite manager from a snippet saved by the sprite editor

      Parameters

      • snippetId: string

        defines the snippet to load (can be set to _BLANK to create a default one)

      • scene: Scene

        defines the hosting scene

      • rootUrl: string = ""

        defines the root URL to use to load textures and relative dependencies

      Returns Promise<SpriteManager>

      a promise that will resolve to the new sprite manager

Please use ParseFromSnippetAsync instead

defines the snippet to load (can be set to _BLANK to create a default one)

defines the hosting scene

defines the root URL to use to load textures and relative dependencies

a promise that will resolve to the new sprite manager

SnippetUrl: string = Constants.SnippetUrl

Define the Url to load snippets

  • get pixelPerfect(): boolean

    Gets or sets a boolean indicating if the renderer must render sprites with pixel perfect rendering In this mode, sprites are rendered as "pixel art", which means that they appear as pixelated but remain stable when moving or when rotated or scaled. Note that for this mode to work as expected, the sprite texture must use the BILINEAR sampling mode, not NEAREST!

    Returns boolean

  • set pixelPerfect(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • Creates a sprite manager from a snippet saved in a remote file

    Parameters

    • name: Nullable<string>

      defines the name of the sprite manager to create (can be null or empty to use the one from the json data)

    • url: string

      defines the url to load from

    • scene: Scene

      defines the hosting scene

    • rootUrl: string = ""

      defines the root URL to use to load textures and relative dependencies

    Returns Promise<SpriteManager>

    a promise that will resolve to the new sprite manager

  • Creates a sprite manager from a snippet saved by the sprite editor

    Parameters

    • snippetId: string

      defines the snippet to load (can be set to _BLANK to create a default one)

    • scene: Scene

      defines the hosting scene

    • rootUrl: string = ""

      defines the root URL to use to load textures and relative dependencies

    Returns Promise<SpriteManager>

    a promise that will resolve to the new sprite manager