Skip to content

Commit f425cfb

Browse files
authored
Merge branch 'master' into scene-config-for-add-map
2 parents 5d1405c + fd3d408 commit f425cfb

35 files changed

Lines changed: 2060 additions & 442 deletions

CHANGELOG.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
### New Features
66

7-
* A new property was added to the scene config, `mapAdd` which is used to extend the default injection map of a scene instead of overwriting it.
8-
* A new property was added to Matter.World, `correction` which is used in the Engine.update call and allows you to adjust the time
9-
being passed to the simulation. The default value is 1 to remain consistent with previous releases.
10-
* Group.destroy has a new optional argument `destroyChildren` which will automatically call `destroy` on all children of a Group if set to true (the default is false, hence it doesn't change the public API). Fix #3246 (thanks @DouglasLapsley)
7+
* A new property was added to Matter.World, `correction` which is used in the Engine.update call and allows you to adjust the time being passed to the simulation. The default value is 1 to remain consistent with previous releases.
118
* Matter Physics now has a new config property `getDelta` which allows you to specify your own function to calculate the delta value given to the Matter Engine when it updates.
129
* Matter Physics has two new methods: `set60Hz` and `set30Hz` which will set an Engine update rate of 60Hz and 30Hz respectively. 60Hz being the default.
1310
* Matter Physics has a new config and run-time property `autoUpdate`, which defaults to `true`. When enabled the Matter Engine will update in sync with the game step (set by Request Animation Frame). The delta value given to Matter is now controlled by the `getDelta` function.
1411
* Matter Physics has a new method `step` which manually advances the physics simulation by one iteration, using whatever delta and correction values you pass in to it. When used in combination with `autoUpdate=false` you can now explicitly control the update frequency of the physics simulation and unbind it from the game step.
12+
* Matter Physics has two new debug properties: `debugShowJoint` and `debugJointColor`. If defined they will display joints in Matter bodies during the postUpdate debug phase (only if debug is enabled) (thanks @OmarShehata)
13+
* Group.destroy has a new optional argument `destroyChildren` which will automatically call `destroy` on all children of a Group if set to true (the default is false, hence it doesn't change the public API). Fix #3246 (thanks @DouglasLapsley)
1514
* WebAudioSound.setMute is a chainable way to mute a single Sound instance.
1615
* WebAudioSound.setVolume is a chainable way to set the volume of a single Sound instance.
1716
* WebAudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
@@ -21,12 +20,33 @@ being passed to the simulation. The default value is 1 to remain consistent with
2120
* HTML5AudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
2221
* HTML5AudioSound.setLoop is a chainable way to set the loop state of a single Sound instance.
2322
* BitmapText has a new property `letterSpacing` which accepts a positive or negative number to add / reduce spacing between characters (thanks @wtravO)
24-
* Matter Physics has two new debug properties: `debugShowJoint` and `debugJointColor`. If defined they will display joints in Matter bodies during the postUpdate debug phase (only if debug is enabled) (thanks @OmarShehata)
2523
* You can now pass a Sprite Sheet or Canvas as the Texture key to `Tilemap.addTileset` and it will work in WebGL, where-as before it would display a corrupted tilemap. Fix #3407 (thanks @Zykino)
2624
* Graphics.slice allows you to easily draw a Pacman, or slice of pie shape to a Graphics object.
2725
* List.addCallback is a new optional callback that is invoked every time a new child is added to the List. You can use this to have a callback fire when children are added to the Display List.
2826
* List.removeCallback is a new optional callback that is invoked every time a new child is removed from the List. You can use this to have a callback fire when children are removed from the Display List.
2927
* ScenePlugin.restart allows you to restart the current Scene. It's the same result as calling `ScenePlugin.start` without any arguments, but is more clear.
28+
* Utils.Array.Add allows you to add one or more items safely to an array, with optional limits and callbacks.
29+
* Utils.Array.AddAt allows you to add one or more items safely to an array at a specified position, with optional limits and callbacks.
30+
* Utils.Array.BringToTop allows you to bring an array element to the top of the array.
31+
* Utils.Array.CountAllMatching will scan an array and count all elements with properties matching the given value.
32+
* Utils.Array.Each will pass each element of an array to a given callback, with optional arguments.
33+
* Utils.Array.EachInRange will pass each element of an array in a given range to a callback, with optional arguments.
34+
* Utils.Array.GetAll will return all elements from an array, with optional property and value comparisons.
35+
* Utils.Array.GetFirst will return the first element in an array, with optional property and value comparisons.
36+
* Utils.Array.GetRandomElement has been renamed to GetRandom and will return a random element from an array.
37+
* Utils.Array.MoveDown will move the given array element down one position in the array.
38+
* Utils.Array.MoveTo will move the given array element to the given position in the array.
39+
* Utils.Array.MoveUp will move the given array element up one position in the array.
40+
* Utils.Array.Remove will remove the given element or array of elements from the array, with an optional callback.
41+
* Utils.Array.RemoveAt will remove the element from the given position in the array, with an optional callback.
42+
* Utils.Array.RemoveBetween will remove the elements between the given range in the array, with an optional callback.
43+
* Utils.Array.Replace will replace an existing element in an array with a new one.
44+
* Utils.Array.SendToBack allows you to send an array element to the bottom of the array.
45+
* Utils.Array.SetAll will set a property on all elements of an array to the given value, with optional range limits.
46+
* Utils.Array.Swap will swap the position of two elements in an array.
47+
* TransformMatrix.destroy is a new method that will clear out the array and object used by a Matrix internally.
48+
* BaseSound, and by extension WebAudioSound and HTMLAudioSound, will now emit a `destroy` event when they are destroyed (thanks @rexrainbow)
49+
* A new property was added to the Scene config: `mapAdd` which is used to extend the default injection map of a scene instead of overwriting it (thanks @sebashwa)
3050

3151
### Bug Fixes
3252

@@ -51,10 +71,12 @@ being passed to the simulation. The default value is 1 to remain consistent with
5171
* Tween.restart handles removed tweens properly and reads them back into the active queue for the TweenManager (thanks @wtravO)
5272
* Tween.resume will now call `Tween.play` on a tween that was paused due to its config object, not as a result of having its paused method called. Fix #3452 (thanks @jazen)
5373
* LoaderPlugin.isReady referenced a constant that no longer exists. Fix #3503 (thanks @Twilrom)
74+
* Tween Timeline.destroy was trying to call `destroy` on Tweens instead of `stop` (thanks @Antriel)
75+
* Calling `setOffset` on a Static Arcade Physics Body would break because the method was missing. It has been added and now functions as expected. Fix #3465 (thanks @josephjaniga and @DouglasLapsley)
5476

5577
### Updates
5678

57-
* The RTree library (rbush) used by Phaser 3 suffered from violating CSP policies by dynamically creating Functions at run-time in an eval-like manner. These are now defined via generators. Fix #3441 (thanks @jamierocks @Colbydude)
79+
* The RTree library (rbush) used by Phaser 3 suffered from violating CSP policies by dynamically creating Functions at run-time in an eval-like manner. These are now defined via generators. Fix #3441 (thanks @jamierocks @Colbydude @jdotrjs)
5880
* BaseSound has had its `rate` and `detune` properties removed as they are always set in the overriding class.
5981
* BaseSound `setRate` and `setDetune` from the 3.3.0 release have moved to the WebAudioSound and HTML5AudioSound classes respectively, as they each handle the values differently.
6082
* The file `InteractiveObject.js` has been renamed to `CreateInteractiveObject.js` to more accurately reflect what it does and to avoid type errors in the docs.
@@ -77,6 +99,11 @@ being passed to the simulation. The default value is 1 to remain consistent with
7799
* SceneManager._processing has been renamed to `isProcessing` which is now a boolean, not an integer. It's also now public and read-only.
78100
* SceneManager.isBooted is a new boolean read-only property that lets you know if the Scene Manager has performed its initial boot sequence.
79101
* TransformMatrix has the following new getter and setters: `a`, `b`, `c`, `d`, `tx` and `ty`. It also has the following new getters: `scaleX`, `scaleY` and `rotation`.
102+
* List.getByKey has been removed. Use `List.getFirst` instead which offers the exact same functionality.
103+
* List.sortIndexHandler has been removed because it's no longer required.
104+
* List.sort no longer takes an array as its argument, instead it only sorts the List contents by the defined property.
105+
* List.addMultiple has been removed. Used `List.add` instead which offers the exact same functionality.
106+
* List is now internally using all of the new Utils.Array functions.
80107

81108
### Animation System Updates
82109

src/gameobjects/GameObject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ var GameObject = new Class({
375375

376376
this.scene = undefined;
377377

378+
this.parentContainer = undefined;
379+
378380
this.removeAllListeners();
379381
}
380382

src/gameobjects/components/Animation.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ var Class = require('../../utils/Class');
88

99
/**
1010
* This event is dispatched when an animation starts playing.
11-
*
11+
*
1212
* @event Phaser.GameObjects.Components.Animation#onStartEvent
1313
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
1414
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
1515
*/
1616

1717
/**
1818
* This event is dispatched when an animation repeats.
19-
*
19+
*
2020
* @event Phaser.GameObjects.Components.Animation#onRepeatEvent
2121
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
2222
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
@@ -26,15 +26,15 @@ var Class = require('../../utils/Class');
2626
/**
2727
* This event is dispatched when an animation updates. This happens when the animation frame changes,
2828
* based on the animation frame rate and other factors like timeScale and delay.
29-
*
29+
*
3030
* @event Phaser.GameObjects.Components.Animation#onUpdateEvent
3131
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
3232
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
3333
*/
3434

3535
/**
3636
* This event is dispatched when an animation completes playing, either naturally or via Animation.stop.
37-
*
37+
*
3838
* @event Phaser.GameObjects.Components.Animation#onCompleteEvent
3939
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
4040
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
@@ -281,7 +281,7 @@ var Animation = new Class({
281281

282282
/**
283283
* Internal property tracking if this Animation is waiting to stop.
284-
*
284+
*
285285
* 0 = No
286286
* 1 = Waiting for ms to pass
287287
* 2 = Waiting for repeat
@@ -625,7 +625,7 @@ var Animation = new Class({
625625

626626
/**
627627
* Gets the amount of delay between repeats, if any.
628-
*
628+
*
629629
* @method Phaser.GameObjects.Components.Animation#getRepeatDelay
630630
* @since 3.4.0
631631
*
@@ -700,7 +700,7 @@ var Animation = new Class({
700700

701701
var gameObject = this.parent;
702702

703-
gameObject.emit('animtioncomplete', this.currentAnim, this.currentFrame);
703+
gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame);
704704

705705
return gameObject;
706706
},
@@ -830,7 +830,7 @@ var Animation = new Class({
830830
return this.currentAnim.completeAnimation(this);
831831
}
832832
}
833-
833+
834834
if (this.accumulator >= this.nextTick)
835835
{
836836
this.currentAnim.setFrame(this);

src/gameobjects/components/TransformMatrix.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,18 @@ var TransformMatrix = new Class({
317317
{
318318
var radianSin = Math.sin(radian);
319319
var radianCos = Math.cos(radian);
320+
var matrix = this.matrix;
321+
var a = matrix[0];
322+
var b = matrix[1];
323+
var c = matrix[2];
324+
var d = matrix[3];
325+
326+
matrix[0] = a * radianCos + c * radianSin;
327+
matrix[1] = b * radianCos + d * radianSin;
328+
matrix[2] = a * -radianSin + c * radianCos;
329+
matrix[3] = b * -radianSin + d * radianCos;
320330

321-
return this.transform(radianCos, radianSin, -radianSin, radianCos, 0, 0);
331+
return this;
322332
},
323333

324334
/**
@@ -548,20 +558,32 @@ var TransformMatrix = new Class({
548558
{
549559
var matrix = this.matrix;
550560

551-
var sr = Math.sin(rotation);
552-
var cr = Math.cos(rotation);
561+
var radianSin = Math.sin(rotation);
562+
var radianCos = Math.cos(rotation);
553563

554564
// Translate
555565
matrix[4] = x;
556566
matrix[5] = y;
557567

558568
// Rotate and Scale
559-
matrix[0] = cr * scaleX;
560-
matrix[1] = -sr * scaleX;
561-
matrix[2] = sr * scaleY;
562-
matrix[3] = cr * scaleY;
569+
matrix[0] = radianCos * scaleX;
570+
matrix[1] = radianSin * scaleX;
571+
matrix[2] = -radianSin * scaleY;
572+
matrix[3] = radianCos * scaleY;
563573

564574
return this;
575+
},
576+
577+
/**
578+
* Destroys this Transform Matrix.
579+
*
580+
* @method Phaser.GameObjects.Components.TransformMatrix#destroy
581+
* @since 3.4.0
582+
*/
583+
destroy: function ()
584+
{
585+
this.matrix = null;
586+
this.decomposedMatrix = null;
565587
}
566588

567589
});

0 commit comments

Comments
 (0)