Tileset

Entitytracker.Modelceramic.Tileset (Class)

Represents a collection of tiles used by a tilemap.

A tileset contains the image data and metadata for tiles that can be placed in a tilemap. Each tile is identified by a global ID (GID) that's unique across all tilesets in a tilemap. Tilesets support various features including tile spacing, margins, and slope definitions for physics interactions.

Features

  • Tile Organization: Tiles arranged in a grid with configurable spacing and margins
  • Global IDs: Each tile has a unique GID for referencing across layers
  • Slope Support: Define collision slopes for individual tiles
  • Grid Orientation: Support for orthogonal and isometric tile arrangements
  • Reactive Properties: Extends Model for automatic change notifications

Usage Example

var tileset = new Tileset();
tileset.name = "terrain";
tileset.firstGid = 1;
tileset.tileSize(32, 32);
tileset.image = tilesetImage;

// Add a slope for tile index 5
tileset.slope(5, {
    index: 5,
    y0: 0.0,    // Left edge height (0 = bottom, 1 = top)
    y1: 0.5,    // Right edge height
    rotation: 0 // Optional rotation
});

Instance Members

ldtk
ldtkTileset: LdtkTilesetDefinition

Reference to the source LDtk tileset definition when this tileset was imported from LDtk. Provides access to additional LDtk-specific metadata.


tilemap
firstGid: Int

First global id. Maps to the first tile in this tileset.


tilemap
name: String

The name of this tileset


tilemap
tileWidth: Int

The (maximum) width of tiles in this tileset


tilemap
tileHeight: Int

The (maximum) height of tiles in this tileset


tilemap
spacing: Int

The spacing between tiles in this tileset


tilemap
margin: Int

The margin around the tiles in this tileset


tilemap
tileCount: Int

The number of tiles in this tileset


tilemap
columns: Int

The number of tile columns in this tileset


tilemap
rows: Int

The number of tile rows in this tileset


tilemap
image: TilesetImage

The image used to display tiles in this tileset


tilemap
gridOrientation: Anonymous

Orientation of the grid for the tiles in this tileset. Only used in case of isometric orientation, to determine how tile overlays for terrain an collision information are rendered.


tilemap
gridCellWidth: Int

Width of a grid cell. Only used in case of isometric orientation, to determine how tile overlays for terrain an collision information are rendered.


tilemap
gridCellHeight: Int

Height of a grid cell. Only used in case of isometric orientation, to determine how tile overlays for terrain an collision information are rendered.


tilemap
texture: Texture

The texture used to display tiles in this tileset. This is a shorthand of image.texture


tilemap
slopes: ReadOnlyArray<TileSlope>

Slopes in this tileset or null if there is no slope.


tilemap
invalidateLdtkTileset(): Void

tilemap
invalidateFirstGid(): Void

tilemap
invalidateName(): Void

tilemap
invalidateTileWidth(): Void

tilemap
invalidateTileHeight(): Void

tilemap
invalidateSpacing(): Void

tilemap
invalidateMargin(): Void

tilemap
invalidateTileCount(): Void

tilemap
invalidateColumns(): Void

tilemap
invalidateRows(): Void

tilemap
invalidateImage(): Void

tilemap
invalidateGridOrientation(): Void

tilemap
invalidateGridCellWidth(): Void

tilemap
invalidateGridCellHeight(): Void

tilemap
tileSize(tileWidth: Int, tileHeight: Int): Void

A shorthand to set tileWidth and tileHeight

Name Type Description
tileWidth Int *
tileHeight Int

tilemap
gidAtPosition(column: Float, row: Float): Int

Get the global id from the given column and row coordinates in the tileset.

Name Type Description
column Float The column position in the tileset (0-based)
row Float The row position in the tileset (0-based)
Returns Description
Int The global tile ID at the specified position

tilemap
columnForGid(gid: Int): Int

Gets the column position of a tile within this tileset from its global ID.

Name Type Description
gid Int The global tile ID
Returns Description
Int The column position (0-based) within the tileset

