Atlantis.Tilemap Class
This class is responsible to store all data for drawing a tilemap. A tilemap is composed of layers, tilesets and backgrounds.
Constructor
Atlantis.Tilemap
-
tilemap
Parameters:
-
tilemap
Atlantis.Tilemap | Object(optional) An object that contains tilemap data.
Item Index
Methods
- draw
- drawBackground
- drawLayer
- getTileAt
- getTileIdAt
- isoToScreen static
- screenToIso static
Methods
draw
-
spriteBatch
-
camera
Draw the tilemap if it's visible and loaded.
Parameters:
-
spriteBatch
Atlantis.SpriteBatchAn instance of SpriteBatch for drawing the tileset.
-
camera
Atlantis.Camera2DThe camera to use to defined what must be drawn.
drawBackground
-
spriteBatch
-
layer
-
background
Draw the background with this defined offset
Parameters:
-
spriteBatch
Atlantis.SpriteBatchAn instance of SpriteBatch for drawing the background.
-
layer
Atlantis.TilemapLayerThe layer to draw.
-
background
Image | CanvasAn image or canvas to draw as background.
drawLayer
-
spriteBatch
-
camera
-
layer
-
The
Draw tiles with the defined offset, spacing and margin
Parameters:
-
spriteBatch
Atlantis.SpriteBatchAn instance of SpriteBatch for drawing the tileset.
-
camera
Atlantis.Camera2DThe camera to use to defined what must be drawn.
-
layer
Atlantis.TilemapLayerThe layer to draw.
-
The
Atlantis.Tilesettileset to use for drawing the layer.
getTileAt
-
tileset
-
layerIndex
-
x
-
y
Extract a tile from tileset and return a canvas element with the tile drawn in it. It's usefull to do some tests, such as pixel perfect. Note 1: that it's work with a scale different to 1. Note 2: The extraction is done once, the result is stored in a cache, so you can safely call this method.
Parameters:
-
tileset
Atlantis.TilesetThe tileset to use to extract the tile.
-
layerIndex
NumberThe index of the layer
-
x
NumberThe position of the tile on X axis.
-
y
NumberThe postion of the tile on Y axis.
Returns:
Return a canvas element of the specified tile if exists, otherwise return null.
getTileIdAt
-
layerIndex
-
x
-
y
Gets the tile index at the specified position.
Parameters:
Returns:
Return the id of the tile at this position if exists, otherwise return 0.