Gamalto

Fork me on GitHub

Object TileMap Overview

Gamalto. TileMap

new Gamalto.TileMap(ts, width, height)

Creates a new rectangular tile-based map.

Parameters
Name Type Description
ts Gamalto.TileSet

Tilset to be used to render the map.

width number

Viewport horizontal size.

height number

Viewport vertical size.

Extends

Members

data :array.<number>

inherited readonly

List of tile indices representing the image.

Inherited From

height :number

inherited readonly

Vertical size of the image in tiles.

Inherited From
Implements

loop :boolean

Whether the map loops. Defaults to not looping.

origin :Gamalto.Vector2

Gets of sets the origin of the visible area of the map in tiles.

tag :object

inherited

Utility property to exchange data between objects.

Inherited From

viewport :Gamalto.Size

Gets or sets the size of the visible area of the map in tiles.

width :number

inherited readonly

Horizontal size of the image in tiles.

Inherited From
Implements

Methods

clone() object

inherited abstract

Clones the object. It will be shallow copy unless otherwise specfied.

Inherited From
Returns
  • New instance of the object. Defaults to null.

draw(renderer, x, y)

Renders the visible part of the map including the overscan if any.

Parameters
Name Type Description
renderer Gamalto.BaseRenderer

Renderer of the Gamalto.surface to which the map will be rendered.

x number

Horizontal drawing position.

y number

Vertical drawing position.

getTile(x, y, absoluteopt) Gamalto.Tile

Gets the tile at the given position.

Parameters
Name Type Attributes Description
x number

Horizontal position in the map.

y number

Vertical position in the map.

absolute boolean <optional>

Whether to get the tile at an absolute position or in the visible space.

Returns

redraw(renderer, x, y) array.<Gamalto.IBox>

Redraws the missing sides of the viewport when scrolling the map.

Parameters
Name Type Description
renderer Gamalto.BaseRenderer

Renderer of the Gamalto.surface to which the sides will be rendered.

x number

Horizontal drawing position of the map.

y number

Vertical drawing position of the map.

Returns
  • List of redrawn areas or null if nothing has been redrawn.

setData(data, width, height)

inherited

Sets the data needed to render the tile-based image.

Parameters
Name Type Description
data array.<number>

List of tile indices representing the image.

width number

Horizontal size of the image in tiles.

height number

Vertical size of the image in tiles.

Inherited From

setOverscan(top, right, bottom, left)

Sets the size in tiles of the offscreen area to be drawn around the effective viewport to help sides redraw while moving in the map.

Parameters
Name Type Description
top number

Size of the top part of the overscan.

right number

Size of the right part of the overscan.

bottom number

Size of the bottom part of the overscan.

left number

Size of the left part of the overscan.

toString() string

inherited abstract

Converts the object into a string.

Inherited From
Returns
  • string

update(mx, my) Gamalto.Vector2

Updates the map position. You can, for instance, pass the computed displacement of a Gamalto.ScrollingRegion and then adjust the effective scrolling displacement with the returned ratios.

Parameters
Name Type Description
mx number

Horizontal displacement in pixels.

my number

Vertical displacement in pixels.

Returns
  • Ratios applied to the desired displacement. Always (1,1) when the map loops.

Documentation generated by JSDoc 3.3.2 on Sun Sep 13 2015 20:13:31 GMT+0200 (CEST)