Tileset Class
This object represents a tileset used by a Tilemap. There can be multiple Tilesets in a map
Constructor
Tileset
-
texture
-
settings
Parameters:
-
texture
TextureThe texture to use for the tileset
-
settings
ObjectAll the settings for the tileset
-
tilewidth
NumberThe width of a single tile in the set
-
tileheight
NumberThe height of a single tile in the set
-
[firstgid=1]
Number optionalThe id of the first tile in the set, defaults to 1
-
[spacing=0]
Number optionalThe spacing around tiles in the tileset (in pixels)
-
[margin=0]
Number optionalThe margin around a tile in the tileset (in pixels)
-
[tileoffset]
Object optionalThe offset to apply to a tile rendered from this tileset
-
[x=0]
Number optionalThe X offset to apply to the tile -
[y=0]
Number optionalThe Y offset to apply to the tile
-
-
[properties]
Object optionalUser-defined, custom properties that apply to the tileset
-
[tileproperties]
Object optionalUser-defined, custom properties that apply to tiles in the tileset. The keys of this object should the tile id of the properties
-
[imagewidth]
Number optionalAn override for the image width
-
[imageheight]
Number optionalAn override for the image height
-
Item Index
Methods
Properties
Methods
contains
-
tileId
Returns whether or not this tileset contains the given tile guid
Parameters:
-
tileId
NumberThe ID of the tile to check
Returns:
emit
-
type
-
data
Emits an event which will run all registered listeners for the event type
Parameters:
-
type
StringThe event name to emit
-
data
MixedAny data you want passed along with the event
Returns:
Returns itself.
getTileProperties
-
tileId
Gets the tile properties for a tile based on it's ID
Parameters:
-
tileId
NumberThe id of the tile to get the properties for
Returns:
The properties of the tile
getTileTexture
-
tileId
Gets the tile texture for a tile based on it's ID
Parameters:
-
tileId
NumberThe id of the tile to get the texture for
Returns:
The texture for the tile
off
-
type
-
listener
Removes a listener function for an event type
Parameters:
-
type
StringThe event name to emit
-
listener
FunctionThe function to remove
Returns:
Returns itself.
on
-
type
-
listener
Registers a listener function to be run on an event occurance
Parameters:
-
type
StringThe event name to listen for
-
listener
FunctionThe function to execute when the event happens
Returns:
Returns itself.
once
-
type
-
listener
Registers a one-time callback for an event
Parameters:
-
type
StringThe event name to listen for
-
listener
Functionthe callback to call when the event occurs
Returns:
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
properties
Object
The properties 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)