Skip to content

Commit ca07b98

Browse files
committed
Merge branch 'renderer-updates' into texture-compression-webgl
2 parents b84e6ef + 19342fa commit ca07b98

16 files changed

Lines changed: 94 additions & 76 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
319319

320320
### Updates
321321

322-
* TypeScript definitions fixes and updates (thanks @calvindavis)
322+
* TypeScript definitions fixes and updates (thanks @calvindavis @AlvaroBarua)
323323
* Docs typo fixes (thanks @rroylance @Owumaro @boniatillo-com)
324324
* The InputHandler.flagged property has been removed. It was never used internally, or exposed via the API, so was just overhead.
325325
* 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.
@@ -332,6 +332,10 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
332332
* 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)
333333
* 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)
334334
* 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)
335339

336340
### Bug Fixes
337341

@@ -340,6 +344,9 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
340344
* 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)
341345
* 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)
342346
* 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)
343350

344351
### Pixi Updates
345352

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/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/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;

src/gameobjects/components/Crop.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Phaser.Component.Crop.prototype = {
4646
* @param {Phaser.Rectangle} rect - The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle.
4747
* @param {boolean} [copy=false] - If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect.
4848
*/
49-
crop: function(rect, copy) {
49+
crop: function (rect, copy) {
5050

5151
if (copy === undefined) { copy = false; }
5252

@@ -83,13 +83,18 @@ Phaser.Component.Crop.prototype = {
8383
*
8484
* @method
8585
*/
86-
updateCrop: function() {
86+
updateCrop: function () {
8787

8888
if (!this.cropRect)
8989
{
9090
return;
9191
}
9292

93+
var oldX = this.texture.crop.x;
94+
var oldY = this.texture.crop.y;
95+
var oldW = this.texture.crop.width;
96+
var oldH = this.texture.crop.height;
97+
9398
this._crop = Phaser.Rectangle.clone(this.cropRect, this._crop);
9499
this._crop.x += this._frame.x;
95100
this._crop.y += this._frame.y;
@@ -112,6 +117,11 @@ Phaser.Component.Crop.prototype = {
112117

113118
this.texture._updateUvs();
114119

120+
if (this.tint !== 0xffffff && (oldX !== cx || oldY !== cy || oldW !== cw || oldH !== ch))
121+
{
122+
this.texture.requiresReTint = true;
123+
}
124+
115125
}
116126

117127
};

src/input/Keyboard.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ Phaser.Keyboard.prototype.constructor = Phaser.Keyboard;
604604
* _Note_: Use `Phaser.KeyCode.KEY` instead of `Phaser.Keyboard.KEY` to refer to a key code;
605605
* the latter approach is supported for compatibility.
606606
*
607-
* @namespace
607+
* @class Phaser.KeyCode
608608
*/
609609
Phaser.KeyCode = {
610610
/** @static */
@@ -814,8 +814,10 @@ Phaser.KeyCode = {
814814
};
815815

816816
// Duplicate Phaser.KeyCode values in Phaser.Keyboard for compatibility
817-
for (var key in Phaser.KeyCode) {
818-
if (Phaser.KeyCode.hasOwnProperty(key) && !key.match(/[a-z]/)) {
817+
for (var key in Phaser.KeyCode)
818+
{
819+
if (Phaser.KeyCode.hasOwnProperty(key) && !key.match(/[a-z]/))
820+
{
819821
Phaser.Keyboard[key] = Phaser.KeyCode[key];
820822
}
821823
}

src/physics/arcade/Body.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ Phaser.Physics.Arcade.Body = function (sprite) {
8282
* itself never rotates, it is always axis-aligned. However these values are passed up to the parent Sprite and updates its rotation.
8383
* @property {number} rotation
8484
*/
85-
this.rotation = sprite.rotation;
85+
this.rotation = sprite.angle;
8686

8787
/**
8888
* @property {number} preRotation - The previous rotation of the physics body.
8989
* @readonly
9090
*/
91-
this.preRotation = sprite.rotation;
91+
this.preRotation = sprite.angle;
9292

9393
/**
9494
* @property {number} width - The calculated width of the physics body.

0 commit comments

Comments
 (0)