From c6bf67c392a64865d3620e2417c29e225206a6e5 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Sun, 13 Oct 2013 20:28:06 +0100 Subject: [PATCH] Group.alpha exposed and instance returns added to Loader functions. --- README.md | 3 +++ examples/sprites/sprite rotation.php | 7 ++++++- src/core/Group.js | 16 ++++++++++++++++ src/loader/Loader.js | 25 +++++++++++++++++++++---- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 25444cee..3055d140 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,9 @@ Version 1.0.7 (in progress in the dev branch) * You can now pass a PIXI.Texture to Sprite (you also need to pass a Phaser.Frame as the frame parameter) but this is useful for Sprites sharing joint canvases. * Fixed Issue #101 (Mouse Button 0 is not recognised, thanks rezoner) * Added Sprite.destroy back in again and made it a lot more robust at cleaning up child objects. +* Added 'return this' to all the core Loader functions so you can chain load calls if you so wish. +* Group.alpha is now exposed publically and changes the Group container object (not the children directly, who can still have their own alpha values) + diff --git a/examples/sprites/sprite rotation.php b/examples/sprites/sprite rotation.php index 706a815f..237da936 100644 --- a/examples/sprites/sprite rotation.php +++ b/examples/sprites/sprite rotation.php @@ -25,7 +25,12 @@ function update() { - sprite.rotation += 0.01; + sprite.angle += 1; + + // Note: Due to a bug in Chrome the following doesn't work atm: + // sprite.angle++; + // See: https://code.google.com/p/chromium/issues/detail?id=306851 + } diff --git a/src/core/Group.js b/src/core/Group.js index eece453b..0bbaf228 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -1219,3 +1219,19 @@ Object.defineProperty(Phaser.Group.prototype, "visible", { } }); + +/** +* @name Phaser.Group#alpha +* @property {number} alpha - The alpha value of the Group container. +*/ +Object.defineProperty(Phaser.Group.prototype, "alpha", { + + get: function () { + return this._container.alpha; + }, + + set: function (value) { + this._container.alpha = value; + } + +}); diff --git a/src/loader/Loader.js b/src/loader/Loader.js index 42c60a30..f672c48c 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -251,6 +251,8 @@ Phaser.Loader.prototype = { this.addToFileList('image', key, url); } + return this; + }, /** @@ -270,6 +272,8 @@ Phaser.Loader.prototype = { this.addToFileList('text', key, url); } + return this; + }, /** @@ -291,6 +295,8 @@ Phaser.Loader.prototype = { this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax }); } + return this; + }, /** @@ -312,6 +318,8 @@ Phaser.Loader.prototype = { this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax }); } + return this; + }, /** @@ -331,6 +339,8 @@ Phaser.Loader.prototype = { this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode }); } + return this; + }, /** @@ -352,7 +362,8 @@ Phaser.Loader.prototype = { if (mapDataURL == null && mapData == null) { console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.'); - return; + + return this; } if (this.checkKeyExists(key) === false) @@ -385,6 +396,8 @@ Phaser.Loader.prototype = { } } + return this; + }, /** @@ -445,6 +458,8 @@ Phaser.Loader.prototype = { } } + return this; + }, /** @@ -457,7 +472,7 @@ Phaser.Loader.prototype = { */ atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); }, @@ -471,7 +486,7 @@ Phaser.Loader.prototype = { */ atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); }, @@ -485,7 +500,7 @@ Phaser.Loader.prototype = { */ atlasXML: function (key, textureURL, atlasURL, atlasData) { - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); }, @@ -568,6 +583,8 @@ Phaser.Loader.prototype = { } + return this; + }, /**