API Docs for: 1.4.0
Show:

Kiwi.Textures.SpriteSheet Class

Extends TextureAtlas
Module: Textures
Parent Module: Kiwi

A special type of TextureAtlas that is created when loading in images that are design to be SpriteSheets. A SpriteSheet will generally contain multiple cells and can also contain sequences which are then automatically added as Animations when this texture is used on a Sprite.

Constructor

Kiwi.Textures.SpriteSheet

(
  • name
  • texture
  • cellWidth
  • cellHeight
  • [numCells]
  • [rows]
  • [cols]
  • [sheetOffsetX]
  • [sheetOffsetY]
  • [cellOffsetX]
  • [cellOffsetY]
)
SpriteSheet

Parameters:

  • name String

    The name of the spritesheet.

  • texture HTMLImageElement/HTMLCanvasElement

    The image that is being used for the spritesheet.

  • cellWidth Number

    The width of a single cell.

  • cellHeight Number

    The height of a single cell.

  • [numCells] Number optional

    The number of cells in total.

  • [rows] Number optional

    The number of cells that make up a row.

  • [cols] Number optional

    The number of cells that make up a column.

  • [sheetOffsetX] Number optional

    The offset of the whole sheet on the x axis. Useful if the image has a border you don't want to show.

  • [sheetOffsetY] Number optional

    The offset of the whole sheet on the y axis. Useful if the image has a border you don't want to show.

  • [cellOffsetX] Number optional

    An offset between cells on the x axis. Useful if there is a border between cells which is not to be shown.

  • [cellOffsetY] Number optional

    An offset between cells on the y axis. Useful if there is a border between cells which is not to be shown.

Returns:

SpriteSheet:

Methods

generateAtlasCells

() Array public

Generates the atlas cells based on the information that was provided.

Returns:

Array:

objType

() String public

The type of object that this is.

Returns:

String:

"SpriteSheet"

Properties

cellHeight

Number private

The height of a single cell.

cellOffsetX

Number private

How much each cell should be offset by on the X axis.

cellOffsetY

Number private

How much each cell should be offset by on the Y axis.

cellWidth

Number private

The width of a single cell.

cols

Number private

The number of columns that are on this spritesheet

numCells

Number private

The number of cells that are on this spritesheet

rows

Number private

The number of rows for the spritesheet

sheetOffsetX

Number private

How much the whole spritesheet should be offset by on the X axis.

sheetOffsetY

Number private

How much the whole spritesheet should be offset by on the Y axis.