Skip to content

Commit c6bf67c

Browse files
committed
Group.alpha exposed and instance returns added to Loader functions.
1 parent e98aa20 commit c6bf67c

4 files changed

Lines changed: 46 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ Version 1.0.7 (in progress in the dev branch)
117117
* 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.
118118
* Fixed Issue #101 (Mouse Button 0 is not recognised, thanks rezoner)
119119
* Added Sprite.destroy back in again and made it a lot more robust at cleaning up child objects.
120+
* Added 'return this' to all the core Loader functions so you can chain load calls if you so wish.
121+
* Group.alpha is now exposed publically and changes the Group container object (not the children directly, who can still have their own alpha values)
122+
120123

121124

122125

examples/sprites/sprite rotation.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ function create() {
2525

2626
function update() {
2727

28-
sprite.rotation += 0.01;
28+
sprite.angle += 1;
29+
30+
// Note: Due to a bug in Chrome the following doesn't work atm:
31+
// sprite.angle++;
32+
// See: https://code.google.com/p/chromium/issues/detail?id=306851
33+
2934

3035
}
3136

src/core/Group.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,3 +1219,19 @@ Object.defineProperty(Phaser.Group.prototype, "visible", {
12191219
}
12201220

12211221
});
1222+
1223+
/**
1224+
* @name Phaser.Group#alpha
1225+
* @property {number} alpha - The alpha value of the Group container.
1226+
*/
1227+
Object.defineProperty(Phaser.Group.prototype, "alpha", {
1228+
1229+
get: function () {
1230+
return this._container.alpha;
1231+
},
1232+
1233+
set: function (value) {
1234+
this._container.alpha = value;
1235+
}
1236+
1237+
});

src/loader/Loader.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ Phaser.Loader.prototype = {
251251
this.addToFileList('image', key, url);
252252
}
253253

254+
return this;
255+
254256
},
255257

256258
/**
@@ -270,6 +272,8 @@ Phaser.Loader.prototype = {
270272
this.addToFileList('text', key, url);
271273
}
272274

275+
return this;
276+
273277
},
274278

275279
/**
@@ -291,6 +295,8 @@ Phaser.Loader.prototype = {
291295
this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax });
292296
}
293297

298+
return this;
299+
294300
},
295301

296302
/**
@@ -312,6 +318,8 @@ Phaser.Loader.prototype = {
312318
this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax });
313319
}
314320

321+
return this;
322+
315323
},
316324

317325
/**
@@ -331,6 +339,8 @@ Phaser.Loader.prototype = {
331339
this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode });
332340
}
333341

342+
return this;
343+
334344
},
335345

336346
/**
@@ -352,7 +362,8 @@ Phaser.Loader.prototype = {
352362
if (mapDataURL == null && mapData == null)
353363
{
354364
console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.');
355-
return;
365+
366+
return this;
356367
}
357368

358369
if (this.checkKeyExists(key) === false)
@@ -385,6 +396,8 @@ Phaser.Loader.prototype = {
385396
}
386397
}
387398

399+
return this;
400+
388401
},
389402

390403
/**
@@ -445,6 +458,8 @@ Phaser.Loader.prototype = {
445458
}
446459
}
447460

461+
return this;
462+
448463
},
449464

450465
/**
@@ -457,7 +472,7 @@ Phaser.Loader.prototype = {
457472
*/
458473
atlasJSONArray: function (key, textureURL, atlasURL, atlasData) {
459474

460-
this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY);
475+
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY);
461476

462477
},
463478

@@ -471,7 +486,7 @@ Phaser.Loader.prototype = {
471486
*/
472487
atlasJSONHash: function (key, textureURL, atlasURL, atlasData) {
473488

474-
this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
489+
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
475490

476491
},
477492

@@ -485,7 +500,7 @@ Phaser.Loader.prototype = {
485500
*/
486501
atlasXML: function (key, textureURL, atlasURL, atlasData) {
487502

488-
this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
503+
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
489504

490505
},
491506

@@ -568,6 +583,8 @@ Phaser.Loader.prototype = {
568583

569584
}
570585

586+
return this;
587+
571588
},
572589

573590
/**

0 commit comments

Comments
 (0)