API Docs for:
Show:

gs.Tilemap Class

A tilemap can be used to display the environment of a level/map of a game. For more information about how to use tilemaps, features and limitations please read the "Scripter's Guide" in the help-file.

Constructor

gs.Tilemap

(
  • viewport
)

Parameters:

  • viewport gs.Viewport
    • The viewport to associate the tilemap with.

Methods

convertTileId

(
  • tile
  • index
  • framesX
  • x
  • y
  • z
)
Number

If necessary, you can override or patch this method to convert tile-ids into another ID space. No conversion is done by default, it returns the tile-id without any changes.

Parameters:

  • tile Number
    • The tile id to convert.
  • index Index
    • The index of the tile id in the map-data array.
  • framesX Number
    • The number of tiles on x-axis in the tileset.
  • x Number
    • The x-coordinate of the tile on the tilemap.
  • y Number
    • The y-coordinate of the tile on the tilemap.
  • z Number
    • The tilemap layer the tile is placed on.

Returns:

Number:

The converted tile id.

dispose

()

Disposes the tilemap and frees the memory. Should be called if the tilemap is no longer needed to free resources.

setup

()

Initializes the tilemap. Must be called after the tilemap settings, map-data and tileset data are set.

update

()

Updates the tilemap scrolling, etc. Needs to be called once per frame.

Properties

animationSpeed

Number

The animation speed for animated tiles. It defines the duration in frames before the next animation frame is displayed.

Default: 16

autotiles

gs.Bitmap[]

An array of autotile-tiles in standard format which are automatically expanded and drawn on the expanded tileset bitmap.

color

Boolean

The color. Can be used for flashing-effects, etc.

depth

Number

The count of tilemap layers.

Default: 3

expandedAutotiles

gs.Bitmap[]

An array of expanded autotile-tiles. They are automatically generated from autotiles-property.

height

Number

The height of the tilemap in tiles

Default: 50

layers

gs.TilemapLayer[]

Array of layer objects used to render the layers of the tilemap.

mapData

Number

An array storing the map-data. Each number in the array refers to a tile on the tileset.

mask

gs.Mask

The mask used for masking-effects.

priorities

Number

An array storing numbers by tile-id to control which tiles are overlapping.

tileset

gs.Bitmap

The tileset bitmap used to construct the tilemap.

tilesetConfig

gs.TilesetConfiguration

The tileset configuration to configure tileset size, regular tiles, auto-tiles and animated tiles. If you want change the configuration, you have to do that before you call the setup-method of the tilemap.

tileSize

Number

The size of a single tile. A tile needs to be quadratic so a value of 32 means 32x32 pixels.

Default: 32

tone

gs.Tone

The color tone.

width

Number

The width of the tilemap in tiles

Default: 50