mirror of
https://github.com/wassname/phaser.git
synced 2026-08-17 11:23:42 +08:00
Updated documentation.
This commit is contained in:
+208
-109
@@ -54,6 +54,10 @@
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
@@ -138,6 +142,10 @@
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
@@ -302,6 +310,26 @@
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
@@ -310,6 +338,10 @@
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
@@ -356,6 +388,14 @@
|
||||
<a href="global.html#HEXtoRGB">HEXtoRGB</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#render">render</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#renderXY">renderXY</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#right">right</a>
|
||||
</li>
|
||||
@@ -399,44 +439,44 @@
|
||||
Phaser.Cache = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
this.game = game;
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {object} game - Canvas key-value container.
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* @property {object} game - Canvas key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._canvases = {};
|
||||
|
||||
/**
|
||||
* @property {object} _images - Image key-value container.
|
||||
* @private
|
||||
*/
|
||||
* @property {object} _images - Image key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._images = {};
|
||||
|
||||
/**
|
||||
* @property {object} _textures - RenderTexture key-value container.
|
||||
* @private
|
||||
*/
|
||||
* @property {object} _textures - RenderTexture key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._textures = {};
|
||||
|
||||
/**
|
||||
* @property {object} _sounds - Sound key-value container.
|
||||
* @private
|
||||
*/
|
||||
* @property {object} _sounds - Sound key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._sounds = {};
|
||||
|
||||
/**
|
||||
* @property {object} _text - Text key-value container.
|
||||
* @private
|
||||
*/
|
||||
* @property {object} _text - Text key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._text = {};
|
||||
|
||||
/**
|
||||
* @property {object} _tilemaps - Tilemap key-value container.
|
||||
* @private
|
||||
*/
|
||||
* @property {object} _tilemaps - Tilemap key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._tilemaps = {};
|
||||
|
||||
/**
|
||||
@@ -445,12 +485,19 @@ Phaser.Cache = function (game) {
|
||||
*/
|
||||
this._tilesets = {};
|
||||
|
||||
/**
|
||||
* @property {object} _bitmapDatas - BitmapData key-value container.
|
||||
* @private
|
||||
*/
|
||||
this._bitmapDatas = {};
|
||||
|
||||
this.addDefaultImage();
|
||||
this.addMissingImage();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onSoundUnlock - Description.
|
||||
*/
|
||||
this.onSoundUnlock = new Phaser.Signal;
|
||||
* @property {Phaser.Signal} onSoundUnlock - This event is dispatched when the sound system is unlocked via a touch event on cellular devices.
|
||||
*/
|
||||
this.onSoundUnlock = new Phaser.Signal();
|
||||
|
||||
};
|
||||
|
||||
@@ -469,12 +516,27 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a BitmapData object in to the cache.
|
||||
* @method Phaser.Cache#addBitmapData
|
||||
* @param {string} key - Asset key for this BitmapData.
|
||||
* @param {Phaser.BitmapData} bitmapData - The BitmapData object to be addded to the cache.
|
||||
* @return {Phaser.BitmapData} The BitmapData object to be addded to the cache.
|
||||
*/
|
||||
addBitmapData: function (key, bitmapData) {
|
||||
|
||||
this._bitmapDatas[key] = bitmapData;
|
||||
|
||||
return bitmapData;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new Phaser.RenderTexture in to the cache.
|
||||
*
|
||||
* @method Phaser.Cache#addRenderTexture
|
||||
* @param {string} key - The unique key by which you will reference this object.
|
||||
* @param {Phaser.Texture} textue - The texture to use as the base of the RenderTexture.
|
||||
* @param {Phaser.Texture} texture - The texture to use as the base of the RenderTexture.
|
||||
*/
|
||||
addRenderTexture: function (key, texture) {
|
||||
|
||||
@@ -601,14 +663,14 @@ Phaser.Cache.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default.
|
||||
* Adds a default image to be used in special cases such as WebGL Filters. Is mapped to the key __default.
|
||||
*
|
||||
* @method Phaser.Cache#addDefaultImage
|
||||
*/
|
||||
addDefaultImage: function () {
|
||||
|
||||
var img = new Image();
|
||||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";
|
||||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==";
|
||||
|
||||
this._images['__default'] = { url: null, data: img, spriteSheet: false };
|
||||
this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', '');
|
||||
@@ -618,6 +680,24 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an image to be used when a key is wrong / missing. Is mapped to the key __missing.
|
||||
*
|
||||
* @method Phaser.Cache#addMissingImage
|
||||
*/
|
||||
addMissingImage: function () {
|
||||
|
||||
var img = new Image();
|
||||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";
|
||||
|
||||
this._images['__missing'] = { url: null, data: img, spriteSheet: false };
|
||||
this._images['__missing'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', '');
|
||||
|
||||
PIXI.BaseTextureCache['__missing'] = new PIXI.BaseTexture(img);
|
||||
PIXI.TextureCache['__missing'] = new PIXI.Texture(PIXI.BaseTextureCache['__missing']);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new text data.
|
||||
*
|
||||
@@ -625,7 +705,7 @@ Phaser.Cache.prototype = {
|
||||
* @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] = {
|
||||
@@ -669,7 +749,6 @@ Phaser.Cache.prototype = {
|
||||
webAudio = webAudio || true;
|
||||
audioTag = audioTag || false;
|
||||
|
||||
var locked = this.game.sound.touchLocked;
|
||||
var decoded = false;
|
||||
|
||||
if (audioTag)
|
||||
@@ -731,13 +810,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new decoded sound.
|
||||
/**
|
||||
* Add a new decoded sound.
|
||||
*
|
||||
* @method Phaser.Cache#decodedSound
|
||||
* @param {string} key - Asset key for the sound.
|
||||
* @param {object} data - Extra sound data.
|
||||
*/
|
||||
* @param {string} key - Asset key for the sound.
|
||||
* @param {object} data - Extra sound data.
|
||||
*/
|
||||
decodedSound: function (key, data) {
|
||||
|
||||
this._sounds[key].data = data;
|
||||
@@ -746,13 +825,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get acanvas object from the cache by its key.
|
||||
/**
|
||||
* Get a canvas object from the cache by its key.
|
||||
*
|
||||
* @method Phaser.Cache#getCanvas
|
||||
* @param {string} key - Asset key of the canvas you want.
|
||||
* @return {object} The canvas you want.
|
||||
*/
|
||||
* @param {string} key - Asset key of the canvas you want.
|
||||
* @return {object} The canvas you want.
|
||||
*/
|
||||
getCanvas: function (key) {
|
||||
|
||||
if (this._canvases[key])
|
||||
@@ -761,6 +840,25 @@ Phaser.Cache.prototype = {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a BitmapData object from the cache by its key.
|
||||
*
|
||||
* @method Phaser.Cache#getBitmapData
|
||||
* @param {string} key - Asset key of the BitmapData object you want.
|
||||
* @return {Phaser.BitmapData} The requested BitmapData object if found, or null if not.
|
||||
*/
|
||||
getBitmapData: function (key) {
|
||||
|
||||
if (this._bitmapDatas[key])
|
||||
{
|
||||
return this._bitmapDatas[key];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -769,7 +867,7 @@ Phaser.Cache.prototype = {
|
||||
* @method Phaser.Cache#checkImageKey
|
||||
* @param {string} key - Asset key of the image you want.
|
||||
* @return {boolean} True if the key exists, otherwise false.
|
||||
*/
|
||||
*/
|
||||
checkImageKey: function (key) {
|
||||
|
||||
if (this._images[key])
|
||||
@@ -781,13 +879,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get image data by key.
|
||||
/**
|
||||
* Get image data by key.
|
||||
*
|
||||
* @method Phaser.Cache#getImage
|
||||
* @param {string} key - Asset key of the image you want.
|
||||
* @return {object} The image data you want.
|
||||
*/
|
||||
* @param {string} key - Asset key of the image you want.
|
||||
* @return {object} The image data you want.
|
||||
*/
|
||||
getImage: function (key) {
|
||||
|
||||
if (this._images[key])
|
||||
@@ -796,6 +894,7 @@ Phaser.Cache.prototype = {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -804,7 +903,7 @@ Phaser.Cache.prototype = {
|
||||
* @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])
|
||||
@@ -822,7 +921,7 @@ Phaser.Cache.prototype = {
|
||||
* @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])
|
||||
@@ -851,13 +950,13 @@ Phaser.Cache.prototype = {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get frame data by key.
|
||||
/**
|
||||
* Get frame data by key.
|
||||
*
|
||||
* @method Phaser.Cache#getFrameData
|
||||
* @param {string} key - Asset key of the frame data you want.
|
||||
* @return {Phaser.FrameData} The frame data you want.
|
||||
*/
|
||||
* @param {string} key - Asset key of the frame data you want.
|
||||
* @return {Phaser.FrameData} The frame data you want.
|
||||
*/
|
||||
getFrameData: function (key) {
|
||||
|
||||
if (this._images[key] && this._images[key].frameData)
|
||||
@@ -911,7 +1010,7 @@ Phaser.Cache.prototype = {
|
||||
*/
|
||||
getFrame: function (key) {
|
||||
|
||||
if (this._images[key] && this._images[key].spriteSheet == false)
|
||||
if (this._images[key] && this._images[key].spriteSheet === false)
|
||||
{
|
||||
return this._images[key].frame;
|
||||
}
|
||||
@@ -954,13 +1053,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get sound by key.
|
||||
/**
|
||||
* Get sound by key.
|
||||
*
|
||||
* @method Phaser.Cache#getSound
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {Phaser.Sound} The sound you want.
|
||||
*/
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {Phaser.Sound} The sound you want.
|
||||
*/
|
||||
getSound: function (key) {
|
||||
|
||||
if (this._sounds[key])
|
||||
@@ -972,13 +1071,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get sound data by key.
|
||||
/**
|
||||
* Get sound data by key.
|
||||
*
|
||||
* @method Phaser.Cache#getSoundData
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {object} The sound data you want.
|
||||
*/
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {object} The sound data you want.
|
||||
*/
|
||||
getSoundData: function (key) {
|
||||
|
||||
if (this._sounds[key])
|
||||
@@ -990,13 +1089,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the given sound has finished decoding.
|
||||
/**
|
||||
* Check if the given sound has finished decoding.
|
||||
*
|
||||
* @method Phaser.Cache#isSoundDecoded
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {boolean} The decoded state of the Sound object.
|
||||
*/
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {boolean} The decoded state of the Sound object.
|
||||
*/
|
||||
isSoundDecoded: function (key) {
|
||||
|
||||
if (this._sounds[key])
|
||||
@@ -1006,26 +1105,26 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked.
|
||||
/**
|
||||
* Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked.
|
||||
*
|
||||
* @method Phaser.Cache#isSoundReady
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {boolean} True if the sound is decoded and the device is not touch locked.
|
||||
*/
|
||||
* @param {string} key - Asset key of the sound you want.
|
||||
* @return {boolean} True if the sound is decoded and the device is not touch locked.
|
||||
*/
|
||||
isSoundReady: function (key) {
|
||||
|
||||
return (this._sounds[key] && this._sounds[key].decoded && this.game.sound.touchLocked == false);
|
||||
return (this._sounds[key] && this._sounds[key].decoded && this.game.sound.touchLocked === false);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether an image asset is sprite sheet or not.
|
||||
/**
|
||||
* Check whether an image asset is sprite sheet or not.
|
||||
*
|
||||
* @method Phaser.Cache#isSpriteSheet
|
||||
* @param {string} key - Asset key of the sprite sheet you want.
|
||||
* @return {boolean} True if the image is a sprite sheet.
|
||||
*/
|
||||
* @param {string} key - Asset key of the sprite sheet you want.
|
||||
* @return {boolean} True if the image is a sprite sheet.
|
||||
*/
|
||||
isSpriteSheet: function (key) {
|
||||
|
||||
if (this._images[key])
|
||||
@@ -1037,13 +1136,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get text data by key.
|
||||
/**
|
||||
* Get text data by key.
|
||||
*
|
||||
* @method Phaser.Cache#getText
|
||||
* @param {string} key - Asset key of the text data you want.
|
||||
* @return {object} The text data you want.
|
||||
*/
|
||||
* @param {string} key - Asset key of the text data you want.
|
||||
* @return {object} The text data you want.
|
||||
*/
|
||||
getText: function (key) {
|
||||
|
||||
if (this._text[key])
|
||||
@@ -1079,42 +1178,42 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the keys of Images in the Cache.
|
||||
/**
|
||||
* Returns an array containing all of the keys of Images in the Cache.
|
||||
*
|
||||
* @method Phaser.Cache#getImageKeys
|
||||
* @return {Array} The string based keys in the Cache.
|
||||
*/
|
||||
* @return {Array} The string based keys in the Cache.
|
||||
*/
|
||||
getImageKeys: function () {
|
||||
return this.getKeys(this._images);
|
||||
return this.getKeys(this._images);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the keys of Sounds in the Cache.
|
||||
/**
|
||||
* Returns an array containing all of the keys of Sounds in the Cache.
|
||||
*
|
||||
* @method Phaser.Cache#getSoundKeys
|
||||
* @return {Array} The string based keys in the Cache.
|
||||
*/
|
||||
* @return {Array} The string based keys in the Cache.
|
||||
*/
|
||||
getSoundKeys: function () {
|
||||
return this.getKeys(this._sounds);
|
||||
return this.getKeys(this._sounds);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the keys of Text Files in the Cache.
|
||||
/**
|
||||
* Returns an array containing all of the keys of Text Files in the Cache.
|
||||
*
|
||||
* @method Phaser.Cache#getTextKeys
|
||||
* @return {Array} The string based keys in the Cache.
|
||||
*/
|
||||
* @return {Array} The string based keys in the Cache.
|
||||
*/
|
||||
getTextKeys: function () {
|
||||
return this.getKeys(this._text);
|
||||
return this.getKeys(this._text);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a canvas from the cache.
|
||||
/**
|
||||
* Removes a canvas from the cache.
|
||||
*
|
||||
* @method Phaser.Cache#removeCanvas
|
||||
* @method Phaser.Cache#removeCanvas
|
||||
* @param {string} key - Key of the asset you want to remove.
|
||||
*/
|
||||
*/
|
||||
removeCanvas: function (key) {
|
||||
delete this._canvases[key];
|
||||
},
|
||||
@@ -1149,11 +1248,11 @@ Phaser.Cache.prototype = {
|
||||
delete this._text[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* Clears the cache. Removes every local cache object reference.
|
||||
/**
|
||||
* Clears the cache. Removes every local cache object reference.
|
||||
*
|
||||
* @method Phaser.Cache#destroy
|
||||
*/
|
||||
* @method Phaser.Cache#destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
for (var item in this._canvases)
|
||||
@@ -1199,7 +1298,7 @@ Phaser.Cache.prototype = {
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Thu Nov 28 2013 15:56:25 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user