Class: TextureManager

hcje/sprites.TextureManager(data, texture)

Class to handle the management of textures.

Constructor

new TextureManager(data, texture)

Construct the texture manager.

Parameters:
Name Type Description
data module:hcje/sprites~PackedSpritesTextureData

Texture data from the JSON file typically created from the file exported by TexturePacker in JSON (Hash) format. export. Rotation and trimming of sprites in the texture is not permitted.

texture HTMLImageElement

The sprite sheet texture.

Source:

Members

spriteFactory :module:hcje/sprites~ImageSpriteFactory

Type:
Source:

Methods

createFrameName()

Default frame name generator. This simply adds the state and index, unpadded, at the end of the name but in front of any extension. The state is prefixed with an underscore, so for a base name of "spaceman.png", state of "idle" and index of 5, the result would be "spaceman_idle5.png".

Source:

createSprite(baseName, stateConfigs, nameGenopt) → {module:hcje/sprites.Sprite}

Create a sprite.

Parameters:
Name Type Attributes Default Description
baseName string

The base name for the sprite.

stateConfigs Array.<Object>

States that the sprite can be in. If stateConfigs is empty, then a single frame is returned using the baseName. Its state name is set to 'anon'.

Properties
Name Type Description
name string

Name of the state.

interval number

Update interval in ms.

cycleType module:hcje/sprites~CycleTypeEnumValue

Type of animation cycle

nameGen module:hcje/sprites~frameNameGenerator <optional>
module:hcje/sprites.TextureManager#createFrameName

The frame name generator. If not provided, the default frame name generator is used. index is simply appended to the base name in front of the extension.

Source:
Throws:

Error thrown if spriteFactory property not set.

Type
Error
Returns:
Type
module:hcje/sprites.Sprite