Skip to content

Commit 4ecab8a

Browse files
committed
Merge branch 'renderer-updates' into multitexture-gl
2 parents 7350509 + 19342fa commit 4ecab8a

32 files changed

Lines changed: 210 additions & 169 deletions

File tree

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
315315
* Group.iterate has a new `returnType`: `RETURN_ALL`. This allows you to return all children that pass the iteration test in an array.
316316
* The property `checkCollision.none` in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by the `separate` method. By setting `checkCollision.none = true` you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme #2661)
317317
* Math.rotateToAngle takes two angles (in radians), and an interpolation value, and returns a new angle, based on the shortest rotational distance between the two.
318+
* Math.getShortestAngle will return the shortest angle between the two given angles. Angles are in the range -180 to 180, which is what `Sprite.angle` uses. So you can happily feed this method two sprite angles, and get the shortest angle back between them (#2494)
318319

319320
### Updates
320321

321-
* TypeScript definitions fixes and updates (thanks @calvindavis)
322+
* TypeScript definitions fixes and updates (thanks @calvindavis @AlvaroBarua)
322323
* Docs typo fixes (thanks @rroylance @Owumaro @boniatillo-com)
323324
* The InputHandler.flagged property has been removed. It was never used internally, or exposed via the API, so was just overhead.
324325
* The src/system folder has been removed and all files relocated to the src/utils folder. This doesn't change anything from an API point of view, but did change the grunt build scripts slightly.
@@ -330,14 +331,22 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
330331
* Phaser.Tileset has a new property `lastgid` which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset.
331332
* Stage will now check if `document.hidden` is available first, and if it is then never even check for the prefixed versions. This stops warnings like "mozHidden and mozVisibilityState are deprecated" in newer versions of browsers and retain backward compatibility (thanks @leopoldobrines7 #2656)
332333
* As a result of changes in #2573 Graphics objects were calling `updateLocalBounds` on any shape change, which could cause dramatic performances drops in Graphics heavy situations (#2618). Graphics objects now have a new flag `_boundsDirty` which is used to detect if the bounds have been invalidated, i.e. by a Graphics being cleared or drawn to. If this is set to true then `updateLocalBounds` is called once in the `postUpdate` method (thanks @pengchuan #2618)
333-
334+
* Phaser.Image now has the ScaleMinMax component.
335+
* Animations now allow for speeds greater than 0, rather than forcing them to be greater than 1. This allows you to have animation speeds slower than 1 frame per second (thanks @jayrobin #2664)
336+
* Weapon.fire and all related methods (fireAtXY, fireAtPointer, fireAtSprite) now all return the instance of the Phaser.Bullet that was fired, or `null` if nothing was fired. Previously it would return a boolean, but this change allows you to perform additional processing on the Bullet as required (thanks @JTronLabs #2696)
337+
* Sound.loopFull now returns the Sound instance that was looped (thanks @hilts-vaughan #2697)
338+
* ArcadePhysics Body.rotation now reads its initial value from sprite.angle instead of sprite.rotation. The property was immediately replaced with the correct value in Body.preUpdate regardless, but it keeps it consistent (thanks @samme #2708)
334339

335340
### Bug Fixes
336341

337342
* A Group with `inputEnableChildren` set would re-start the Input Handler on a Sprite, even if that handler had been disabled previously.
338343
* Weapon.autofire wouldn't fire after the first bullet, or until `fire` was called, neither of which are requirements. If you now set this boolean the Weapon will fire continuously until you toggle it back to false (thanks @alverLopez #2647)
339344
* ArcadePhysics.World.angleBetweenCenters now uses `centerX` and `centerY` properties to check for the angle between, instead of `center.x/y` as that property no longer exists (thanks @leopoldobrines7 #2654)
340345
* The Emitter.makeParticles `collide` argument didn't work, as a result of #2661, but is now properly respected thanks to that change (thanks @samme #2662)
346+
* Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing.
347+
* Text bounds would incorrectly displace if the Text resolution was greater than 1 (thanks @valent-novem #2685)
348+
* TilemapParser would calculate widthInPixels and heightInPixels were being read incorrectly from JSON data (capitalisation of properties) (thanks @hexus #2691)
349+
* A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688)
341350

342351
### Pixi Updates
343352

build/config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
<script src="$path/src/pixi/display/SpriteBatch.js"></script>
5555
5656
<script src="$path/src/pixi/utils/Utils.js"></script>
57-
<script src="$path/src/pixi/utils/PolyK.js"></script>
5857
<script src="$path/src/pixi/utils/EarCut.js"></script>
5958
<script src="$path/src/pixi/utils/CanvasPool.js"></script>
6059

resources/docstrap-master/template/tmpl/layout.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<li class="class-depth-1"><a href="Phaser.Mouse.html">Mouse</a></li>
129129
<li class="class-depth-1"><a href="Phaser.Keyboard.html">Keyboard</a></li>
130130
<li class="class-depth-1"><a href="Phaser.Key.html">Key</a></li>
131+
<li class="class-depth-1"><a href="Phaser.KeyCode.html">Key Codes</a></li>
131132
<li class="class-depth-1"><a href="Phaser.Gamepad.html">Gamepad</a></li>
132133
</ul>
133134
</li>

resources/tutorials/02 Making your first game/tutorial.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ <h3>Starshine</h3>
240240

241241
It's time to give our little game a purpose. Let's drop a sprinkling of stars into the scene and allow the player to collect them. To achieve this we'll create a new Group called 'stars' and populate it. In our create function we add the following code (this can be seen in part8.html):
242242

243-
<pre class="lang:js decode:true"> stars = game.add.group();
243+
<pre class="lang:js decode:true">
244+
// Finally some stars to collect
245+
stars = game.add.group();
246+
247+
// We will enable physics for any star that is created in this group
248+
stars.enableBody = true;
244249

245250
// Here we'll create 12 of them evenly spaced apart
246251
for (var i = 0; i &lt; 12; i++)

src/animation/Animation.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,29 +244,33 @@ Phaser.Animation.prototype = {
244244
},
245245

246246
/**
247-
* Reverses the animation direction
248-
*
249-
* @method Phaser.Animation#reverse
250-
* @return {Phaser.Animation} The animation instance.
251-
* */
247+
* Reverses the animation direction.
248+
*
249+
* @method Phaser.Animation#reverse
250+
* @return {Phaser.Animation} The animation instance.
251+
*/
252252
reverse: function () {
253+
253254
this.reversed = !this.reversed;
254255

255256
return this;
257+
256258
},
257259

258260
/**
259-
* Reverses the animation direction for the current/next animation only
260-
* Once the onComplete event is called this method will be called again and revert
261-
* the reversed state.
262-
*
263-
* @method Phaser.Animation#reverseOnce
264-
* @return {Phaser.Animation} The animation instance.
265-
* */
261+
* Reverses the animation direction for the current/next animation only
262+
* Once the onComplete event is called this method will be called again and revert
263+
* the reversed state.
264+
*
265+
* @method Phaser.Animation#reverseOnce
266+
* @return {Phaser.Animation} The animation instance.
267+
*/
266268
reverseOnce: function () {
267-
this.onComplete.addOnce(this.reverse.bind(this));
269+
270+
this.onComplete.addOnce(this.reverse, this);
268271

269272
return this.reverse();
273+
270274
},
271275

272276
/**
@@ -768,19 +772,19 @@ Object.defineProperty(Phaser.Animation.prototype, 'frame', {
768772

769773
/**
770774
* @name Phaser.Animation#speed
771-
* @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Minimum value is 1.
775+
* @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Value must be greater than 0.
772776
*/
773777
Object.defineProperty(Phaser.Animation.prototype, 'speed', {
774778

775779
get: function () {
776780

777-
return Math.round(1000 / this.delay);
781+
return 1000 / this.delay;
778782

779783
},
780784

781785
set: function (value) {
782786

783-
if (value >= 1)
787+
if (value > 0)
784788
{
785789
this.delay = 1000 / value;
786790
}

src/animation/AnimationManager.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ Phaser.AnimationManager.prototype = {
207207

208208
this.currentAnim = this._anims[name];
209209

210-
// This shouldn't be set until the Animation is played, surely?
211-
// this.currentFrame = this.currentAnim.currentFrame;
212-
213210
if (this.sprite.tilingTexture)
214211
{
215212
this.sprite.refreshTexture = true;

src/core/Group.js

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,25 +2711,20 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
27112711
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
27122712
* visible children.
27132713
*
2714-
* Note that no ancestors are factored into the result, meaning that if this Group is
2715-
* nested within another Group, with heavy transforms on it, the result of this property
2716-
* is likely to be incorrect. It is safe to get and set this property if the Group is a
2717-
* top-level descendant of Phaser.World, or untransformed parents.
2718-
*
27192714
* @name Phaser.Group#centerX
27202715
* @property {number} centerX
27212716
*/
27222717
Object.defineProperty(Phaser.Group.prototype, "centerX", {
27232718

27242719
get: function () {
27252720

2726-
return this.getBounds().centerX;
2721+
return this.getBounds(this.parent).centerX;
27272722

27282723
},
27292724

27302725
set: function (value) {
27312726

2732-
var r = this.getBounds();
2727+
var r = this.getBounds(this.parent);
27332728
var offset = this.x - r.x;
27342729

27352730
this.x = (value + offset) - r.halfWidth;
@@ -2744,25 +2739,20 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", {
27442739
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
27452740
* visible children.
27462741
*
2747-
* Note that no ancestors are factored into the result, meaning that if this Group is
2748-
* nested within another Group, with heavy transforms on it, the result of this property
2749-
* is likely to be incorrect. It is safe to get and set this property if the Group is a
2750-
* top-level descendant of Phaser.World, or untransformed parents.
2751-
*
27522742
* @name Phaser.Group#centerY
27532743
* @property {number} centerY
27542744
*/
27552745
Object.defineProperty(Phaser.Group.prototype, "centerY", {
27562746

27572747
get: function () {
27582748

2759-
return this.getBounds().centerY;
2749+
return this.getBounds(this.parent).centerY;
27602750

27612751
},
27622752

27632753
set: function (value) {
27642754

2765-
var r = this.getBounds();
2755+
var r = this.getBounds(this.parent);
27662756
var offset = this.y - r.y;
27672757

27682758
this.y = (value + offset) - r.halfHeight;
@@ -2777,25 +2767,20 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", {
27772767
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
27782768
* visible children.
27792769
*
2780-
* Note that no ancestors are factored into the result, meaning that if this Group is
2781-
* nested within another Group, with heavy transforms on it, the result of this property
2782-
* is likely to be incorrect. It is safe to get and set this property if the Group is a
2783-
* top-level descendant of Phaser.World, or untransformed parents.
2784-
*
27852770
* @name Phaser.Group#left
27862771
* @property {number} left
27872772
*/
27882773
Object.defineProperty(Phaser.Group.prototype, "left", {
27892774

27902775
get: function () {
27912776

2792-
return this.getBounds().left;
2777+
return this.getBounds(this.parent).left;
27932778

27942779
},
27952780

27962781
set: function (value) {
27972782

2798-
var r = this.getBounds();
2783+
var r = this.getBounds(this.parent);
27992784
var offset = this.x - r.x;
28002785

28012786
this.x = value + offset;
@@ -2809,11 +2794,6 @@ Object.defineProperty(Phaser.Group.prototype, "left", {
28092794
*
28102795
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
28112796
* visible children.
2812-
*
2813-
* Note that no ancestors are factored into the result, meaning that if this Group is
2814-
* nested within another Group, with heavy transforms on it, the result of this property
2815-
* is likely to be incorrect. It is safe to get and set this property if the Group is a
2816-
* top-level descendant of Phaser.World, or untransformed parents.
28172797
*
28182798
* @name Phaser.Group#right
28192799
* @property {number} right
@@ -2822,13 +2802,13 @@ Object.defineProperty(Phaser.Group.prototype, "right", {
28222802

28232803
get: function () {
28242804

2825-
return this.getBounds().right;
2805+
return this.getBounds(this.parent).right;
28262806

28272807
},
28282808

28292809
set: function (value) {
28302810

2831-
var r = this.getBounds();
2811+
var r = this.getBounds(this.parent);
28322812
var offset = this.x - r.x;
28332813

28342814
this.x = (value + offset) - r.width;
@@ -2842,11 +2822,6 @@ Object.defineProperty(Phaser.Group.prototype, "right", {
28422822
*
28432823
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
28442824
* visible children.
2845-
*
2846-
* Note that no ancestors are factored into the result, meaning that if this Group is
2847-
* nested within another Group, with heavy transforms on it, the result of this property
2848-
* is likely to be incorrect. It is safe to get and set this property if the Group is a
2849-
* top-level descendant of Phaser.World, or untransformed parents.
28502825
*
28512826
* @name Phaser.Group#top
28522827
* @property {number} top
@@ -2855,13 +2830,13 @@ Object.defineProperty(Phaser.Group.prototype, "top", {
28552830

28562831
get: function () {
28572832

2858-
return this.getBounds().top;
2833+
return this.getBounds(this.parent).top;
28592834

28602835
},
28612836

28622837
set: function (value) {
28632838

2864-
var r = this.getBounds();
2839+
var r = this.getBounds(this.parent);
28652840
var offset = this.y - r.y;
28662841

28672842
this.y = (value + offset);
@@ -2876,25 +2851,20 @@ Object.defineProperty(Phaser.Group.prototype, "top", {
28762851
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
28772852
* visible children.
28782853
*
2879-
* Note that no ancestors are factored into the result, meaning that if this Group is
2880-
* nested within another Group, with heavy transforms on it, the result of this property
2881-
* is likely to be incorrect. It is safe to get and set this property if the Group is a
2882-
* top-level descendant of Phaser.World, or untransformed parents.
2883-
*
28842854
* @name Phaser.Group#bottom
28852855
* @property {number} bottom
28862856
*/
28872857
Object.defineProperty(Phaser.Group.prototype, "bottom", {
28882858

28892859
get: function () {
28902860

2891-
return this.getBounds().bottom;
2861+
return this.getBounds(this.parent).bottom;
28922862

28932863
},
28942864

28952865
set: function (value) {
28962866

2897-
var r = this.getBounds();
2867+
var r = this.getBounds(this.parent);
28982868
var offset = this.y - r.y;
28992869

29002870
this.y = (value + offset) - r.height;

src/gameobjects/Button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
173173
this.onOverMouseOnly = true;
174174

175175
/**
176-
* Suppresse the over event if a pointer was just released and it matches the given {@link Phaser.PointerModer pointer mode bitmask}.
176+
* Suppress the over event if a pointer was just released and it matches the given {@link Phaser.PointerModer pointer mode bitmask}.
177177
*
178178
* This behavior was introduced in Phaser 2.3.1; this property is a soft-revert of the change.
179179
*

src/gameobjects/Image.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @extends Phaser.Component.LoadTexture
2525
* @extends Phaser.Component.Overlap
2626
* @extends Phaser.Component.Reset
27+
* @extends Phaser.Component.ScaleMinMax
2728
* @extends Phaser.Component.Smoothed
2829
* @constructor
2930
* @param {Phaser.Game} game - A reference to the currently running game.
@@ -68,6 +69,7 @@ Phaser.Component.Core.install.call(Phaser.Image.prototype, [
6869
'LoadTexture',
6970
'Overlap',
7071
'Reset',
72+
'ScaleMinMax',
7173
'Smoothed'
7274
]);
7375

src/gameobjects/Text.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,20 +1442,20 @@ Phaser.Text.prototype.updateTexture = function () {
14421442
// Align the canvas based on the bounds
14431443
if (this.style.boundsAlignH === 'right')
14441444
{
1445-
x += this.textBounds.width - this.canvas.width;
1445+
x += this.textBounds.width - this.canvas.width / this.resolution;
14461446
}
14471447
else if (this.style.boundsAlignH === 'center')
14481448
{
1449-
x += this.textBounds.halfWidth - (this.canvas.width / 2);
1449+
x += this.textBounds.halfWidth - (this.canvas.width / this.resolution / 2);
14501450
}
14511451

14521452
if (this.style.boundsAlignV === 'bottom')
14531453
{
1454-
y += this.textBounds.height - this.canvas.height;
1454+
y += this.textBounds.height - this.canvas.height / this.resolution;
14551455
}
14561456
else if (this.style.boundsAlignV === 'middle')
14571457
{
1458-
y += this.textBounds.halfHeight - (this.canvas.height / 2);
1458+
y += this.textBounds.halfHeight - (this.canvas.height / this.resolution / 2);
14591459
}
14601460

14611461
this.pivot.x = -x;

0 commit comments

Comments
 (0)