Constructor
new Tileset(path, twidth, theight)
| Name | Type | Description |
|---|---|---|
path | String | The image/tileset filepath |
twidth | Number | The width of each tile |
theight | Number | The height of each tile |
- Source
let myTileset = new gameify.Tileset("images/tileset.png");
// Give the coordinates of a tile to retrieve it
let grassTile = myTileset.getTile(3, 2);Members
(package) texture
The tileset's image/texture
- Source
(readonly) theight
The Tilemap's tile height
- Source
(readonly) theight
The Tileset's tile height
- Source
(readonly) twidth
The Tilemap's tile width
- Source
(readonly) twidth
The Tileset's tile width
- Source
Methods
changePath(path)
Change and load a new image path. Please note this does not clear tilemaps' cached data, and it might retain its the original image.
| Name | Type | Description |
|---|---|---|
path | string | The new tileset image path |
- Source
fromJSON(data, ref) → {gameify.Tileset}
Creates a object 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.
Tileset
getTile(x, y, widthopt, heightopt) → {gameify.Image}
Get a tile (or section of tiles) from the tileset. Returns a new Image object each time, so if you're getting the same tile a lot you might want to save it to a variable
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x | Number | The x coordinate of the tile | ||
y | Number | The y coordinate of the tile | ||
width | Number | <optional> | 1 | How many tiles wide |
height | Number | <optional> | 1 | How many tiles tall |
- Source
- Type:
- gameify.
Image
onLoad(callback)
Set a function to be run when the image is loaded
| Name | Type | Description |
|---|---|---|
callback | function | The function to be called when the image is loaded. |
- Source
removeCollisionShape(tilex, tiley)
Remove a collision shape from the tileset
| Name | Type | Description |
|---|---|---|
tilex | Number | |
tiley | Number |
- Source
removeCollisionShape(tilepos)
Remove a collision shape from the tileset
| Name | Type | Description |
|---|---|---|
tilepos | gameify. |
- Source
setCollisionShape(shape, tilex, tiley)
Add a collision shape to the tileset
| Name | Type | Description |
|---|---|---|
shape | gameify. | |
tilex | Number | |
tiley | Number |
- Source
setCollisionShape(shape, tilepos)
Add a collision shape to the tileset
| Name | Type | Description |
|---|---|---|
shape | gameify. | |
tilepos | gameify. |
- Source
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