phaser/src/tilemap/Tileset.js

59 lines
873 B
JavaScript
Raw Normal View History

2013-10-11 05:30:28 +00:00
Phaser.Tileset = function (image, key, tileWidth, tileHeight) {
/**
* @property {string} key - The cache ID.
*/
this.key = key;
2013-10-11 05:30:28 +00:00
this.image = image;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
2013-10-11 05:30:28 +00:00
this.tiles = [];
}
Phaser.Tileset.prototype = {
addTile: function (tile) {
2013-10-11 05:30:28 +00:00
this.tiles.push(tile);
return tile;
},
getTile: function (index) {
2013-10-11 05:30:28 +00:00
if (this.tiles[index])
{
2013-10-11 05:30:28 +00:00
return this.tiles[index];
}
return null;
2013-10-11 05:30:28 +00:00
},
checkTileIndex: function (index) {
return (this.tiles[index]);
}
}
/**
* @name Phaser.Tileset#total
* @property {number} total - The total number of tiles in this Tileset.
* @readonly
*/
Object.defineProperty(Phaser.Tileset.prototype, "total", {
get: function () {
2013-10-11 05:30:28 +00:00
return this.tiles.length;
}
});