Version: alpha
FUNCTION | |
---|---|
tilemap.set_tile() | set a tile in a tile map |
tilemap.get_tile() | get a tile from a tile map |
tilemap.get_bounds() | get the bounds of a tile map |
tilemap.set_visible() | set the visibility of a layer |
PROPERTIES | |
---|---|
tile_source | hash tile source |
material | hash tile map material |
tilemap.set_tile(url,layer,x,y,tile,[h-flipped],[v-flipped])
+-------+-------+------+------+ | 0,3 | 1,3 | 2,3 | 3,3 | +-------+-------+------+------+ | 0,2 | 1,2 | 2,2 | 3,2 | +-------+-------+------+------+ | 0,1 | 1,1 | 2,1 | 3,1 | +-------O-------+------+------+ | 0,0 | 1,0 | 2,0 | 3,0 | +-------+-------+------+------+The coordinates must be within the bounds of the tile map as it were created. That is, it is not possible to extend the size of a tile map by setting tiles outside the edges. To clear a tile, set the tile to number 0. Which tile map and layer to manipulate is identified by the URL and the layer name parameters.
PARAMETERS
url |
the tile map |
layer |
name of the layer for the tile |
x |
x-coordinate of the tile |
y |
y-coordinate of the tile |
tile |
index of new tile to set |
[h-flipped] |
optional if the tile should be horizontally flipped |
[v-flipped] |
optional i the tile should be vertically flipped |
EXAMPLES
-- Clear the tile under the player. tilemap.set_tile("/level#tilemap", "foreground", self.player_x, self.player_y, 0)
tilemap.get_tile(url,layer,x,y)
PARAMETERS
url |
the tile map |
layer |
name of the layer for the tile |
x |
x-coordinate of the tile |
y |
y-coordinate of the tile |
RETURNS
tile |
index of the tile |
EXAMPLES
-- get the tile under the player. local tileno = tilemap.get_tile("/level#tilemap", "foreground", self.player_x, self.player_y)
tilemap.get_bounds(url)
PARAMETERS
url |
the tile map |
RETURNS
x |
x coordinate of the bottom left corner |
y |
y coordinate of the bottom left corner |
w |
number of columns (width) in the tile map |
h |
number of rows (height) in the tile map |
EXAMPLES
-- get the level bounds. local x, y, w, h = tilemap.get_bounds("/level#tilemap")
tilemap.set_visible(url,layer,visible)
PARAMETERS
url |
the tile map |
layer |
name of the layer for the tile |
visible |
should the layer be visible |
EXAMPLES
-- Disable rendering of the layer tilemap.set_visible("/level#tilemap", "foreground", false)
The tile source used when rendering the tile map. The type of the property is hash.
hash tile source
EXAMPLES
How to set tile source using a script property (see resource.tile_source)go.property("my_tile_source", resource.tile_source("/tilesource.tilesource")) function init(self) go.set("#tilemap", "tile_source", self.my_tile_source) end
The material used when rendering the tile map. The type of the property is hash.
hash tile map material
EXAMPLES
How to set material using a script property (see resource.material)go.property("my_material", resource.material("/material.material")) function init(self) go.set("#tilemap", "material", self.my_material) end