Started revamp of the Tilemap system. Also removed old 'Advanced Physics' and dropped in p2.js which is what I hope we'll eventually use.

This commit is contained in:
photonstorm
2013-10-11 04:42:11 +01:00
parent a7230aa769
commit b868c2cb1b
72 changed files with 6704 additions and 6454 deletions
+80 -17
View File
@@ -56,6 +56,11 @@ Phaser.Cache = function (game) {
*/
this._tilemaps = {};
/**
* @property {object} _tilesets - Tileset key-value container.
* @private
*/
this._tilesets = {};
this.addDefaultImage();
@@ -118,6 +123,28 @@ Phaser.Cache.prototype = {
},
/**
* Add a new tile set in to the cache.
*
* @method Phaser.Cache#addTileset
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of this tile set file.
* @param {object} data - Extra tile set data.
* @param {number} tileWidth - Width of the sprite sheet.
* @param {number} tileHeight - Height of the sprite sheet.
* @param {number} tileMax - How many tiles stored in the sprite sheet.
*/
addTileset: function (key, url, data, tileWidth, tileHeight, tileMax) {
this._tilesets[key] = { url: url, data: data, tileWidth: tileWidth, tileHeight: tileHeight };
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
this._tilesets[key].tileData = Phaser.TilemapParser.tileset(this.game, key, tileWidth, tileHeight, tileMax);
},
/**
* Add a new tilemap.
*
@@ -208,6 +235,23 @@ Phaser.Cache.prototype = {
},
/**
* Add a new text data.
*
* @method Phaser.Cache#addText
* @param {string} key - Asset key for the text data.
* @param {string} url - URL of this text data file.
* @param {object} data - Extra text data.
*/
addText: function (key, url, data) {
this._text[key] = {
url: url,
data: data
};
},
/**
* Add a new image.
*
@@ -316,23 +360,6 @@ Phaser.Cache.prototype = {
this._sounds[key].decoded = true;
this._sounds[key].isDecoding = false;
},
/**
* Add a new text data.
*
* @method Phaser.Cache#addText
* @param {string} key - Asset key for the text data.
* @param {string} url - URL of this text data file.
* @param {object} data - Extra text data.
*/
addText: function (key, url, data) {
this._text[key] = {
url: url,
data: data
};
},
/**
@@ -387,6 +414,42 @@ Phaser.Cache.prototype = {
return null;
},
/**
* Get tile set image data by key.
*
* @method Phaser.Cache#getTileSetImage
* @param {string} key - Asset key of the image you want.
* @return {object} The image data you want.
*/
getTilesetImage: function (key) {
if (this._tilesets[key])
{
return this._tilesets[key].data;
}
return null;
},
/**
* Get tile set image data by key.
*
* @method Phaser.Cache#getTileset
* @param {string} key - Asset key of the image you want.
* @return {Phaser.Tileset} The tileset data. The tileset image is in the data property, the tile data in tileData.
*/
getTileset: function (key) {
if (this._tilesets[key])
{
return this._tilesets[key];
}
return null;
},
/**
* Get tilemap data by key.
*