API Docs for: 0.0.2
Show:

Atlantis.Tilemap Class

Module: Engine
Parent Module: Atlantis

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:

Methods

draw

(
  • spriteBatch
  • camera
)

Draw the tilemap if it's visible and loaded.

Parameters:

drawBackground

(
  • spriteBatch
  • layer
  • background
)

Draw the background with this defined offset

Parameters:

drawLayer

(
  • spriteBatch
  • camera
  • layer
  • The
)

Draw tiles with the defined offset, spacing and margin

Parameters:

getTileAt

(
  • tileset
  • layerIndex
  • x
  • y
)
HTMLCanvas

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.Tileset

    The tileset to use to extract the tile.

  • layerIndex Number

    The index of the layer

  • x Number

    The position of the tile on X axis.

  • y Number

    The postion of the tile on Y axis.

Returns:

HTMLCanvas:

Return a canvas element of the specified tile if exists, otherwise return null.

getTileIdAt

(
  • layerIndex
  • x
  • y
)
Number

Gets the tile index at the specified position.

Parameters:

  • layerIndex Number

    The index of the layer

  • x Number

    The position of the tile on X axis.

  • y Number

    The postion of the tile on Y axis.

Returns:

Number:

Return the id of the tile at this position if exists, otherwise return 0.

isoToScreen

(
  • x
  • y
)
Object static

Get a transformed position from isometric world coordinates to screen coordinates.

Parameters:

  • x Number

    The x coordinate on isometric world.

  • y Number

    The y coordinate on isometric world.

Returns:

Object:

Return an object with transformed coordinates.

screenToIso

(
  • x
  • y
)
Object static

Get a transformed position from screen coordinates to iso coordinates.

Parameters:

  • x Number

    The x coordinate on screen.

  • y Number

    The y coordinate on screen.

Returns:

Object:

Return an object with transformed coordinates.