mirror of
https://github.com/wassname/phaser.git
synced 2026-09-10 12:29:30 +08:00
Promoted the Tilemap to a DisplayObject and vastly simplified the load process.
This commit is contained in:
@@ -47,6 +47,12 @@ Phaser.Cache = function (game) {
|
||||
*/
|
||||
this._text = {};
|
||||
|
||||
/**
|
||||
* Tilemap key-value container.
|
||||
* @type {object}
|
||||
*/
|
||||
this._tilemaps = {};
|
||||
|
||||
this.addDefaultImage();
|
||||
|
||||
this.onSoundUnlock = new Phaser.Signal;
|
||||
@@ -100,6 +106,22 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new tilemap.
|
||||
* @param key {string} Asset key for the texture atlas.
|
||||
* @param url {string} URL of this texture atlas file.
|
||||
* @param data {object} Extra texture atlas data.
|
||||
* @param atlasData {object} Texture atlas frames data.
|
||||
*/
|
||||
addTilemap: function (key, url, data, mapData, format) {
|
||||
|
||||
this._tilemaps[key] = { url: url, data: data, spriteSheet: true, mapData: mapData, format: format };
|
||||
|
||||
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
|
||||
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new texture atlas.
|
||||
* @param key {string} Asset key for the texture atlas.
|
||||
@@ -315,6 +337,21 @@ Phaser.Cache.prototype = {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get tilemap data by key.
|
||||
* @param key Asset key of the tilemap you want.
|
||||
* @return {object} The tilemap data. The tileset image is in the data property, the map data in mapData.
|
||||
*/
|
||||
getTilemap: function (key) {
|
||||
|
||||
if (this._tilemaps[key])
|
||||
{
|
||||
return this._tilemaps[key];
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get frame data by key.
|
||||
* @param key Asset key of the frame data you want.
|
||||
|
||||
Reference in New Issue
Block a user