Phaser 3.4.0 was just released today. The popular HTML5 game framework has been improving rapidly since the 3.x branch was released earlier this year. This release includes beta support for the new Game Object Container class, an updated animation API, and much more. Additionally there were a ton of bug fixes and improvements. If you are interested in learning more about Phaser 3, be sure to check out our getting started video, which is also embedded below.
New features in this release:
- 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.
- 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.
- Matter Physics has two new methods:
set30Hz which will set an Engine update rate of 60Hz and 30Hz respectively. 60Hz being the default.
- 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
- 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.
- Matter Physics has two new debug properties:
debugJointColor. If defined they will display joints in Matter bodies during the postUpdate debug phase (only if debug is enabled) (thanks @OmarShehata)
- 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)
- WebAudioSound.setMute is a chainable way to mute a single Sound instance.
- WebAudioSound.setVolume is a chainable way to set the volume of a single Sound instance.
- WebAudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
- WebAudioSound.setLoop is a chainable way to set the loop state of a single Sound instance.
- HTML5AudioSound.setMute is a chainable way to mute a single Sound instance.
- HTML5AudioSound.setVolume is a chainable way to set the volume of a single Sound instance.
- HTML5AudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
- HTML5AudioSound.setLoop is a chainable way to set the loop state of a single Sound instance.
- BitmapText has a new property
letterSpacing which accepts a positive or negative number to add / reduce spacing between characters (thanks @wtravO)
- 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)
- Graphics.slice allows you to easily draw a Pacman, or slice of pie shape to a Graphics object.
- 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.
- 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.
- 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.
- Utils.Array.Add allows you to add one or more items safely to an array, with optional limits and callbacks.
- Utils.Array.AddAt allows you to add one or more items safely to an array at a specified position, with optional limits and callbacks.
- Utils.Array.BringToTop allows you to bring an array element to the top of the array.
- Utils.Array.CountAllMatching will scan an array and count all elements with properties matching the given value.
- Utils.Array.Each will pass each element of an array to a given callback, with optional arguments.
- Utils.Array.EachInRange will pass each element of an array in a given range to a callback, with optional arguments.
- Utils.Array.GetAll will return all elements from an array, with optional property and value comparisons.
- Utils.Array.GetFirst will return the first element in an array, with optional property and value comparisons.
- Utils.Array.GetRandomElement has been renamed to GetRandom and will return a random element from an array.
- Utils.Array.MoveDown will move the given array element down one position in the array.
- Utils.Array.MoveTo will move the given array element to the given position in the array.
- Utils.Array.MoveUp will move the given array element up one position in the array.
- Utils.Array.Remove will remove the given element or array of elements from the array, with an optional callback.
- Utils.Array.RemoveAt will remove the element from the given position in the array, with an optional callback.
- Utils.Array.RemoveBetween will remove the elements between the given range in the array, with an optional callback.
- Utils.Array.Replace will replace an existing element in an array with a new one.
- Utils.Array.SendToBack allows you to send an array element to the bottom of the array.
- Utils.Array.SetAll will set a property on all elements of an array to the given value, with optional range limits.
- Utils.Array.Swap will swap the position of two elements in an array.
- TransformMatrix.destroy is a new method that will clear out the array and object used by a Matrix internally.
- BaseSound, and by extension WebAudioSound and HTMLAudioSound, will now emit a
destroy event when they are destroyed (thanks @rexrainbow)
- 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)
getBottomRight all have a new optional argument
includeParent which will factor in all ancestor transforms to the returned point.
Getting Started with Phaser 3