Constructor
new Tile(x, y, sourcex, sourcey, image, rotationopt, widthopt, heightopt, twidthopt)
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x | Number | The x coordinate of the tile | ||
y | Number | The y coordinate of the tile | ||
sourcex | Number | The source x coordinate of the tile | ||
sourcey | Number | The source y coordinate of the tile | ||
image | gameify. | The tile's Image (reference) | ||
rotation | Number | <optional> | 0 | The rotation of the tile, in degrees |
width | Number | <optional> | 1 | The width (in tiles) of the tile |
height | Number | <optional> | 1 | The height (in tiles) of the tile |
twidth | Number | <optional> | 1 | The width (in pixels) of the tile on the tilemap |
- Source
Members
image :gameify.Image
The tile's Image
- Source
position :gameify.Vector2d
The tile's position in the tilemap
- Source
rotation :Number
The tile's rotation
- Number
- Source
size :gameify.Vector2d
The tile's size (in tiles)
- Source
source :gameify.Vector2d
The tile's source coordinates
- Source
tags :Array.<String>
Any tags that the tile has
- Array.<String>
- Source
(static, readonly) shape :gameify.shapes.Shape
The tile's collision shape
- Source
Methods
fromJSON(data, ref) → {gameify.Tile}
Creates a Tile from JSON data
| Name | Type | Description |
|---|---|---|
data | Object | | Serialized object data (from object.toJSON) |
ref | function | A function that returns a name for other objects, so they can be restored later |
- Source
- Type:
- gameify.
Tile
hasTag(tag) → {boolean}
Check if the tile has a tag
| Name | Type | Description |
|---|---|---|
tag | String | The tag to check for |
- Source
- Type:
- boolean
toJSON(keyopt, ref) → {Object}
Convert the object to JSON
| Name | Type | Attributes | Description |
|---|---|---|---|
key | string | <optional> | Key object is stored under (unused, here for consistency with e.g. Date.toJSON, etc.) |
ref | function | A function that returns a name for other objects, so they can be restored later |
- Source
- Type:
- Object