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:
-
tilemapAtlantis.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:
-
spriteBatchAtlantis.SpriteBatchAn instance of SpriteBatch for drawing the tileset.
-
cameraAtlantis.Camera2DThe camera to use to defined what must be drawn.
drawBackground
-
spriteBatch -
layer -
background
Draw the background with this defined offset
Parameters:
-
spriteBatchAtlantis.SpriteBatchAn instance of SpriteBatch for drawing the background.
-
layerAtlantis.TilemapLayerThe layer to draw.
-
backgroundImage | CanvasAn image or canvas to draw as background.
drawLayer
-
spriteBatch -
camera -
layer -
The
Draw tiles with the defined offset, spacing and margin
Parameters:
-
spriteBatchAtlantis.SpriteBatchAn instance of SpriteBatch for drawing the tileset.
-
cameraAtlantis.Camera2DThe camera to use to defined what must be drawn.
-
layerAtlantis.TilemapLayerThe layer to draw.
-
TheAtlantis.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:
-
tilesetAtlantis.TilesetThe tileset to use to extract the tile.
-
layerIndexNumberThe index of the layer
-
xNumberThe position of the tile on X axis.
-
yNumberThe 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.
