Releases: phaserjs/phaser
Phaser v4.0.0 Beta 1
This is the first beta release of Phaser v4.0.0. This build includes the brand new Phaser Beam renderer, that powers all of the WebGL rendering internally. We will be publishing more details about this in the coming days, but for now, you can drop in this build as a direct v3.80+ replacement and see how your game runs! Check out the README for more internal changes.
Phaser v3.87
New Features
FontFile
is a new File Type loader that allows you to load TTF/OTF fonts directly into Phaser, without the need for a 3rd party web font loader or CSS hacks. The loaded fonts can be used in the Text Game Objects, such as the example below:
preload ()
{
this.load.font('Caroni', 'assets/fonts/ttf/caroni.otf', 'opentype');
this.load.font('troika', 'assets/fonts/ttf/troika.otf', 'opentype');
}
create ()
{
this.add.text(32, 32, 'The face of the moon was in shadow.', { fontFamily: 'troika', fontSize: 80, color: '#ff0000' });
this.add.text(150, 350, 'Waves flung themselves at the blue evening.', { fontFamily: 'Caroni', fontSize: 64, color: '#5656ee' });
}
Updates
- The Particle Animation State is now optional. A Particle will not create an Animation State controller unless the
anim
property exists within the emitter configuration. By not creating the controller it leads to less memory overhead and a much faster clean-up time when destroying particles. Fix #6482 (thanks @samme) - Optimized
TweenData.update
to achieve the same result with my less repetition. Also fixes an issue where a Tween that used a customease
callback would glitch when the final value was set, as it would be set outside of the ease callback. It's now passed through it, no matter what. Fix #6939 (thanks @SBCGames)
Bug Fixes
- Fixed the calculation of the index in
GetBitmapTextSize
that would lead to incorrect indexes vs. the docs and previous releases (thanks @bagyoni) Utils.String.RemoveAt
would incorrectly calculate the slice index if it was > 0. It will now remove the correctly specified character.
Examples, Documentation, Beta Testing and TypeScript
Thanks to the following for helping with the Phaser Examples, Beta Testing, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:
Phaser v3.86.0
Updates
RenderTarget.init
is a new method that will create the underlying framebuffer and texture for a Render Target. This is called in the constructor only, avoiding the need to call theresize
method.Phaser.GameObjects.Container#tempTransformMatrix
has been removed. This was an internal private Transform Matrix. It has been replaced by a global single matrix that is used instead. This removes the need for every Container to have its own instance of this temporary matrix, reducing object allocation and memory overhead.BaseCamera.renderRoundPixels
is a new read-only property that is set during the CamerapreRender
method every frame. It is true if the Camera is set to render round pixels and the zoom values are integers, otherwise it is false. This is then fed into the MultiPipeline when rendering sprites and textures.
Bug Fixes
- The Canvas Renderer and WebGL Multi Pipeline now uses the new
renderRoundPixels
boolean to determine if it can render a Sprite or a Texture with rounded position values, or not. This fixes an issue where black lines would appear between tightly grouped sprites or tiles at non-integer Camera zoom values. Fix #6907 (thanks @MarcJamesIO) RenderTarget.resize
will now check theautoResize
property before applying the change. Textures that have been locked to a fixed size, such as FX POT buffers, will no longer be resized to the full canvas dimensions, causing Out of Memory errors on some mobile devices. Fix #6914 (thanks @mikaleerhart @DavidTalevski)- The
Array.MoveAbove
function didn't recalculate the baseIndex after the splice, meaning the item would end up in the wrong location. - The
HexagonalTileToWorldXY
function incorrectly usedthis
instead oflayer
causing it to error in hex tilemaps with x axis staggering. Fix #6913 (thanks @jummy123) - The
Text
Game Object could truncate the length of the Text whensetLetterSpacing
was used. Fix #6915 (thanks @monteiz @rexrainbow) - The
EXPAND
Scale Mode would cause the error "Framebuffer status: Incomplete Attachment" under WebGL if the Phaser game loaded into an iframe or element with a size of 0 on either axis, such as when you load the game into a 0x0 iframe before expanding it. It now protects against divide by zero errors. - The
RenderTarget.willResize
method will now check if the values given to it are actually numbers. If not it will return false.
Examples, Documentation, Beta Testing and TypeScript
Thanks to the following for helping with the Phaser Examples, Beta Testing, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:
Phaser v3.85.2
Updates
WebGLRenderer.setExtensions
is a new method that queries the GL context to get the list of supported extensions. Which it then sets into the class properties. This method is called internally as part of theinit
and restore process.
Bug Fixes
- When the WebGL context was restored it would incorrectly try to call
init.setupExtensions()
which didn't exist. It now calls the correct method,WebGLRenderer.setExtensions
. Fix #6905 (thanks @RedRoosterMobile) TransformMatrix.setQuad
has been fixed so it no longer rounds the quad dimensions, only the x/y coordinates. This fixes a bug where it could give slightly different (+- 1px) sized textures based on how the dimensions were rounded when usingroundPixels
on the camera. Fix #6874 (thanks @saintflow47)
Examples, Documentation, Beta Testing and TypeScript
Thanks to the following for helping with the Phaser Examples, Beta Testing, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:
Phaser v3.85.1
Version 3.85.1 - Itsuki - 5th September 2024
MatterJS
- MatterJS has been updated to version 0.20.0 - Here are all the details about this update.
- A new
wrap
method has been natively integrated into theBody
class to replace the existingMatterWrap
plugin. Here's how it works. - The Matter
attractors
plugin has been natively integrated into theBody
class and Matter engine. More details here. - Integrated
MatterCollisionEvents
plugin functionality directly into theMatter.World
class to handle collisions more effectively. More details here. - Updated
Matter.World
to improve the performance, accuracy, and reliability of theupdate
method in handling physics simulations or animations. More details here. - Fixed
Matter.World
bug wheregroup.length
returnsundefined
. Changed togroup.getLength()
to correctly return number of children in a group. - Calling
Matter.World.pause
would stop the world updating, but the RunnertimeLastTick
wasn't reset whenresume
was called, causing all the bodies to advance. The time is now reset correctly. Fix #6892 (thanks @philipgriffin)
Round Pixels
Includes a Potentially Breaking Change
The way roundPixels
has been handled in this release has been changed significantly. In previous versions we passed a uniform to the shaders and handled the pixel rounding on the GPU. However, this caused issues with our batching flow - for example, a Sprite would need to be rounded, but a Text or Shape object would not. This lead to complications in some parts of the render code.
In this release we have removed the shader uniform and branching and also made roundPixels
default to false
in the Game Config. Previously, it was true
, so you may need to switch this flag if you were relying on it. Here are the results of this change:
- The Game Config
roundPixels
property now defaults tofalse
. - The
uRoundPixels
uniform has been removed from the Single, Multi and Mobile vertex shaders. - Setting the
uRoundPixels
uniform has been removed from the Single, Rope, PreFX, PostFX, Multi and Mobile WebGL Pipelines. - The Multi Pipeline and Blitter WebGL Renderer will now pass the
camera.roundPixels
value to the Transform MatrixsetQuad
method. - The Multi Pipeline
batchSprite
andbatchTexture
methods will now applyMath.floor
to the sprite matrix calculations if camera round pixels is enabled. BaseCamera.preRender
has been removed. This method was completely overridden byCamera.preRender
which is the method that contained the correct rendering logic. As the Base Camera variant was not used internally outside of Dynamic Textures, we have removed it to save space.Camera.preRender
has been updated to use both zoomX and zoomY for the matrix transform.Camera.preRender
has been updated to apply Math.floor to the scroll factor when rounding is enabled on the Camera. This fixes an issue where following sprites with Camera lerp, or heavy zoom factors, would cause 'stuttering' at sub-pixel values.
New Features - Loader
The Loader now has a new feature called maxRetries
. This specifies the number of times a single File will retry loading itself should it error for whatever reason, such as poor network connectivity. The default value is 2. You can change this in the Game Config, on the LoaderPlugin instance, on the FileConfig or on the File level itself. Thanks to @pavle-goloskokovic for the suggestion.
loader.maxRetries
is a new Game Config option to set the number of retries a file will attempt to load. The default is 2.LoaderPlugin.maxRetries
is a new property that holds the number of times to retry loading a single file before it fails. This property is set via the Game Config, but can also be adjusted manually. Changing it doesn't not impact files already in the load queue, only those added later.FileConfig.maxRetries
is a new File Config option to set the number of retries a file will attempt to load. If not specified in the config, the value is read from theLoaderPlugin.maxRetries
property.Loader.File.retryAttempts
is the internal property holding the counter for the number of times to retry loading this file before it fails. This value is decreased after each attempt. When it reaches zero, the file is considered as failed.
New Features
BaseSoundManager.isPlaying
is a new method that will return a boolean if the given sound key is playing. If you don't provide a key, it will return a boolean if any sound is playing (thanks @samme)WebGLRenderer.dispatchContextLost
is a new internal method that is called when the WebGL context is lost. By default this is bound to the propertyWebGLRenderer.contextLostHandler
. If you override the context loss handler, be sure to invoke this method in due course.WebGLRenderer.dispatchContextRestore
is a new internal method that is called when the WebGL context is restored. By default this is bound to the propertyWebGLRenderer.contextRestoreHandler
. If you override the context restore handler, be sure to invoke this method in due course.WebGLRenderer.setContextHandlers
is a new internal method with 2 optional parameters:contextLost
andcontextRestored
. These allow you to overwrite the defaultcontextLostHandler
andcontextRestoreHandler
handlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPosition
is a new internal method with 2 optional parameters:x
andy
. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSize
is a new internal method with 2 parameters:width
andheight
. These sets the width, and height of the area in the source image to cut. (thanks @FelipeIzolan)- Introduced new constants in
ORIENTATION_CONST
. The constantsLANDSCAPE_SECONDARY
andPORTRAIT_SECONDARY
have been added to thePhaser.Scale.Orientation
object. These constants represent the secondary landscape and portrait orientations respectively. This addition provides more granular control over device orientation handling in Phaser. Fix #6837 (thanks @rexrainbow) - Introduced
updateConfig
method inParticleEmitter
to allow dynamic updating of Particle Emitter configurations. This method enables existing properties to be overridden and new properties to be added to the emitter's configuration. It ensures that the emitter is reset with the updated configuration for more flexible particle effects management. - Added functionality to the
Phaser.Textures.DynamicTexture#clear
method. Clear a specific area within aDynamic Texture
by specifyingx
,y
,width
, andheight
parameters to clear only a portion of the texture. Fix #6853 (thanks @SelfDevTV) - Added functionality to the
Phaser.Renderer.WebGL.RenderTarget#clear
method. Clear a specific area within theRenderTarget
by specifyingx
,y
,width
, andheight
parameters. - Added Default Image Handling in
TextureManager
. In the gameconfig
, setdefaultImage
tonull
to ignore loading thedefaultImage
. - Added Missing Image Handling in
TextureManager
. In the gameconfig
, setmissingImage
tonull
to ignore loading themissingImage
. - Added White Image Support in
TextureManager
. In the gameconfig
, setwhiteImage
tonull
to ignore loading thewhiteImage
. Phaser.Core.TimeStep#pauseDuration
is a new property that holds the duration of the most recent game pause, if any, in ms (thanks @samme)- The Game
Events#RESUME
event now contains a new parameterpauseDuration
which is the duration, in ms, that the game was paused for (thanks @samme) - Added
Phaser.Loader.LoaderPlugin#removePack
method toLoaderPlugin
that removes resources listed in an Asset Pack.(thanks @samme) - When using
Scene.switch
you can now optionally specify adata
argument, just like with Scene start, which will be passed along to the Scene that was switched to (thanks @wooseok123) PRE_RENDER_CLEAR
is a new event dispatched by the WebGL and Canvas Renderer. It's dispatched at the start of the render step, immediately before the canvas is cleared. This allows you to toggle theclearBeforeRender
property as required, to have fine-grained control over when the canvas is cleared during render.Video.getFirstFrame
is a new method that can be used to load the first frame of the Video into its texture without starting playback. This is useful if you want to display the first frame of a video behind a 'Play' button, without calling the 'play' method.GameObject.getDisplayList
is a new method that will return the underlying list object that the Game Object belongs to, either the display list or its parent container.GameObject.setToTop
is a new method that will move the Game Object to the top of the display list, or its parent container (thanks @rexrainbow)GameObject.setToBack
is a new method that will move the Game Object to the bottom of the display list, or its parent container (thanks @rexrainbow)GameObject.setAbove
is a new method that will move the Game Object to appear above a given Game Object (thanks @rexrainbow)GameObject.setBelow
is a new method that will move the Game Object to appear below a given Game Object (thanks @rexrainbow)
WebGL Rendering Updates
WebGLTextureWrapper.update
expanded:source
parameter is now type?object
, so it can be used for anything that is valid in the constructor.- New
format
parameter can update the texture format.
Updates - Input System
- The
GameObject.disableInteractive
method has a new optional parameterresetCursor
. If set, this will reset the current custom input cursor - regardless if the Game Object was the one that set it, or not. - The
GameObject.removeInteractive
method has a new optional parameterresetCursor
. If set, this w...
Phaser v3.85.0
Version 3.85.0 - Itsuki - 5th September 2024
MatterJS
- MatterJS has been updated to version 0.20.0 - Here are all the details about this update.
- A new
wrap
method has been natively integrated into theBody
class to replace the existingMatterWrap
plugin. Here's how it works. - The Matter
attractors
plugin has been natively integrated into theBody
class and Matter engine. More details here. - Integrated
MatterCollisionEvents
plugin functionality directly into theMatter.World
class to handle collisions more effectively. More details here. - Updated
Matter.World
to improve the performance, accuracy, and reliability of theupdate
method in handling physics simulations or animations. More details here. - Fixed
Matter.World
bug wheregroup.length
returnsundefined
. Changed togroup.getLength()
to correctly return number of children in a group. - Calling
Matter.World.pause
would stop the world updating, but the RunnertimeLastTick
wasn't reset whenresume
was called, causing all the bodies to advance. The time is now reset correctly. Fix #6892 (thanks @philipgriffin)
Round Pixels
Includes a Potentially Breaking Change
The way roundPixels
has been handled in this release has been changed significantly. In previous versions we passed a uniform to the shaders and handled the pixel rounding on the GPU. However, this caused issues with our batching flow - for example, a Sprite would need to be rounded, but a Text or Shape object would not. This lead to complications in some parts of the render code.
In this release we have removed the shader uniform and branching and also made roundPixels
default to false
in the Game Config. Previously, it was true
, so you may need to switch this flag if you were relying on it. Here are the results of this change:
- The Game Config
roundPixels
property now defaults tofalse
. - The
uRoundPixels
uniform has been removed from the Single, Multi and Mobile vertex shaders. - Setting the
uRoundPixels
uniform has been removed from the Single, Rope, PreFX, PostFX, Multi and Mobile WebGL Pipelines. - The Multi Pipeline and Blitter WebGL Renderer will now pass the
camera.roundPixels
value to the Transform MatrixsetQuad
method. - The Multi Pipeline
batchSprite
andbatchTexture
methods will now applyMath.floor
to the sprite matrix calculations if camera round pixels is enabled. BaseCamera.preRender
has been removed. This method was completely overridden byCamera.preRender
which is the method that contained the correct rendering logic. As the Base Camera variant was not used internally outside of Dynamic Textures, we have removed it to save space.Camera.preRender
has been updated to use both zoomX and zoomY for the matrix transform.Camera.preRender
has been updated to apply Math.floor to the scroll factor when rounding is enabled on the Camera. This fixes an issue where following sprites with Camera lerp, or heavy zoom factors, would cause 'stuttering' at sub-pixel values.
New Features - Loader
The Loader now has a new feature called maxRetries
. This specifies the number of times a single File will retry loading itself should it error for whatever reason, such as poor network connectivity. The default value is 2. You can change this in the Game Config, on the LoaderPlugin instance, on the FileConfig or on the File level itself. Thanks to @pavle-goloskokovic for the suggestion.
loader.maxRetries
is a new Game Config option to set the number of retries a file will attempt to load. The default is 2.LoaderPlugin.maxRetries
is a new property that holds the number of times to retry loading a single file before it fails. This property is set via the Game Config, but can also be adjusted manually. Changing it doesn't not impact files already in the load queue, only those added later.FileConfig.maxRetries
is a new File Config option to set the number of retries a file will attempt to load. If not specified in the config, the value is read from theLoaderPlugin.maxRetries
property.Loader.File.retryAttempts
is the internal property holding the counter for the number of times to retry loading this file before it fails. This value is decreased after each attempt. When it reaches zero, the file is considered as failed.
New Features
BaseSoundManager.isPlaying
is a new method that will return a boolean if the given sound key is playing. If you don't provide a key, it will return a boolean if any sound is playing (thanks @samme)WebGLRenderer.dispatchContextLost
is a new internal method that is called when the WebGL context is lost. By default this is bound to the propertyWebGLRenderer.contextLostHandler
. If you override the context loss handler, be sure to invoke this method in due course.WebGLRenderer.dispatchContextRestore
is a new internal method that is called when the WebGL context is restored. By default this is bound to the propertyWebGLRenderer.contextRestoreHandler
. If you override the context restore handler, be sure to invoke this method in due course.WebGLRenderer.setContextHandlers
is a new internal method with 2 optional parameters:contextLost
andcontextRestored
. These allow you to overwrite the defaultcontextLostHandler
andcontextRestoreHandler
handlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPosition
is a new internal method with 2 optional parameters:x
andy
. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSize
is a new internal method with 2 parameters:width
andheight
. These sets the width, and height of the area in the source image to cut. (thanks @FelipeIzolan)- Introduced new constants in
ORIENTATION_CONST
. The constantsLANDSCAPE_SECONDARY
andPORTRAIT_SECONDARY
have been added to thePhaser.Scale.Orientation
object. These constants represent the secondary landscape and portrait orientations respectively. This addition provides more granular control over device orientation handling in Phaser. Fix #6837 (thanks @rexrainbow) - Introduced
updateConfig
method inParticleEmitter
to allow dynamic updating of Particle Emitter configurations. This method enables existing properties to be overridden and new properties to be added to the emitter's configuration. It ensures that the emitter is reset with the updated configuration for more flexible particle effects management. - Added functionality to the
Phaser.Textures.DynamicTexture#clear
method. Clear a specific area within aDynamic Texture
by specifyingx
,y
,width
, andheight
parameters to clear only a portion of the texture. Fix #6853 (thanks @SelfDevTV) - Added functionality to the
Phaser.Renderer.WebGL.RenderTarget#clear
method. Clear a specific area within theRenderTarget
by specifyingx
,y
,width
, andheight
parameters. - Added Default Image Handling in
TextureManager
. In the gameconfig
, setdefaultImage
tonull
to ignore loading thedefaultImage
. - Added Missing Image Handling in
TextureManager
. In the gameconfig
, setmissingImage
tonull
to ignore loading themissingImage
. - Added White Image Support in
TextureManager
. In the gameconfig
, setwhiteImage
tonull
to ignore loading thewhiteImage
. Phaser.Core.TimeStep#pauseDuration
is a new property that holds the duration of the most recent game pause, if any, in ms (thanks @samme)- The Game
Events#RESUME
event now contains a new parameterpauseDuration
which is the duration, in ms, that the game was paused for (thanks @samme) - Added
Phaser.Loader.LoaderPlugin#removePack
method toLoaderPlugin
that removes resources listed in an Asset Pack.(thanks @samme) - When using
Scene.switch
you can now optionally specify adata
argument, just like with Scene start, which will be passed along to the Scene that was switched to (thanks @wooseok123) PRE_RENDER_CLEAR
is a new event dispatched by the WebGL and Canvas Renderer. It's dispatched at the start of the render step, immediately before the canvas is cleared. This allows you to toggle theclearBeforeRender
property as required, to have fine-grained control over when the canvas is cleared during render.Video.getFirstFrame
is a new method that can be used to load the first frame of the Video into its texture without starting playback. This is useful if you want to display the first frame of a video behind a 'Play' button, without calling the 'play' method.GameObject.getDisplayList
is a new method that will return the underlying list object that the Game Object belongs to, either the display list or its parent container.GameObject.setToTop
is a new method that will move the Game Object to the top of the display list, or its parent container (thanks @rexrainbow)GameObject.setToBack
is a new method that will move the Game Object to the bottom of the display list, or its parent container (thanks @rexrainbow)GameObject.setAbove
is a new method that will move the Game Object to appear above a given Game Object (thanks @rexrainbow)GameObject.setBelow
is a new method that will move the Game Object to appear below a given Game Object (thanks @rexrainbow)
WebGL Rendering Updates
WebGLTextureWrapper.update
expanded:source
parameter is now type?object
, so it can be used for anything that is valid in the constructor.- New
format
parameter can update the texture format.
Updates - Input System
- The
GameObject.disableInteractive
method has a new optional parameterresetCursor
. If set, this will reset the current custom input cursor - regardless if the Game Object was the one that set it, or not. - The
GameObject.removeInteractive
method has a new optional parameterresetCursor
. If set, this w...
Phaser v3.85.0 Beta 2
Version 3.85.0 - Itsuki - in development
Round Pixels
Includes a Potentially Breaking Change
The way roundPixels
has been handled in this release has been changed significantly. In previous versions we passed a uniform to the shaders and handled the pixel rounding on the GPU. However, this caused issues with our batching flow - for example, a Sprite would need to be rounded, but a Text or Shape object would not. This lead to complications in some parts of the render code.
In this release we have removed the shader uniform and branching and also made roundPixels
default to false
in the Game Config. Previously, it was true
, so you may need to switch this flag if you were relying on it. Here are the results of this change:
- The Game Config
roundPixels
property now defaults tofalse
. - The
uRoundPixels
uniform has been removed from the Single, Multi and Mobile vertex shaders. - Setting the
uRoundPixels
uniform has been removed from the Single, Rope, PreFX, PostFX, Multi and Mobile WebGL Pipelines. - The Multi Pipeline and Blitter WebGL Renderer will now pass the
camera.roundPixels
value to the Transform MatrixsetQuad
method. - The Multi Pipeline
batchSprite
andbatchTexture
methods will now applyMath.floor
to the sprite matrix calculations if camera round pixels is enabled. BaseCamera.preRender
has been removed. This method was completely overridden byCamera.preRender
which is the method that contained the correct rendering logic. As the Base Camera variant was not used internally outside of Dynamic Textures, we have removed it to save space.Camera.preRender
has been updated to use both zoomX and zoomY for the matrix transform.Camera.preRender
has been updated to apply Math.floor to the scroll factor when rounding is enabled on the Camera. This fixes an issue where following sprites with Camera lerp, or heavy zoom factors, would cause 'stuttering' at sub-pixel values.
New Features
BaseSoundManager.isPlaying
is a new method that will return a boolean if the given sound key is playing. If you don't provide a key, it will return a boolean if any sound is playing (thanks @samme)WebGLRenderer.dispatchContextLost
is a new internal method that is called when the WebGL context is lost. By default this is bound to the propertyWebGLRenderer.contextLostHandler
. If you override the context loss handler, be sure to invoke this method in due course.WebGLRenderer.dispatchContextRestore
is a new internal method that is called when the WebGL context is restored. By default this is bound to the propertyWebGLRenderer.contextRestoreHandler
. If you override the context restore handler, be sure to invoke this method in due course.WebGLRenderer.setContextHandlers
is a new internal method with 2 optional parameters:contextLost
andcontextRestored
. These allow you to overwrite the defaultcontextLostHandler
andcontextRestoreHandler
handlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPosition
is a new internal method with 2 optional parameters:x
andy
. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSize
is a new internal method with 2 parameters:width
andheight
. These sets the width, and height of the area in the source image to cut. (thanks @FelipeIzolan)- Introduced new constants in
ORIENTATION_CONST
. The constantsLANDSCAPE_SECONDARY
andPORTRAIT_SECONDARY
have been added to thePhaser.Scale.Orientation
object. These constants represent the secondary landscape and portrait orientations respectively. This addition provides more granular control over device orientation handling in Phaser. Fix #6837 (thanks @rexrainbow) - Introduced
updateConfig
method inParticleEmitter
to allow dynamic updating of Particle Emitter configurations. This method enables existing properties to be overridden and new properties to be added to the emitter's configuration. It ensures that the emitter is reset with the updated configuration for more flexible particle effects management. - A new
wrap
method has been natively integrated into theBody
class to replace the existingMatterWrap
plugin. Here's how it works. - The Matter
attractors
plugin has been natively integrated into theBody
class and Matter engine. More details here. - Added functionality to the
Phaser.Textures.DynamicTexture#clear
method. Clear a specific area within aDynamic Texture
by specifyingx
,y
,width
, andheight
parameters to clear only a portion of the texture. Fix #6853 (thanks @SelfDevTV) - Added functionality to the
Phaser.Renderer.WebGL.RenderTarget#clear
method. Clear a specific area within theRenderTarget
by specifyingx
,y
,width
, andheight
parameters. - Added Default Image Handling in
TextureManager
. In the gameconfig
, setdefaultImage
tonull
to ignore loading thedefaultImage
. - Added Missing Image Handling in
TextureManager
. In the gameconfig
, setmissingImage
tonull
to ignore loading themissingImage
. - Added White Image Support in
TextureManager
. In the gameconfig
, setwhiteImage
tonull
to ignore loading thewhiteImage
. Phaser.Core.TimeStep#pauseDuration
is a new property that holds the duration of the most recent game pause, if any, in ms (thanks @samme)- The Game
Events#RESUME
event now contains a new parameterpauseDuration
which is the duration, in ms, that the game was paused for (thanks @samme) - Added
Phaser.Loader.LoaderPlugin#removePack
method toLoaderPlugin
that removes resources listed in an Asset Pack.(thanks @samme)
WebGL Rendering Updates
WebGLTextureWrapper.update
expanded:source
parameter is now type?object
, so it can be used for anything that is valid in the constructor.- New
format
parameter can update the texture format.
Updates
- MatterJS updated to 0.20.0 and integrated into Phaser. Here are details about the update.
- Integrated
MatterCollisionEvents
plugin functionality directly into theMatter.World
class to handle collisions more effectively. More details here. - Updated
Matter.World
to improve the performance, accuracy, and reliability of theupdate
method in handling physics simulations or animations. More details here. - Calling
Timeline.pause
will now pause any currently active Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.resume
will now resume any currently paused Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.clear
andTimeline.destroy
will now destroy any currently active Tweens that the Timeline had created. Previously, active tweens would continue to play to completion (thanks @monteiz) TimelineEvent
has a new property calledtweenInstance
. If the Timeline event has a tween that has been activated, this will hold a reference to it.- If you create a BitmapText with an invalid key it will now throw a runtime error. Previously it just issued a console warning and then crashed (thanks @samme)
- The console warnings when Audio files are missing/incorrect have been improved (thanks @samme)
- The
requestVideoFrame
polyfill has been updated to the latest release, which should resolve some SSR framework issues. Fix #6776 (thanks @lantictac) ScaleManager
listeners includes checks for thescreen.orientation
object and adds/removes achange
eventListener method to handle screen orientation changes on mobile devices. Theorientationchange
event is still maintained for backwards compatibility. Fix #6837 (thanks @rexrainbow)- When creating a new
TileSprite
, setting eitherwidth
orheight
to0
results in both values being set to thedisplayFrame.width
anddisplayFrame.height
. The updated logic now checks forwidth
andheight
separately. Ifwidth
is0
, it is set todisplayFrame.width
. Ifheight
is0
, it is set todisplayFrame.height
. Fix #6857 (thanks @GaryStanton) - Updated
GetBitmapTextSize
with improvedmaxWidth
calculations for wrapped text. Vector3.subVectors
is a new method that will take 2 Vector3s, subtract them from each other and store the result in the Vector3 it was called on.- The
TextStyle.setStyle
method will no longer mutate the givenstyle
object if it includes a numericfontSize
value. Fix #6863 (thanks @stormpanda) - Calling the
Shape.Ellipse.setSize
method will internally callupdateDisplayOrigin
to retain position after a size change. - The
BitmapText BatchChar
function now inlines all of the matrix math, avoiding 16 function calls per character rendered.
Bug Fixes
- The
activePointers
game config option is now the correct amount of touch input pointers set. Fix #6783 (thanks @samme) - The method
TextureManager.checkKey
will now returnfalse
if the key is not a string, which fixes issues where a texture could be created if a key was given that was already in use (thanks Will Macfarlane). - Added all of the missing Loader Config values (such as
imageLoadType
) to LoaderConfig, so they now appear in the TypeScript defs. - The
EXPAND
scale mode had a bug that prevented it from using the world bounds cameras, cutting rendering short. Fix #6767 (thanks @Calcue-dev @rexrainbow) - Calling
getPipelineName()
on a Game Object would cause a runtime error if running under Canvas. It now simply returnsnull
. Fix #6799 (thanks @samme) - Calling the Arcade Body
setPushable(false)
method forcircle
bodies prevents the bodies from being pushed. Fix #5617 (thanks @kainage) - Calling
addDeathZone()
on a particle emitter Game Object had a bug where theDeathZone
used world position coordinates.DeathZone
now uses local position coordinates following the particle emitter position. Fix #6371 (thanks @vforsh) - Upda...
Phaser v3.85.0 Beta 1
Version 3.85.0 - Itsuki - in development
New Features
BaseSoundManager.isPlaying
is a new method that will return a boolean if the given sound key is playing. If you don't provide a key, it will return a boolean if any sound is playing (thanks @samme)WebGLRenderer.dispatchContextLost
is a new internal method that is called when the WebGL context is lost. By default this is bound to the propertyWebGLRenderer.contextLostHandler
. If you override the context loss handler, be sure to invoke this method in due course.WebGLRenderer.dispatchContextRestore
is a new internal method that is called when the WebGL context is restored. By default this is bound to the propertyWebGLRenderer.contextRestoreHandler
. If you override the context restore handler, be sure to invoke this method in due course.WebGLRenderer.setContextHandlers
is a new internal method with 2 optional parameters:contextLost
andcontextRestored
. These allow you to overwrite the defaultcontextLostHandler
andcontextRestoreHandler
handlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPosition
is a new internal method with 2 optional parameters:x
andy
. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSize
is a new internal method with 2 parameters:width
andheight
. These sets the width, and height of the area in the source image to cut. (thanks @FelipeIzolan)- Introduced new constants in
ORIENTATION_CONST.js
. The constantsLANDSCAPE_SECONDARY
andPORTRAIT_SECONDARY
have been added to thePhaser.Scale.Orientation
object. These constants represent the secondary landscape and portrait orientations respectively. This addition provides more granular control over device orientation handling in Phaser. Fix #6837 (thanks @rexrainbow)
WebGL Rendering Updates
WebGLTextureWrapper.update
expanded:source
parameter is now type?object
, so it can be used for anything that is valid in the constructor.- New
format
parameter can update the texture format.
Updates
- Calling
Timeline.pause
will now pause any currently active Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.resume
will now resume any currently paused Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.clear
andTimeline.destroy
will now destroy any currently active Tweens that the Timeline had created. Previously, active tweens would continue to play to completion (thanks @monteiz) TimelineEvent
has a new property calledtweenInstance
. If the Timeline event has a tween that has been activated, this will hold a reference to it.- If you create a BitmapText with an invalid key it will now throw a runtime error. Previously it just issued a console warning and then crashed (thanks @samme)
- The console warnings when Audio files are missing/incorrect have been improved (thanks @samme)
- The
requestVideoFrame
polyfill has been updated to the latest release, which should resolve some SSR framework issues. Fix #6776 (thanks @lantictac) ScaleManager
listeners includes checks for thescreen.orientation
object and adds/removes achange
eventListener method to handle screen orientation changes on mobile devices. Theorientationchange
event is still maintained for backwards compatibility. Fix #6837 (thanks @rexrainbow)
Bug Fixes
- The
activePointers
game config option is now the correct amount of touch input pointers set. Fix #6783 (thanks @samme) - The method
TextureManager.checkKey
will now returnfalse
if the key is not a string, which fixes issues where a texture could be created if a key was given that was already in use (thanks Will Macfarlane). - Added all of the missing Loader Config values (such as
imageLoadType
) to LoaderConfig, so they now appear in the TypeScript defs. - The
EXPAND
scale mode had a bug that prevented it from using the world bounds cameras, cutting rendering short. Fix #6767 (thanks @Calcue-dev @rexrainbow) - Calling
getPipelineName()
on a Game Object would cause a runtime error if running under Canvas. It now simply returnsnull
. Fix #6799 (thanks @samme) - Calling the Arcade Body
setPushable(false)
method forcircle
bodies prevents the bodies from being pushed. Fix #5617 (thanks @kainage) - Calling
addDeathZone()
on a particle emitter Game Object had a bug where theDeathZone
used world position coordinates.DeathZone
now uses local position coordinates following the particle emitter position. Fix #6371 (thanks @vforsh) - Updated the
GetLineToLine
method inGetLineToLine.js
to handle the case wheredx1
ordy1
values is zero. This ensures the function correctly returnsnull
in this case to prevent errors in calculations involving line segments. Fix #6579 (thanks @finscn) - Resolved all kerning issues in WebGL bitmap text rendering. This includes adjustments to glyph positioning and spacing, ensuring accurate and visually pleasing text display across all WebGL contexts. Fix #6631 (thanks @monteiz)
- Resolved an issue in
GetBitmapTextSize.js
where an extra empty line was added whensetMaxWidth
was called, and the width of the line was less than a word. Previously,yAdvance
was incorrectly incremented bylineHeight + lineSpacing
for each word, leading to an unintended increase in vertical space. The correction now calculatesyAdvance
based on thecurrentLine
index, ensuring that vertical spacing accurately reflects the number of lines. Fix #6807 (thanks @AlvaroNeuronup)
Input Bug Fixes
- The method
pointer.leftButtonReleased
will now returntrue
when multiple mouse buttons are being pressed. - The method
pointer.rightButtonReleased
will now returntrue
when multiple mouse buttons are being pressed. - The method
pointer.middleButtonReleased
will now returntrue
when multiple mouse buttons are being pressed. - The method
pointer.backButtonReleased
will now returntrue
when multiple mouse buttons are being pressed. - The method
pointer.forwardButtonReleased
will now returntrue
when multiple mouse buttons are being pressed. Fix #6027 (thanks @michalfialadev)
Examples, Documentation, Beta Testing and TypeScript
Thanks to the following for helping with the Phaser Examples, Beta Testing, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:
@lgtome
@samme
@AlbertMontagutCasero
@rexrainbow
Deprecation Warning for the next release
The next release of Phaser will make the following API-breaking changes:
- We are removing
Phaser.Struct.Map
and replacing it with a regular JSMap
instance. This means methods likecontains
andsetAll
will be gone. - We are removing
Phaser.Struct.Set
and replacing it with a regular JSSet
instance. This means methods likeiterateLocal
will be gone. - The
Create.GenerateTexture
, all of the Create Palettes and thecreate
folder will be removed. - The
phaser-ie9.js
entry-point will be removed along with all associated polyfills.
Phaser v3.80.1
Please also see the 3.80 Change Log for details about the major 3.80 release.
Bug Fixes
- Fix
RenderTexture
crashing in the presence of a light. - Fix failure to restore compressed textures after WebGL context loss.
- Fix a single WebGL error, with no visual side-effects, from occurring while calling
Shader.setRenderToTexture()
after the game has started running. Actually, the root cause was leaving new WebGL textures bound after creation. - Ensure that
TextureSource.setFlipY
always updates the texture. - Remove unsynced
flipY
from render textures inShader
andDynamicTexture
. - Reverted a change made in
TouchManager
that would prevent clicks from outside the game window from being registered. Fix #6747 (thanks @ulsoftnaver @jaxtheking)
Updates
- Modified
onMouseUpWindow
andonMouseDownWindow
in theMouseManager
so they now check forsourceCapabilities.firesTouchEvents
and if found, abort registering the event. This new browser event property is designed to prevent you accidentally registering a Mouse Event when a Touch Event has just occurred (see https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceCapabilities/firesTouchEvents)
Phaser v3.80.0
New Features - WebGL Context Loss Handling
- Phaser now performs a WebGL Context Restore to keep the game running after losing WebGL context. This affects many parts of the rendering system, but everything should work just the same unless you're doing something very technical. See the link for more details.
New Feature - Base64 Loader
The Phaser LoaderPlugin and related classes have been updated so that they now work natively with base64 encoded files and Data URIs. This means you can now load a base64 encoded image, audio file or text file directly into the Loader. The Loader will then decode the data and process it as if it was a normal file. This is particularly useful for environments such as Playable Ads where you have to provide a single html file with all assets embedded and no XHR requests.
Loader.File.base64
is a new read-only boolean property that is set if the file contains a Data URI encoded string.Loader.File.onBase64Load
is a new method that is called when the file has finished decoding from a Data URI.- The
ImageFile
will now default to using the Image Load Element if a base64 file is detected, instead of throwing a console warning about unsupported types. - The
XHRLoader
will now return a fake XHR result object containing the decoded base64 data if a base64 file is detected, skipping the creation of a real XML Http Request object.
New Feature - Scale Manager Snap Mode
The Game Config has a new Scale Manager property called snap
. This allows you to set a 'snapping' value for the width and height of your game. This is especially useful for games where you want to keep a fixed dimension: for example, you want the game to always snap to a multiple of 16 pixels for the width. Or, if you want to scale a pixel-art game up by integer values, you can now set the game size as the snap
value and the Scale Manager will ensure the game size is always a multiple of that value.
- A new property is available in the Game Configuration specifically for setting the 'snap' values for the Scale Manager. You can now set
snap: { width, height }
in the game config. This is then passed to the display size by the Scale Manager and used to control the snap values. Fix #6629 (thanks @musjj @samme) ScaleManager.setSnap
is a new method that allows you to set the snap values for the game size, should you need to do it post-boot and not in the game config.Config#snapWidth
andConfig#snapHeight
are new properties in the Game Config that hold the parsedsnap
config values, as used by the Scale Manager.
New Features
- The Scale Manager has a new scale mode called
EXPAND
. This is inspired by the Expand mode in Godot: "Keep aspect ratio when stretching the screen, but keep neither the base width nor height. Depending on the screen aspect ratio, the viewport will either be larger in the horizontal direction (if the screen is wider than the base size) or in the vertical direction (if the screen is taller than the original size)" (thanks @rexrainbow) - The
Tilemap.createFromTiles
method has been updated. It will now copy the following properties, if set in the Tile, to the Sprites it creates:rotation
,flipX
,flipY
,alpha
,visible
andtint
. If these properties are declared in thespriteConfig
passed to the method, those will be used instead, otherwise the Tile values are used. Fix #6711 (thanks @Nerodon) - The
Tilemap.createFromTiles
method has a new property calleduseSpriteSheet
. If this is set totrue
and you have loaded the tileset as a sprite sheet (not an image), then it will set the Sprite key and frame to match the sprite texture and tile index. Also, if you have not specified anorigin
in the spriteConfig, it will adjust the sprite positions by half the tile size, to position them accurately on the map. Texture#getFrameBounds
is a new method that will return the bounds that all of the frames of a given Texture Source encompass. This is useful for things like calculating the bounds of a Sprite Sheet embedded within a Texture Atlas.Math.RectangleLike
is a new typedef that defines a rectangle-like object with publicx
,y
,width
andheight
properties.
WebGL Renderer Updates
- Fix MIPmap filters being effectively disabled for compressed textures.
WebGLRenderer.getCompressedTextures
can now identify BPTC and RGTC support correctly. These were previously skipped.- PVR compressed texture files now support sRGB color space in S3TCSRGB, ETC, and ASTC formats. Fix #6247 (thanks @dominikhalvonik)
- Compressed texture files which are incompatible with WebGL will now fail to load, and display a console warning explaining why. Previously they might seem to load, but not display properly.
- Add experimental support for BPTC compressed textures in PVR files.
- Change
S3TCRGB
toS3TCSRGB
inWebGLTextureCompression
,CompressedTextureFileConfig
, andFileConfig
typedefs. - Fix generating spritesheets from members of texture atlases based on compressed textures (thanks @vladyslavfolkuian)
- The
BloomFX
andBlurFX
and any custom pipeline that relies on using theUtilityPipeline
full or half frame targets will now correctly draw even after the renderer size changes. Fix #6677 (thanks @Nerodon) - The
PostFXPipeline.postBatch
method will now bind the current Render Target after the pipeline has booted for the first time. This fixes glitch errors on mobile devices where Post FX would appear corrupted for a single frame. Fix #6681 (thanks @moufmouf @tongliang999) - Fix unpredictable text sizes failing to render in WebGL with
mipmapFilter
set. Fix #6721 (thanks @SaintFlow and @rexrainbow) - The
UtilityPipeline
now setsautoResize
totrue
in its Render Target Config, so that the globalfullFrame
andhalfFrame
Render Targets will automatically resize if the renderer changes. WebGLPipeline.resizeUniform
is a new property that is defined in theWebGLPipelineConfig
. This is a string that defines auResolution
property, or similar, within the pipeline shader. If the WebGL Renderer resizes, this uniform will now be updated automatically as part of the pipeline resize method. It has been added to both the Multi and Mobile pipelines as default. This fixes issues where the pipelines were rendering with old resolution values, causing graphical glitches in mostly pixel-art games. Fix #6674 #6678 (thanks @Nerodon @LazeKer)
Spine Updates
- The Spine 3 and 4.1 Plugins will now call
preUpdate
automatically when theplay
method is called. This forces the new animation state to update and apply itself to the skeleton. This fixes an issue where Spine object would show the default frame in the Spine atlas for a single update before the animation started. Fix #5443 (thanks @spayton) SpineGameObject.setSlotAlpha
is a new method that allows you to set the alpha on a specific slot in a Spine skeleton.- The
SpineGameObject.setAlpha
method has had its 2nd parameter removed. This fixes needless slot look-ups during rendering when a Spine Game Object is inside a regular Container. If you need to set slot alpha, use the newsetSlotAlpha
method instead. Fix #6571 (thanks @spayton) - The
SpineFile.onFileComplete
handler was running a regular expression againstfile.src
instead offile.url
, sometimes leading to double paths in the atlas paths on loading. Fix #6642 (thanks @rez23)
Input Updates
The Phaser Input and related classes have been updated to be more consistent with each Game Object.
- If you enable a Game Object for Input Debugging, the debug shape will no longer be rendered if the Game Object itself is not visible. Fix #6364 (thanks @orjandh)
Mesh
based Game Objects now can use an input config with thesetInteractive
method, which supports the optionsdraggable
,dropzone
,cursor
anduserHandCursor
. Fix #6510 #6652 (thanks @Baegus @Neppord)- The touch event handler
onTouchEndWindow
now stops pointer events when clicking through DOM elements to input. Fix #6697 (thanks @laineus) - The
Input.InputPlugin
methoddisable
which is called byGameObjects.GameObject#disableInteractive
keeps its temp hit box value which stops propagation to interactive Game Objects in another scene. Fix #6601 (thanks @UnaiNeuronUp) - Using
setInteractive
andremoveInteractive
methods of a Game Object outside of the game loop would cause an error in whichInput.InputManager#resetCursor
would lose input context. Fix #6387 (thanks @TomorrowToday)
Updates
- The
TweenChainBuilder
was incorrectly setting thepersist
flag on the Chain totrue
, which goes against what the documentation says. It now correctly sets it tofalse
. This means if you previously had a Tween Chain that was persisting, it will no longer do so, so add the property to regain the feature. - The
dropped
argument has now been added to the documentation for theDRAG_END
andGAMEOBJECT_DRAG_END
events. (thanks @samme) Container.onChildDestroyed
is a new internal method used to destroy Container children. Previously, if you destroyed a Game Object in an exclusive Container, the game object would (momentarily) move onto the Scene display list and emit an ADDED_TO_SCENE event. Also, if you added a Sprite to a non-exclusive Container and stopped the Scene, you would get a TypeError (evaluating 'this.anims.destroy'). This happened because the fromChild argument in the DESTROY event was misinterpreted as destroyChild in the Container's remove(), and the Container was calling the Sprite's destroy() again. (thanks @samme)- The
Text
andTileSprite
Game Objects now place their textures into the globalTextureManager
and a_textureKey
private string property has been added which contains a UUID to reference that texture. - The
Tilemaps.Components.WeightedRandomize
method now uses the PhaserMath.RND.frac
method with a seed instead ...