SpriteSheetTexture Class

Extends Texture
Module: Textures

SpriteSheet texture, can be used load spritesheet animations as textures.

The images have to be aligned in a grid without overlapping if the spritesheet is not full the last rows or blocks should be empty.

Images are played row by row, changing every animationSpeed seconds.

Methods

dispose

()

Dispose spritesheet texture.

setAnimationFrames

(
  • beginFrame
  • endFrame
)

Set frames to be used for this animation.

Frame starts counting from 0.

Parameters:

  • beginFrame Number
  • endFrame Number

setAnimationSpeed

(
  • animationSpeed
)

Set animation playback speed.

Parameters:

  • animationSpeed Number

setFrameGrid

(
  • framesHorizontal
  • framesVertical
)

Set the sprite sheet grid dimension.

Automatically sets the totalFrame value to framesHorizontal * framesVertical.

Parameters:

  • framesHorizontal Number
  • framesVertical Number

step

()

Step the sprite sheet animation, move to next frame and recalculate the texture offset.

toJSON

(
  • meta
)
Object

Create texture json description.

Parameters:

  • meta Object

Returns:

Object:

json

Properties

animationSpeed

Number

Animation speed in seconds.

Default: 0.1

beginFrame

Number

The offset frame can be ajusted to control in which frame the animation starts.

Default: 0

currentFrame

Number

Indicates the current frame of the animation.

endFrame

Number

The offset frame can be ajusted to control in which frame the animation ends.

framesHorizontal

Number

Spritesheet number of frames horizontally.

When this values is changed the totalFrames value is automatically updated to framesHorizontal * framesVertical.

Default: 1.0

framesVertical

Number

Spritesheet number of frames vertically.

When this values is changed the totalFrames value is automatically updated to framesHorizontal * framesVertical.

Default: 1.0

loop

Boolean

If true the animation plays in loop.

Default: true

totalFrames

Number

Total number of frames present in the texture.

Sometimes a NxM spritesheet does not have all spaces filled, this parameter is used to take care of those cases.

Default: 1