tilemap
rowForGid(gid: Int): Int

Gets the row position of a tile within this tileset from its global ID.

Name Type Description
gid Int The global tile ID
Returns Description
Int The row position (0-based) within the tileset

tilemap
invalidateSlopes(): Void

tilemap
slope(slope: TileSlope): Void

Add a slope to this tileset.

Name Type
slope TileSlope

tilemap
destroy(): Void

tilemap
new(): Void

Private Members

tilemap
unobservedLdtkTileset: LdtkTilesetDefinition

tilemap
unobservedFirstGid: Int

tilemap
unobservedName: String

tilemap
unobservedTileWidth: Int

tilemap
unobservedTileHeight: Int

tilemap
unobservedSpacing: Int

tilemap
unobservedMargin: Int

tilemap
unobservedTileCount: Int

tilemap
unobservedColumns: Int

tilemap
unobservedRows: Int

tilemap
unobservedImage: TilesetImage

tilemap
unobservedGridOrientation: Anonymous

tilemap
unobservedGridCellWidth: Int

tilemap
unobservedGridCellHeight: Int

tilemap
slopesMapping: IntIntMap

A mapping to access a given slope by it's tile index without having to walk through the whole slope array


tilemap
implicitImage: Bool

Internal: true if TilesetImage instance was created implicitly from assigning a texture object.


tilemap
unobservedSlopes: ReadOnlyArray<TileSlope>

tilemap
emitLdtkTilesetChange(current: LdtkTilesetDefinition, previous: LdtkTilesetDefinition): Void

Event when ldtkTileset field changes.

Name Type
current LdtkTilesetDefinition
previous LdtkTilesetDefinition

tilemap
emitFirstGidChange(current: Int, previous: Int): Void

Event when firstGid field changes.

Name Type
current Int
previous Int

tilemap
emitNameChange(current: String, previous: String): Void

Event when name field changes.

Name Type
current String
previous String

tilemap
emitTileWidthChange(current: Int, previous: Int): Void

Event when tileWidth field changes.

Name Type
current Int
previous Int

tilemap
emitTileHeightChange(current: Int, previous: Int): Void

Event when tileHeight field changes.

Name Type
current Int
previous Int

tilemap
emitSpacingChange(current: Int, previous: Int): Void

Event when spacing field changes.

Name Type
current Int
previous Int

tilemap
emitMarginChange(current: Int, previous: Int): Void

Event when margin field changes.

Name Type
current Int
previous Int

tilemap
emitTileCountChange(current: Int, previous: Int): Void

Event when tileCount field changes.

Name Type
current Int
previous Int

tilemap
emitColumnsChange(current: Int, previous: Int): Void

Event when columns field changes.

Name Type
current Int
previous Int

tilemap
emitRowsChange(current: Int, previous: Int): Void

Event when rows field changes.

Name Type
current Int
previous Int

tilemap
emitImageChange(current: TilesetImage, previous: TilesetImage): Void

Event when image field changes.

Name Type
current TilesetImage
previous TilesetImage

tilemap
emitGridOrientationChange(current: Anonymous, previous: Anonymous): Void

Event when gridOrientation field changes.

Name Type
current Anonymous
previous Anonymous

tilemap
emitGridCellWidthChange(current: Int, previous: Int): Void

Event when gridCellWidth field changes.

Name Type
current Int
previous Int

tilemap
emitGridCellHeightChange(current: Int, previous: Int): Void

Event when gridCellHeight field changes.

Name Type
current Int
previous Int

tilemap
emitSlopesChange(current: ReadOnlyArray<TileSlope>, previous: ReadOnlyArray<TileSlope>): Void

Event when slopes field changes.

Name Type
current ReadOnlyArray<TileSlope>
previous ReadOnlyArray<TileSlope>

tilemap
toString(): String
Returns
String

Metadata

Name Parameters
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.ObservableMacro.build()
:autoBuild tracker.macros.ObservableMacro.build()
:build tracker.macros.SerializableMacro.build()
:autoBuild tracker.macros.SerializableMacro.build()