gameify. Tile

A Tile as part of a Tilemap (not a tile from a Tileset)

Constructor

new Tile(x, y, sourcex, sourcey, image, rotationopt, widthopt, heightopt, twidthopt)

Parameters:
NameTypeAttributesDefaultDescription
xNumber

The x coordinate of the tile

yNumber

The y coordinate of the tile

sourcexNumber

The source x coordinate of the tile

sourceyNumber

The source y coordinate of the tile

imagegameify.Image

The tile's Image (reference)

rotationNumber<optional>
0

The rotation of the tile, in degrees

widthNumber<optional>
1

The width (in tiles) of the tile

heightNumber<optional>
1

The height (in tiles) of the tile

twidthNumber<optional>
1

The width (in pixels) of the tile on the tilemap

Members

image :gameify.Image

The tile's Image

position :gameify.Vector2d

The tile's position in the tilemap

rotation :Number

The tile's rotation

Type:
  • Number

size :gameify.Vector2d

The tile's size (in tiles)

source :gameify.Vector2d

The tile's source coordinates

tags :Array.<String>

Any tags that the tile has

Type:
  • Array.<String>

(static, readonly) shape :gameify.shapes.Shape

The tile's collision shape

Methods

fromJSON(data, ref) → {gameify.Tile}

Creates a Tile from JSON data

Parameters:
NameTypeDescription
dataObject | Array

Serialized object data (from object.toJSON)

reffunction

A function that returns a name for other objects, so they can be restored later

Returns:
Type: 
gameify.Tile

hasTag(tag) → {boolean}

Check if the tile has a tag

Parameters:
NameTypeDescription
tagString

The tag to check for

Returns:
Type: 
boolean

toJSON(keyopt, ref) → {Object}

Convert the object to JSON

Parameters:
NameTypeAttributesDescription
keystring<optional>

Key object is stored under (unused, here for consistency with e.g. Date.toJSON, etc.)

reffunction

A function that returns a name for other objects, so they can be restored later

Returns:
Type: 
Object