API Docs for: v0.1.0
Show:

Tileset Class

Extends Texture

This object represents a tileset used by a Tilemap. There can be multiple Tilesets in a map

Constructor

Tileset

(
  • texture
  • settings
)

Parameters:

  • texture Texture

    The texture to use for the tileset

  • settings Object

    All the settings for the tileset

    • tilewidth Number

      The width of a single tile in the set

    • tileheight Number

      The height of a single tile in the set

    • [firstgid=1] Number optional

      The id of the first tile in the set, defaults to 1

    • [spacing=0] Number optional

      The spacing around tiles in the tileset (in pixels)

    • [margin=0] Number optional

      The margin around a tile in the tileset (in pixels)

    • [tileoffset] Object optional

      The offset to apply to a tile rendered from this tileset

      • [x=0] Number optional
        The X offset to apply to the tile
      • [y=0] Number optional
        The Y offset to apply to the tile
    • [properties] Object optional

      User-defined, custom properties that apply to the tileset

    • [tileproperties] Object optional

      User-defined, custom properties that apply to tiles in the tileset. The keys of this object should the tile id of the properties

    • [imagewidth] Number optional

      An override for the image width

    • [imageheight] Number optional

      An override for the image height

Methods

contains

(
  • tileId
)
Boolean

Returns whether or not this tileset contains the given tile guid

Parameters:

  • tileId Number

    The ID of the tile to check

Returns:

Boolean:

emit

(
  • type
  • data
)
Mixed chainable

Emits an event which will run all registered listeners for the event type

Parameters:

  • type String

    The event name to emit

  • data Mixed

    Any data you want passed along with the event

Returns:

Mixed:

Returns itself.

getTileProperties

(
  • tileId
)
Object

Gets the tile properties for a tile based on it's ID

Parameters:

  • tileId Number

    The id of the tile to get the properties for

Returns:

Object:

The properties of the tile

getTileTexture

(
  • tileId
)
Texture

Gets the tile texture for a tile based on it's ID

Parameters:

  • tileId Number

    The id of the tile to get the texture for

Returns:

Texture:

The texture for the tile

off

(
  • type
  • listener
)
Mixed chainable

Removes a listener function for an event type

Parameters:

  • type String

    The event name to emit

  • listener Function

    The function to remove

Returns:

Mixed:

Returns itself.

on

(
  • type
  • listener
)
Mixed chainable

Registers a listener function to be run on an event occurance

Parameters:

  • type String

    The event name to listen for

  • listener Function

    The function to execute when the event happens

Returns:

Mixed:

Returns itself.

once

(
  • type
  • listener
)
Mixed chainable

Registers a one-time callback for an event

Parameters:

  • type String

    The event name to listen for

  • listener Function

    the callback to call when the event occurs

Returns:

Mixed:

Returns itself.

Properties

firstgid

Number

The first tileId in the tileset

FLAGS

Unknown static

Tileset GID flags, these flags are set on a tile's ID to give it a special property

lastgid

Number

The last tileId in the tileset

margin

Number

The margin around a tile in the tileset

name

String

The name of the tileset

numTiles

Vector

The number of tiles calculated based on size, margin, and spacing

properties

Object

The properties of the tileset

size

Vector

The size of the tileset

spacing

Number

The spacing around a tile in the tileset

textures

Array

The texture instances for each tile in the set

tileoffset

Number

The offset of tile positions when rendered

tileproperties

Object

The properties of the tiles in the tileset (like collision stuff)

tileSize

Vector

The size of a tile in the tileset