Options
All
  • Public
  • Public/Protected
  • All
Menu

Utility class for maintaining reference to a collection of Textures on a single Spritesheet.

To access a sprite sheet from your code pass its JSON data file to Pixi's loader:

PIXI.Loader.shared.add("images/spritesheet.json").load(setup);

function setup() {
  let sheet = PIXI.Loader.shared.resources["images/spritesheet.json"].spritesheet;
  ...
}

With the sheet.textures you can create Sprite objects,sheet.animations can be used to create an AnimatedSprite.

Sprite sheets can be packed using tools like TexturePacker, Shoebox or Spritesheet.js. Default anchor points (see {@link PIXI.Texture#defaultAnchor}) and grouping of animation sprites are currently only supported by TexturePacker.

memberof

PIXI

Hierarchy

  • Spritesheet

Index

Constructors

constructor

Properties

Private _batchIndex

_batchIndex: any

Private _callback

_callback: any

Private _frameKeys

_frameKeys: any

Private _frames

_frames: any

Private _nextBatch

_nextBatch: any

Begin the next batch of textures.

Private _parseComplete

_parseComplete: any

The parse has completed.

Private _processAnimations

_processAnimations: any

Parse animations config

Private _processFrames

_processFrames: any

Process a batch of frames

param

The index of frame to start.

Private _texture

_texture: any

Private _updateResolution

_updateResolution: any

Generate the resolution from the filename or fallback to the meta.scale field of the JSON data.

param

The filename to use for resolving the default resolution.

returns

Resolution to use for spritesheet.

animations

animations: Dict<Texture<Resource>[]>

baseTexture

data

resolution

resolution: number

textures

textures: Dict<Texture<Resource>>

Static Readonly BATCH_SIZE

BATCH_SIZE: 1000 = 1000

The maximum number of Textures to build per process.

default

1000

Methods

destroy

  • destroy(destroyBase?: boolean): void
  • Destroy Spritesheet and don't use after this.

    Parameters

    • Optional destroyBase: boolean

    Returns void

parse

  • parse(callback: () => void): void
  • Parser spritesheet from loaded data. This is done asynchronously to prevent creating too many Texture within a single process.

    Parameters

    • callback: () => void

      Callback when complete returns a map of the Textures for this spritesheet.

        • (): void
        • Returns void

    Returns void

Generated using TypeDoc