Phaser/phaser: Release v3.85.0-beta.2
Name: phaser
Owner: Phaser
Release: Phaser v3.85.0 Beta 2
Released: 2024-07-23
License: MIT
Release Assets:
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) - Updated the
GetLineToLinemethod inGetLineToLineto 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)
- Fixed
Matter.Worldbug wheregroup.lengthreturnsundefined. Changed togroup.getLength()to correctly return number of children in a group. - Fixed Group vs Group collisions failing when performing a bitwise
&operation betweenbody1.collisionMaskandbody2.collisionCategory. The defaultcollisionMaskvalue is changed to2147483647to correctly match anycollisionCategory. Fix #6764 (thanks @codeimpossible) - Resolved an issue in
BitmapTextwhere adding a space character' 'at the end of a line did not correctly align the vertical position of the new line. The updated calculation now correctly accounts for both line height and line spacing. Fix #6717 (thanks @wooseok123) - Resolved an issue in
BitmapTextwhere 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) - Resolved an issue in
BitmapTextwhere adding a space character' 'at the end of a line caused the following line of to ignore line wrapping when usingsetMaxWidth. Fix #6860 (thanks @bagyoni) - The
Matrix4.lookAtRHmethod would fail because it called two missing Vector3 methods. - The
RenderTargetwill now automatically listen for the Renderer resize event ifautoResizeis true. This fixes an issue with Bitmap Masks where they wouldn't resize if the renderer resized. Fix #6769 (thanks @pavels) - The
Texture.getFrameBoundsmethod will now include the BASE texture in its calculations. This prevents it from returning a size of Infinity. This fixes an issue where a Tileset with margin/spacing loaded viaload.spritesheetinstead ofload.imagewould have its margin and spacing ignored. Fix #6823 (thanks @damian-pastorini)
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. - The Spine 3 and Spine 4 plugins will no longer be updated. You should now use the official Phaser Spine plugin created by Esoteric Software.