mirror of
https://github.com/wassname/phaser.git
synced 2026-07-22 12:50:19 +08:00
The entire Phaser library has been updated to match the new JSHint configuration.
This commit is contained in:
+102
-103
@@ -16,44 +16,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 = {};
|
||||
|
||||
/**
|
||||
@@ -72,9 +72,9 @@ Phaser.Cache = function (game) {
|
||||
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();
|
||||
|
||||
};
|
||||
|
||||
@@ -282,7 +282,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] = {
|
||||
@@ -326,7 +326,6 @@ Phaser.Cache.prototype = {
|
||||
webAudio = webAudio || true;
|
||||
audioTag = audioTag || false;
|
||||
|
||||
var locked = this.game.sound.touchLocked;
|
||||
var decoded = false;
|
||||
|
||||
if (audioTag)
|
||||
@@ -388,13 +387,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;
|
||||
@@ -403,13 +402,13 @@ Phaser.Cache.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a canvas 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])
|
||||
@@ -445,7 +444,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])
|
||||
@@ -457,13 +456,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])
|
||||
@@ -481,7 +480,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])
|
||||
@@ -499,7 +498,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])
|
||||
@@ -528,13 +527,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)
|
||||
@@ -631,13 +630,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])
|
||||
@@ -649,13 +648,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])
|
||||
@@ -667,13 +666,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])
|
||||
@@ -683,26 +682,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);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 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])
|
||||
@@ -714,13 +713,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])
|
||||
@@ -756,42 +755,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];
|
||||
},
|
||||
@@ -826,11 +825,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)
|
||||
|
||||
+1058
-1058
File diff suppressed because it is too large
Load Diff
@@ -10,14 +10,14 @@
|
||||
* @class Phaser.LoaderParser
|
||||
*/
|
||||
Phaser.LoaderParser = {
|
||||
|
||||
|
||||
/**
|
||||
* Parse frame data from an XML file.
|
||||
* @method Phaser.LoaderParser.bitmapFont
|
||||
* @param {object} xml - XML data you want to parse.
|
||||
* @return {FrameData} Generated FrameData object.
|
||||
*/
|
||||
bitmapFont: function (game, xml, cacheKey) {
|
||||
bitmapFont: function (game, xml, cacheKey) {
|
||||
|
||||
// Malformed?
|
||||
if (!xml.getElementsByTagName('font'))
|
||||
@@ -50,8 +50,8 @@ Phaser.LoaderParser = {
|
||||
height: parseInt(letters[i].attributes.getNamedItem("height").nodeValue, 10)
|
||||
};
|
||||
|
||||
// Note: This means you can only have 1 BitmapFont loaded at once!
|
||||
// Need to replace this with our own handler soon.
|
||||
// Note: This means you can only have 1 BitmapFont loaded at once!
|
||||
// Need to replace this with our own handler soon.
|
||||
PIXI.TextureCache[charCode] = new PIXI.Texture(texture, textureRect);
|
||||
|
||||
data.chars[charCode] = {
|
||||
@@ -69,9 +69,9 @@ Phaser.LoaderParser = {
|
||||
|
||||
for (i = 0; i < kernings.length; i++)
|
||||
{
|
||||
var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10);
|
||||
var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10);
|
||||
var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10);
|
||||
var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10);
|
||||
var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10);
|
||||
var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10);
|
||||
|
||||
data.chars[second].kerning[first] = amount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user