Releases: phaserjs/phaser
Phaser v3.85.2
Updates
WebGLRenderer.setExtensionsis 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 theinitand 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.setQuadhas 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 usingroundPixelson 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
wrapmethod has been natively integrated into theBodyclass to replace the existingMatterWrapplugin. Here's how it works. - The Matter
attractorsplugin has been natively integrated into theBodyclass and Matter engine. More details here. - Integrated
MatterCollisionEventsplugin functionality directly into theMatter.Worldclass to handle collisions more effectively. More details here. - Updated
Matter.Worldto improve the performance, accuracy, and reliability of theupdatemethod in handling physics simulations or animations. More details here. - Fixed
Matter.Worldbug wheregroup.lengthreturnsundefined. Changed togroup.getLength()to correctly return number of children in a group. - Calling
Matter.World.pausewould stop the world updating, but the RunnertimeLastTickwasn't reset whenresumewas 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
roundPixelsproperty now defaults tofalse. - The
uRoundPixelsuniform has been removed from the Single, Multi and Mobile vertex shaders. - Setting the
uRoundPixelsuniform 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.roundPixelsvalue to the Transform MatrixsetQuadmethod. - The Multi Pipeline
batchSpriteandbatchTexturemethods will now applyMath.floorto the sprite matrix calculations if camera round pixels is enabled. BaseCamera.preRenderhas been removed. This method was completely overridden byCamera.preRenderwhich 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.preRenderhas been updated to use both zoomX and zoomY for the matrix transform.Camera.preRenderhas 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.maxRetriesis a new Game Config option to set the number of retries a file will attempt to load. The default is 2.LoaderPlugin.maxRetriesis 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.maxRetriesis 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.maxRetriesproperty.Loader.File.retryAttemptsis 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.isPlayingis 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.dispatchContextLostis 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.dispatchContextRestoreis 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.setContextHandlersis a new internal method with 2 optional parameters:contextLostandcontextRestored. These allow you to overwrite the defaultcontextLostHandlerandcontextRestoreHandlerhandlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPositionis a new internal method with 2 optional parameters:xandy. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSizeis a new internal method with 2 parameters:widthandheight. 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_SECONDARYandPORTRAIT_SECONDARYhave been added to thePhaser.Scale.Orientationobject. 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
updateConfigmethod inParticleEmitterto 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#clearmethod. Clear a specific area within aDynamic Textureby specifyingx,y,width, andheightparameters to clear only a portion of the texture. Fix #6853 (thanks @SelfDevTV) - Added functionality to the
Phaser.Renderer.WebGL.RenderTarget#clearmethod. Clear a specific area within theRenderTargetby specifyingx,y,width, andheightparameters. - Added Default Image Handling in
TextureManager. In the gameconfig, setdefaultImagetonullto ignore loading thedefaultImage. - Added Missing Image Handling in
TextureManager. In the gameconfig, setmissingImagetonullto ignore loading themissingImage. - Added White Image Support in
TextureManager. In the gameconfig, setwhiteImagetonullto ignore loading thewhiteImage. Phaser.Core.TimeStep#pauseDurationis a new property that holds the duration of the most recent game pause, if any, in ms (thanks @samme)- The Game
Events#RESUMEevent now contains a new parameterpauseDurationwhich is the duration, in ms, that the game was paused for (thanks @samme) - Added
Phaser.Loader.LoaderPlugin#removePackmethod toLoaderPluginthat removes resources listed in an Asset Pack.(thanks @samme) - When using
Scene.switchyou can now optionally specify adataargument, just like with Scene start, which will be passed along to the Scene that was switched to (thanks @wooseok123) PRE_RENDER_CLEARis 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 theclearBeforeRenderproperty as required, to have fine-grained control over when the canvas is cleared during render.Video.getFirstFrameis 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.getDisplayListis 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.setToTopis a new method that will move the Game Object to the top of the display list, or its parent container (thanks @rexrainbow)GameObject.setToBackis a new method that will move the Game Object to the bottom of the display list, or its parent container (thanks @rexrainbow)GameObject.setAboveis a new method that will move the Game Object to appear above a given Game Object (thanks @rexrainbow)GameObject.setBelowis a new method that will move the Game Object to appear below a given Game Object (thanks @rexrainbow)
WebGL Rendering Updates
WebGLTextureWrapper.updateexpanded:sourceparameter is now type?object, so it can be used for anything that is valid in the constructor.- New
formatparameter can update the texture format.
Updates - Input System
- The
GameObject.disableInteractivemethod 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.removeInteractivemethod 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
wrapmethod has been natively integrated into theBodyclass to replace the existingMatterWrapplugin. Here's how it works. - The Matter
attractorsplugin has been natively integrated into theBodyclass and Matter engine. More details here. - Integrated
MatterCollisionEventsplugin functionality directly into theMatter.Worldclass to handle collisions more effectively. More details here. - Updated
Matter.Worldto improve the performance, accuracy, and reliability of theupdatemethod in handling physics simulations or animations. More details here. - Fixed
Matter.Worldbug wheregroup.lengthreturnsundefined. Changed togroup.getLength()to correctly return number of children in a group. - Calling
Matter.World.pausewould stop the world updating, but the RunnertimeLastTickwasn't reset whenresumewas 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
roundPixelsproperty now defaults tofalse. - The
uRoundPixelsuniform has been removed from the Single, Multi and Mobile vertex shaders. - Setting the
uRoundPixelsuniform 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.roundPixelsvalue to the Transform MatrixsetQuadmethod. - The Multi Pipeline
batchSpriteandbatchTexturemethods will now applyMath.floorto the sprite matrix calculations if camera round pixels is enabled. BaseCamera.preRenderhas been removed. This method was completely overridden byCamera.preRenderwhich 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.preRenderhas been updated to use both zoomX and zoomY for the matrix transform.Camera.preRenderhas 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.maxRetriesis a new Game Config option to set the number of retries a file will attempt to load. The default is 2.LoaderPlugin.maxRetriesis 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.maxRetriesis 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.maxRetriesproperty.Loader.File.retryAttemptsis 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.isPlayingis 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.dispatchContextLostis 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.dispatchContextRestoreis 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.setContextHandlersis a new internal method with 2 optional parameters:contextLostandcontextRestored. These allow you to overwrite the defaultcontextLostHandlerandcontextRestoreHandlerhandlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPositionis a new internal method with 2 optional parameters:xandy. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSizeis a new internal method with 2 parameters:widthandheight. 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_SECONDARYandPORTRAIT_SECONDARYhave been added to thePhaser.Scale.Orientationobject. 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
updateConfigmethod inParticleEmitterto 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#clearmethod. Clear a specific area within aDynamic Textureby specifyingx,y,width, andheightparameters to clear only a portion of the texture. Fix #6853 (thanks @SelfDevTV) - Added functionality to the
Phaser.Renderer.WebGL.RenderTarget#clearmethod. Clear a specific area within theRenderTargetby specifyingx,y,width, andheightparameters. - Added Default Image Handling in
TextureManager. In the gameconfig, setdefaultImagetonullto ignore loading thedefaultImage. - Added Missing Image Handling in
TextureManager. In the gameconfig, setmissingImagetonullto ignore loading themissingImage. - Added White Image Support in
TextureManager. In the gameconfig, setwhiteImagetonullto ignore loading thewhiteImage. Phaser.Core.TimeStep#pauseDurationis a new property that holds the duration of the most recent game pause, if any, in ms (thanks @samme)- The Game
Events#RESUMEevent now contains a new parameterpauseDurationwhich is the duration, in ms, that the game was paused for (thanks @samme) - Added
Phaser.Loader.LoaderPlugin#removePackmethod toLoaderPluginthat removes resources listed in an Asset Pack.(thanks @samme) - When using
Scene.switchyou can now optionally specify adataargument, just like with Scene start, which will be passed along to the Scene that was switched to (thanks @wooseok123) PRE_RENDER_CLEARis 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 theclearBeforeRenderproperty as required, to have fine-grained control over when the canvas is cleared during render.Video.getFirstFrameis 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.getDisplayListis 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.setToTopis a new method that will move the Game Object to the top of the display list, or its parent container (thanks @rexrainbow)GameObject.setToBackis a new method that will move the Game Object to the bottom of the display list, or its parent container (thanks @rexrainbow)GameObject.setAboveis a new method that will move the Game Object to appear above a given Game Object (thanks @rexrainbow)GameObject.setBelowis a new method that will move the Game Object to appear below a given Game Object (thanks @rexrainbow)
WebGL Rendering Updates
WebGLTextureWrapper.updateexpanded:sourceparameter is now type?object, so it can be used for anything that is valid in the constructor.- New
formatparameter can update the texture format.
Updates - Input System
- The
GameObject.disableInteractivemethod 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.removeInteractivemethod 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
roundPixelsproperty now defaults tofalse. - The
uRoundPixelsuniform has been removed from the Single, Multi and Mobile vertex shaders. - Setting the
uRoundPixelsuniform 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.roundPixelsvalue to the Transform MatrixsetQuadmethod. - The Multi Pipeline
batchSpriteandbatchTexturemethods will now applyMath.floorto the sprite matrix calculations if camera round pixels is enabled. BaseCamera.preRenderhas been removed. This method was completely overridden byCamera.preRenderwhich 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.preRenderhas been updated to use both zoomX and zoomY for the matrix transform.Camera.preRenderhas 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.isPlayingis 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.dispatchContextLostis 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.dispatchContextRestoreis 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.setContextHandlersis a new internal method with 2 optional parameters:contextLostandcontextRestored. These allow you to overwrite the defaultcontextLostHandlerandcontextRestoreHandlerhandlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPositionis a new internal method with 2 optional parameters:xandy. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSizeis a new internal method with 2 parameters:widthandheight. 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_SECONDARYandPORTRAIT_SECONDARYhave been added to thePhaser.Scale.Orientationobject. 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
updateConfigmethod inParticleEmitterto 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
wrapmethod has been natively integrated into theBodyclass to replace the existingMatterWrapplugin. Here's how it works. - The Matter
attractorsplugin has been natively integrated into theBodyclass and Matter engine. More details here. - Added functionality to the
Phaser.Textures.DynamicTexture#clearmethod. Clear a specific area within aDynamic Textureby specifyingx,y,width, andheightparameters to clear only a portion of the texture. Fix #6853 (thanks @SelfDevTV) - Added functionality to the
Phaser.Renderer.WebGL.RenderTarget#clearmethod. Clear a specific area within theRenderTargetby specifyingx,y,width, andheightparameters. - Added Default Image Handling in
TextureManager. In the gameconfig, setdefaultImagetonullto ignore loading thedefaultImage. - Added Missing Image Handling in
TextureManager. In the gameconfig, setmissingImagetonullto ignore loading themissingImage. - Added White Image Support in
TextureManager. In the gameconfig, setwhiteImagetonullto ignore loading thewhiteImage. Phaser.Core.TimeStep#pauseDurationis a new property that holds the duration of the most recent game pause, if any, in ms (thanks @samme)- The Game
Events#RESUMEevent now contains a new parameterpauseDurationwhich is the duration, in ms, that the game was paused for (thanks @samme) - Added
Phaser.Loader.LoaderPlugin#removePackmethod toLoaderPluginthat removes resources listed in an Asset Pack.(thanks @samme)
WebGL Rendering Updates
WebGLTextureWrapper.updateexpanded:sourceparameter is now type?object, so it can be used for anything that is valid in the constructor.- New
formatparameter can update the texture format.
Updates
- MatterJS updated to 0.20.0 and integrated into Phaser. Here are details about the update.
- Integrated
MatterCollisionEventsplugin functionality directly into theMatter.Worldclass to handle collisions more effectively. More details here. - Updated
Matter.Worldto improve the performance, accuracy, and reliability of theupdatemethod in handling physics simulations or animations. More details here. - Calling
Timeline.pausewill now pause any currently active Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.resumewill now resume any currently paused Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.clearandTimeline.destroywill now destroy any currently active Tweens that the Timeline had created. Previously, active tweens would continue to play to completion (thanks @monteiz) TimelineEventhas 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
requestVideoFramepolyfill has been updated to the latest release, which should resolve some SSR framework issues. Fix #6776 (thanks @lantictac) ScaleManagerlisteners includes checks for thescreen.orientationobject and adds/removes achangeeventListener method to handle screen orientation changes on mobile devices. Theorientationchangeevent is still maintained for backwards compatibility. Fix #6837 (thanks @rexrainbow)- When creating a new
TileSprite, setting eitherwidthorheightto0results in both values being set to thedisplayFrame.widthanddisplayFrame.height. The updated logic now checks forwidthandheightseparately. Ifwidthis0, it is set todisplayFrame.width. Ifheightis0, it is set todisplayFrame.height. Fix #6857 (thanks @GaryStanton) - Updated
GetBitmapTextSizewith improvedmaxWidthcalculations for wrapped text. Vector3.subVectorsis 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.setStylemethod will no longer mutate the givenstyleobject if it includes a numericfontSizevalue. Fix #6863 (thanks @stormpanda) - Calling the
Shape.Ellipse.setSizemethod will internally callupdateDisplayOriginto retain position after a size change. - The
BitmapText BatchCharfunction now inlines all of the matrix math, avoiding 16 function calls per character rendered.
Bug Fixes
- The
activePointersgame config option is now the correct amount of touch input pointers set. Fix #6783 (thanks @samme) - The method
TextureManager.checkKeywill now returnfalseif 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
EXPANDscale 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 forcirclebodies prevents the bodies from being pushed. Fix #5617 (thanks @kainage) - Calling
addDeathZone()on a particle emitter Game Object had a bug where theDeathZoneused world position coordinates.DeathZonenow 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.isPlayingis 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.dispatchContextLostis 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.dispatchContextRestoreis 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.setContextHandlersis a new internal method with 2 optional parameters:contextLostandcontextRestored. These allow you to overwrite the defaultcontextLostHandlerandcontextRestoreHandlerhandlers. (thanks @yaustar)Phaser.Textures.Frame#setCutPositionis a new internal method with 2 optional parameters:xandy. These sets the x and y position within the source image to cut from.Phaser.Textures.Frame#setCutSizeis a new internal method with 2 parameters:widthandheight. 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_SECONDARYandPORTRAIT_SECONDARYhave been added to thePhaser.Scale.Orientationobject. 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.updateexpanded:sourceparameter is now type?object, so it can be used for anything that is valid in the constructor.- New
formatparameter can update the texture format.
Updates
- Calling
Timeline.pausewill now pause any currently active Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.resumewill now resume any currently paused Tweens that the Timeline had started (thanks @monteiz) - Calling
Timeline.clearandTimeline.destroywill now destroy any currently active Tweens that the Timeline had created. Previously, active tweens would continue to play to completion (thanks @monteiz) TimelineEventhas 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
requestVideoFramepolyfill has been updated to the latest release, which should resolve some SSR framework issues. Fix #6776 (thanks @lantictac) ScaleManagerlisteners includes checks for thescreen.orientationobject and adds/removes achangeeventListener method to handle screen orientation changes on mobile devices. Theorientationchangeevent is still maintained for backwards compatibility. Fix #6837 (thanks @rexrainbow)
Bug Fixes
- The
activePointersgame config option is now the correct amount of touch input pointers set. Fix #6783 (thanks @samme) - The method
TextureManager.checkKeywill now returnfalseif 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
EXPANDscale 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 forcirclebodies prevents the bodies from being pushed. Fix #5617 (thanks @kainage) - Calling
addDeathZone()on a particle emitter Game Object had a bug where theDeathZoneused world position coordinates.DeathZonenow uses local position coordinates following the particle emitter position. Fix #6371 (thanks @vforsh) - Updated the
GetLineToLinemethod inGetLineToLine.jsto handle the case wheredx1ordy1values is zero. This ensures the function correctly returnsnullin 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.jswhere an extra empty line was added whensetMaxWidthwas called, and the width of the line was less than a word. Previously,yAdvancewas incorrectly incremented bylineHeight + lineSpacingfor each word, leading to an unintended increase in vertical space. The correction now calculatesyAdvancebased on thecurrentLineindex, ensuring that vertical spacing accurately reflects the number of lines. Fix #6807 (thanks @AlvaroNeuronup)
Input Bug Fixes
- The method
pointer.leftButtonReleasedwill now returntruewhen multiple mouse buttons are being pressed. - The method
pointer.rightButtonReleasedwill now returntruewhen multiple mouse buttons are being pressed. - The method
pointer.middleButtonReleasedwill now returntruewhen multiple mouse buttons are being pressed. - The method
pointer.backButtonReleasedwill now returntruewhen multiple mouse buttons are being pressed. - The method
pointer.forwardButtonReleasedwill now returntruewhen 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.Mapand replacing it with a regular JSMapinstance. This means methods likecontainsandsetAllwill be gone. - We are removing
Phaser.Struct.Setand replacing it with a regular JSSetinstance. This means methods likeiterateLocalwill be gone. - The
Create.GenerateTexture, all of the Create Palettes and thecreatefolder will be removed. - The
phaser-ie9.jsentry-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
RenderTexturecrashing 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.setFlipYalways updates the texture. - Remove unsynced
flipYfrom render textures inShaderandDynamicTexture. - Reverted a change made in
TouchManagerthat would prevent clicks from outside the game window from being registered. Fix #6747 (thanks @ulsoftnaver @jaxtheking)
Updates
- Modified
onMouseUpWindowandonMouseDownWindowin theMouseManagerso they now check forsourceCapabilities.firesTouchEventsand 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.base64is a new read-only boolean property that is set if the file contains a Data URI encoded string.Loader.File.onBase64Loadis a new method that is called when the file has finished decoding from a Data URI.- The
ImageFilewill now default to using the Image Load Element if a base64 file is detected, instead of throwing a console warning about unsupported types. - The
XHRLoaderwill 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.setSnapis 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#snapWidthandConfig#snapHeightare new properties in the Game Config that hold the parsedsnapconfig 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.createFromTilesmethod has been updated. It will now copy the following properties, if set in the Tile, to the Sprites it creates:rotation,flipX,flipY,alpha,visibleandtint. If these properties are declared in thespriteConfigpassed to the method, those will be used instead, otherwise the Tile values are used. Fix #6711 (thanks @Nerodon) - The
Tilemap.createFromTilesmethod has a new property calleduseSpriteSheet. If this is set totrueand 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 anoriginin the spriteConfig, it will adjust the sprite positions by half the tile size, to position them accurately on the map. Texture#getFrameBoundsis 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.RectangleLikeis a new typedef that defines a rectangle-like object with publicx,y,widthandheightproperties.
WebGL Renderer Updates
- Fix MIPmap filters being effectively disabled for compressed textures.
WebGLRenderer.getCompressedTexturescan 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
S3TCRGBtoS3TCSRGBinWebGLTextureCompression,CompressedTextureFileConfig, andFileConfigtypedefs. - Fix generating spritesheets from members of texture atlases based on compressed textures (thanks @vladyslavfolkuian)
- The
BloomFXandBlurFXand any custom pipeline that relies on using theUtilityPipelinefull or half frame targets will now correctly draw even after the renderer size changes. Fix #6677 (thanks @Nerodon) - The
PostFXPipeline.postBatchmethod 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
mipmapFilterset. Fix #6721 (thanks @SaintFlow and @rexrainbow) - The
UtilityPipelinenow setsautoResizetotruein its Render Target Config, so that the globalfullFrameandhalfFrameRender Targets will automatically resize if the renderer changes. WebGLPipeline.resizeUniformis a new property that is defined in theWebGLPipelineConfig. This is a string that defines auResolutionproperty, 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
preUpdateautomatically when theplaymethod 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.setSlotAlphais a new method that allows you to set the alpha on a specific slot in a Spine skeleton.- The
SpineGameObject.setAlphamethod 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 newsetSlotAlphamethod instead. Fix #6571 (thanks @spayton) - The
SpineFile.onFileCompletehandler was running a regular expression againstfile.srcinstead 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)
Meshbased Game Objects now can use an input config with thesetInteractivemethod, which supports the optionsdraggable,dropzone,cursoranduserHandCursor. Fix #6510 #6652 (thanks @Baegus @Neppord)- The touch event handler
onTouchEndWindownow stops pointer events when clicking through DOM elements to input. Fix #6697 (thanks @laineus) - The
Input.InputPluginmethoddisablewhich is called byGameObjects.GameObject#disableInteractivekeeps its temp hit box value which stops propagation to interactive Game Objects in another scene. Fix #6601 (thanks @UnaiNeuronUp) - Using
setInteractiveandremoveInteractivemethods of a Game Object outside of the game loop would cause an error in whichInput.InputManager#resetCursorwould lose input context. Fix #6387 (thanks @TomorrowToday)
Updates
- The
TweenChainBuilderwas incorrectly setting thepersistflag 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
droppedargument has now been added to the documentation for theDRAG_ENDandGAMEOBJECT_DRAG_ENDevents. (thanks @samme) Container.onChildDestroyedis 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
TextandTileSpriteGame Objects now place their textures into the globalTextureManagerand a_textureKeyprivate string property has been added which contains a UUID to reference that texture. - The
Tilemaps.Components.WeightedRandomizemethod now uses the PhaserMath.RND.fracmethod with a seed instead ...
Phaser v3.80.0 Beta 2
Version 3.80.0 - Nino - in dev
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) - 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 Features - 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.base64is a new read-only boolean property that is set if the file contains a Data URI encoded string.Loader.File.onBase64Loadis a new method that is called when the file has finished decoding from a Data URI.- The
ImageFilewill now default to using the Image Load Element if a base64 file is detected, instead of throwing a console warning about unsupported types. - The
XHRLoaderwill 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.
Spine Updates
- The Spine 3 and 4.1 Plugins will now call
preUpdateautomatically when theplaymethod 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.setSlotAlphais a new method that allows you to set the alpha on a specific slot in a Spine skeleton.- The
SpineGameObject.setAlphamethod 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 newsetSlotAlphamethod instead. Fix #6571 (thanks @spayton) - The
SpineFile.onFileCompletehandler was running a regular expression againstfile.srcinstead offile.url, sometimes leading to double paths in the atlas paths on loading. Fix #6642 (thanks @rez23)
Updates
- The
TweenChainBuilderwas incorrectly setting thepersistflag 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
droppedargument has now been adeded to the documentation for theDRAG_ENDandGAMEOBJECT_DRAG_ENDevents. (thanks @samme) Container.onChildDestroyedis 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
TextandTileSpriteGame Objects now place their textures into the globalTextureManagerand a_textureKeyprivate string property has been added which contains a UUID to reference that texture. - The
Tilemaps.Components.WeightedRandomizemethod now uses the PhaserMath.RND.fracmethod with a seed instead of theMath.Randomstatic method. (thanks @jorbascrumps) Tilemaps.Components.IsometricCullTilesdoes theCheckIsoBoundsmethod check last when building the outputArray, as to help optimize in situations where the tile would not be visible anyways. (thanks @zegenie)Tilemaps.Components.WeightedRandomizenow uses the PhaserMath.RND.fracmethod with a seed instead theMath.Randomstatic method. (thanks @jorbascrumps)- The
LayerGame Object has had itsremoveAll,removeandaddmethods removed. These methods are all still available via theListclass that Layer inherits, but thedestroyChildparameters are no longer available. - The
Renderer.CanvasandRenderer.WebGLwill now only be included in the build file if the corresponding feature flagsCANVAS_RENDERERand/orWEBGL_RENDERERare set totrue. For Canvas only builds this saves a lot of space in the build. (thanks @samme) - You can now specify an
autoResizeboolean in theRenderTargetConfigwhich is passed to the Render Targets when they are created by a pipeline. - The
UtilityPipelinenow setsautoResizetotruein its Render Target Config, so that the globalfullFrameandhalfFrameRender Targets will automatically resize if the renderer changes. Actions.PlaceOnLinenow has an addedeaseparameter which accepts a string from the EaseMap or a custom ease function to allow for different distrubutions along a line. (thanks @sB3p)- 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)
- The
XHRLoaderwill now listen forontimeoutand if triggered it will hand over to theFile.onErrorhandler. This prevents the Loader from stalling if a file times out. Fix #6472 (thanks @343dev) LightPipeline.currentNormalMapwas incorrectly documented as being a property ofWebGLRenderer.Meshbased Game Objects now can use an input config with thesetInteractivemethod, which supports the optionsdraggable,dropzone,cursoranduserHandCursor. Fix #6510 #6652 (thanks @Baegus @Neppord)
Bug Fixes
- The
InputManager.onTouchMovefunction has been fixed so it now correctly handles touch events on pages that have scrolled horizontally or vertically and shifted the viewport. Fix #6489 (thanks @somechris @hyewonjo) Factory.staticBodyhad the wrong return type in the docs/TS defs. Fix #6693 (thanks @ddhaiby)- The
Time.Timelineclass didn't show as extending the Event Emitter, or haveconfigas an optional argument in the docs / TS defs. Fix #6673 (thanks @ghclark2) - The
Animations.AnimationFramememberdurationis now the complete duration of the frame, which is a breaking change. Before thisAnimations.AnimationState#msPerFramewas combined withAnimations.AnimationFrame#durationwhich wasn't intuitive. The fix to removeAnimations.AnimationState#msPerFramefromAnimations.AnimationFrame#durationhas been removed from theAnimations.AnimationManagermethodcreateFromAsepritebecause of this clarification. Fix #6712 (thanks @Nerodon @TomMalitz) - The
NineSliceGame Object methodsetSizenow recalculates its origin by calling theupdateDisplayOriginmethod. (thanks @dhashvir) - When a
LayerGame Object is destroyed, i.e. from changing or restarting a Scene, it will no longer cause an error when trying to destroy the children on its display list. Fix #6675 (thanks @crockergd @gm0nk) DynamicTexturewill now automatically callsetSize(width, height)for both WebGL and Canvas. Previously it only did it for WebGL. This fixes an issue where DynamicTextures in Canvas mode would have a width and height of -1. Fix #6682 (thanks @samme)DynamicTexture.setSizewill now check to see if theglTexturebound to the current frame is stale, and if so, destroy it before binding the one from the Render Target. This fixes an issue where constantly destroying and creating Dynamic Textures would cause a memory leak in WebGL. Fix #6669 (thanks @DavidTalevski)- The
BloomFXandBlurFXand any custom pipeline that relies on using theUtilityPipelinefull or half frame targets will now correctly draw even after the renderer size changes. Fix #6677 (thanks @Nerodon) - The
PostFXPipeline.postBatchmethod will now skiponDrawif the pipeline hasn't booted, introducing an artificial frame skip. This should potentially fix glitch errors on mobile devices where Post FX would appear corrupted for a single frame. Fix #6681 (thanks @moufmouf @tongliang999) - The
Matter.Bodyfunctionscalehas been updated so if the Body originally had aninertiaofInfinitythis will be restored at the end of the call. This happens if you set a Matter Body to have fixed rotation. Fix #6369 (thanks @sushovande) - Modified the
RandomDataGenerator.weightedPickmethod to avoid sampling past the last element. Fix #6701 (thanks @jameskirkwood) - The touch event handler
onTouchEndWindownow stops pointer events when clicking through DOM elements to input. Fix #6697 (thanks @laineus) - The
Physics.Matter.FactorymethodpointerConstraintno longer returns an error when it can't find the camera. Fix #6684 (thanks @spritus) - The
Physics.Arcade.StaticBodymethodresetnow re-appliesoffsetvalues. Fix #6729 (thanks @samme) - The
Input.InputPluginmethoddisablewhich is called byGameObjects.GameObject#disableInteractivekeeps its temp hit box value which stops propagation to interactive Game Objects in another scene. Fix #6601 (thanks @UnaiNeuronUp) - Using
setInteractiveandremoveInteractivemethods of a Game Object outside of the game loop w...
Phaser v3.80.0 Beta 1
Version 3.80.0 - Nino - in dev
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) - 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 Features - 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.base64is a new read-only boolean property that is set if the file contains a Data URI encoded string.Loader.File.onBase64Loadis a new method that is called when the file has finished decoding from a Data URI.- The
ImageFilewill now default to using the Image Load Element if a base64 file is detected, instead of throwing a console warning about unsupported types. - The
XHRLoaderwill 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.
Spine Updates
- The Spine 3 and 4.1 Plugins will now call
preUpdateautomatically when theplaymethod 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.setSlotAlphais a new method that allows you to set the alpha on a specific slot in a Spine skeleton.- The
SpineGameObject.setAlphamethod 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 newsetSlotAlphamethod instead. Fix #6571 (thanks @spayton) - The
SpineFile.onFileCompletehandler was running a regular expression againstfile.srcinstead offile.url, sometimes leading to double paths in the atlas paths on loading. Fix #6642 (thanks @rez23)
Updates
- The
TweenChainBuilderwas incorrectly setting thepersistflag 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
droppedargument has now been adeded to the documentation for theDRAG_ENDandGAMEOBJECT_DRAG_ENDevents. (thanks @samme) Container.onChildDestroyedis 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
TextandTileSpriteGame Objects now place their textures into the globalTextureManagerand a_textureKeyprivate string property has been added which contains a UUID to reference that texture. - The
Tilemaps.Components.WeightedRandomizemethod now uses the PhaserMath.RND.fracmethod with a seed instead of theMath.Randomstatic method. (thanks @jorbascrumps) Tilemaps.Components.IsometricCullTilesdoes theCheckIsoBoundsmethod check last when building the outputArray, as to help optimize in situations where the tile would not be visible anyways. (thanks @zegenie)Tilemaps.Components.WeightedRandomizenow uses the PhaserMath.RND.fracmethod with a seed instead theMath.Randomstatic method. (thanks @jorbascrumps)- The
LayerGame Object has had itsremoveAll,removeandaddmethods removed. These methods are all still available via theListclass that Layer inherits, but thedestroyChildparameters are no longer available. - The
Renderer.CanvasandRenderer.WebGLwill now only be included in the build file if the corresponding feature flagsCANVAS_RENDERERand/orWEBGL_RENDERERare set totrue. For Canvas only builds this saves a lot of space in the build. (thanks @samme) - You can now specify an
autoResizeboolean in theRenderTargetConfigwhich is passed to the Render Targets when they are created by a pipeline. - The
UtilityPipelinenow setsautoResizetotruein its Render Target Config, so that the globalfullFrameandhalfFrameRender Targets will automatically resize if the renderer changes. Actions.PlaceOnLinenow has an addedeaseparameter which accepts a string from the EaseMap or a custom ease function to allow for different distrubutions along a line. (thanks @sB3p)- 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)
- The
XHRLoaderwill now listen forontimeoutand if triggered it will hand over to theFile.onErrorhandler. This prevents the Loader from stalling if a file times out. Fix #6472 (thanks @343dev)
Bug Fixes
- The
InputManager.onTouchMovefunction has been fixed so it now correctly handles touch events on pages that have scrolled horizontally or vertically and shifted the viewport. Fix #6489 (thanks @somechris @hyewonjo) Factory.staticBodyhad the wrong return type in the docs/TS defs. Fix #6693 (thanks @ddhaiby)- The
Time.Timelineclass didn't show as extending the Event Emitter, or haveconfigas an optional argument in the docs / TS defs. Fix #6673 (thanks @ghclark2) - The
Animations.AnimationFramememberdurationis now the complete duration of the frame, which is a breaking change. Before thisAnimations.AnimationState#msPerFramewas combined withAnimations.AnimationFrame#durationwhich wasn't intuitive. The fix to removeAnimations.AnimationState#msPerFramefromAnimations.AnimationFrame#durationhas been removed from theAnimations.AnimationManagermethodcreateFromAsepritebecause of this clarification. Fix #6712 (thanks @Nerodon @TomMalitz) - The
NineSliceGame Object methodsetSizenow recalculates its origin by calling theupdateDisplayOriginmethod. (thanks @dhashvir) - When a
LayerGame Object is destroyed, i.e. from changing or restarting a Scene, it will no longer cause an error when trying to destroy the children on its display list. Fix #6675 (thanks @crockergd @gm0nk) DynamicTexturewill now automatically callsetSize(width, height)for both WebGL and Canvas. Previously it only did it for WebGL. This fixes an issue where DynamicTextures in Canvas mode would have a width and height of -1. Fix #6682 (thanks @samme)DynamicTexture.setSizewill now check to see if theglTexturebound to the current frame is stale, and if so, destroy it before binding the one from the Render Target. This fixes an issue where constantly destroying and creating Dynamic Textures would cause a memory leak in WebGL. Fix #6669 (thanks @DavidTalevski)- The
BloomFXandBlurFXand any custom pipeline that relies on using theUtilityPipelinefull or half frame targets will now correctly draw even after the renderer size changes. Fix #6677 (thanks @Nerodon) - The
PostFXPipeline.postBatchmethod will now skiponDrawif the pipeline hasn't booted, introducing an artificial frame skip. This should potentially fix glitch errors on mobile devices where Post FX would appear corrupted for a single frame. Fix #6681 (thanks @moufmouf @tongliang999) - The
Matter.Bodyfunctionscalehas been updated so if the Body originally had aninertiaofInfinitythis will be restored at the end of the call. This happens if you set a Matter Body to have fixed rotation. Fix #6369 (thanks @sushovande) - Modified the
RandomDataGenerator.weightedPickmethod to avoid sampling past the last element. Fix #6701 (thanks @jameskirkwood) - The touch event handler
onTouchEndWindownow stops pointer events when clicking through DOM elements to input. Fix #6697 (thanks @laineus) - The
Physics.Matter.FactorymethodpointerConstraintno longer returns an error when it can't find the camera. Fix #6684 (thanks @spritus)
Examples, Documentation, Beta Testing and TypeScript
My thanks to the following for helping with the Phaser 3 Examples, Beta Testing, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:
@AlvaroEstradaDev
@stevenwithaph
@paxperscientiam
@samme
@actionmoon
@rafael-lua
@Byvire
Phaser v3.70.0
Version 3.70.0 - Yotsuba - 10th November 2023
New Features - Round Pixels
All pixel rounding math is now handled on the GPU instead of on the CPU. This feature has now been enabled by default.
- The Game Config
roundPixelsproperty is nowtrueby default. This means that all Game Objects will be positioned and rendered with pixel-perfect precision, which is by far the most common use-case for Phaser games. This will prevent sub-pixelation when rendering at non-integer offsets and allows for smoother camera scrolling, especially at higher zoom scales. If you wish to disable this, you can do so by setting theroundPixelsproperty in the Game Config tofalse. Note that onlyroundPixelshas been set totrue. ThepixelArtproperty remainsfalse. So if you're creating a pixel-art style game, please still enable this in your config. - All of the core vertex shaders, including Multi, Single and Mobile now have a new uniform called
uRoundPixelswhich is set in all of the corresponding pipelines. This means that all pixel rounding calculations are now done on the GPU instead of the CPU, which can save a lot of math in intensive games. CanvasRenderer.batchSpritehas been updated to correctly use the CameraroundPixelsproperty and apply it to thedrawImagecall.Camera.preRenderwill no longer round the origin, follow coordinates or scrollX/Y coordinates. It will still round the World view.- The
MultiPipeline.batchSpritemethod (which is also used by the Single Pipeline and Mobile Pipeline) will no longer useroundPixelswhen calculating the quad vertex data. It also won't apply it to any of the sprite values. This is all now handled in the shader directly. TransformMatrix.setQuadno longer uses an anonymous function forroundPixels, which will help with performance.- The
TransformMatrix.setQuadmethod signature has changed slightly. TheroundPixelsparameter is now optional and defaults tofalse. Previously, you always had to set it.
New Features - Texture Packer Nine Slice Support
The new version of Texture Packer (v7.1.0) and above will now allow you to export scale9 sprite data in your Phaser 3 Atlas JSON. This allows you to create Nine Slice Sprites directly from the data, without having to specify the border sizes directly in your code. To use this feature, simply edit the sprite in Texture Packer, enable the 'scale9' checkbox and then drag the guides as required. When you export the atlas, the JSON will contain the new scale9 object, which Phaser will parse and use when creating Nine Slice Game Objects.
- You can now create a
NineSliceGame Object without specifying a width or height for it. If you do this, it will use the size of the texture frame instead. - The
NineSliceGame Object will now check to see if its associated Frame has any scale9 data set, and if so this is now used automatically to populate all of the border values. - The
NineSlice.setSlicesmethod has a new optional boolean parameterskipScale9which will allow you to set the border values of the Nine Slice directly, even if its Frame has associated scale9 data Frame.setScale9is a new method that allows you to set the scale9 data associated with the given Frame. This is used internally by the Texture Packer parsers, but can also be called directly.Frame.scale9is a new read-only boolean property that returnstrueif the Frame has scale9 data associated with it.Frame.is3Sliceis a new read-only boolean property that returnstrueif the Frame has scale9 data associated with it that is 3-slice instead of 9-slice.- The
JSONHashtexture parser will now check forscale9data in the JSON and if found, set it via theFrame.setScale9method. - The
JSONArraytexture parser will now check forscale9data in the JSON and if found, set it via theFrame.setScale9method.
New Features - Arcade Physics
- Arcade Physics Bodies have a new method called
setDirectControlwhich toggles a new boolean propertydirectControl. When enabled (it's false by default) it means the Body will calculate its velocity based on its change in position compared to the previous frame. This allows you to directly move a Body around the physics world by just changing its position, without having to use acceleration or velocity. This is useful if you want to move it via a Tween, or follow a Pointer, or a Path. Because its velocity is calculated based on this movement it will still resolve collisions with other bodies, imparting velocity to them as usual. - Arcade Physics Bodies have a new property called
slideFactor. This is a Vector2 that controls how much velocity is retained by a Body after it has been pushed by another Body. The default value is 1, which means it retains all of its velocity. If set to zero, it will retain none of it. This allows you to create a Body that can be pushed around without imparting any velocity to it. Body.setSlideFactoris a new method that sets the Body'sslideFactorproperty.- The Arcade Physics World has a new method
nextCategorywhich will create a new collision category and return it. You can define up to 32 unique collision categories per world. - Arcade Physics Bodies have two new properties:
collisionCategoryandcollisionMask. These allow you to set a specific collision category and list of categories the body will collide with. This allows for fine-grained control over which bodies collide with which others. The default is that all bodies collide with all others, just like before. setCollisionCategoryis a new method available on Arcade Physics Bodies that allows you to set the collision category of the body. It's also available on Arcade Sprites, Images, Tilemap Layers, Groups and Static Groups directly.setCollidesWithis a new method available on Arcade Physics Bodies that allows you to set which collision categories the body should collide with. It's also available on Arcade Sprites, Images, Tilemap Layers, Groups and Static Groups directly.resetCollisionis a new method available on Arcade Physics Bodies that allows you to reset the collision category and mask to their defaults. It's also available on Arcade Sprites, Images, Tilemap Layers, Groups and Static Groups directly.
The default is as before: all bodies collide with each other. However, by using the categories you now have much more fine-grained control over which objects collide together, or not. They are filtered out at the top-level, meaning you can have a Sprite set to not collide with a Physics Group and it will skip checking every single child in the Group, potentially saving a lot of processing time.
The new collision categories are used automatically by either directly calling the collide or overlap methods, or by creating a Collider object. This allows you to use far less colliders than you may have needed previously and skip needing to filter the pairs in the collision handlers.
New Features - FX Updates and Fixes
You can now set in your game config two new boolean properties that control if the built-in FX are enabled, or not. If you don't need to use the FX then disabling these will help save on texture memory and will compile less shaders, which can help with startup time. These are single-set flags, you cannot toggle them after the game has booted.
disablePreFXset this totruein your game config to disable the creation and use of Pre FX on all Game Objects.disablePostFXset this totruein your game config to disable the creation and use of Post FX on all Game Objects.- The
PipelineManagerwill now delay the creation of the FX Pipelines until itsbootmethod, using these config values to determine if it should proceed. - The
PipelineManager.renderTargetsarray will no longer be pre-populated if you disable Pre FX, saving on texture memory. FX.Circle.backgroundAlphais a new property that allows you to set the amount of the alpha of the background color in the Circle FX (thanks @rexrainbow)PostFXPipeline.bootFXis a new method, which is the previousbootmethod but renamed. This is no longer called from the constructor, but instead when the Post FX Pipeline is activated by the Pipeline Manager. This means that the resources the Post FX requires, such as creating Render Targets and shaders, is delayed until the FX is actually used, saving on memory.- The
PostFXPipelinewill now setautoResizetotrueon all of itsRenderTargetinstances. This fixes an issue where thePostFXPipelinewould not resize the render targets when the game size changed, causing them to become out of sync with the game canvas. Fix #6503 (thanks @Waclaw-I) FX.Blurdidn't set thequalityparameter to its property, meaning it wasn't applied in the shader, causing it to always use a Low Blur quality (unless modified post-creation).- The
BlurFXPipelinedidn't bind the quality of shader specified in the controller, meaning it always used the Low Blur shader, regardless of what the FX controller asked for. - The
FXBlurLowfragment shader didn't have theoffsetuniform. This is now passed in and applied to the resulting blur, preventing it from creating 45 degree artifacts (thanks Wayfinder) - Fixed an issue in the way the Tilemap WebGL Renderer would call
batchTexturethat meant if you applied a PostFX to a Tilemap Layer it would apply the fx for every single tile in the layer, instead of just once per layer. In a simple map this fix has reduced draw calls from over 12,000 to just 52, and it no longer matters how many tiles are on the layer, the cost of applying the FX is consistent regardless.
New Features
Text.setRTLis a new method that allows you to set a Text Game Object as being rendered from right-to-left, instead of the default left to right (thanks @rexrainbow)Physics.Arcade.World.singleStepis a new method that wil...