Due to the massive amount of changes in 3.50 this Change Log is, by its nature, very long. It's important to scan through it, especially if you're porting a game from an earlier version of Phaser to 3.50. However, if you're after more top-level descriptions of what's new, with example code, then please see the posts we will be making to the Phaser site and Phaser Patreon in the coming months after release. We have also updated the Phaser 3 Examples site, so that every single example up there has been rewritten for 3.50, so you don't have to struggle working through old or deprecated syntax. Virtually all new features are covered in new examples, as well.
With that said, we've tried to organize the Change Log into commonly themed sections to make it more digestible, but we appreciate there is a lot here. Please don't feel overwhelmed! If you need clarification about something, join us on the Phaser Discord and feel free to ask.
WebGL Pipelines are responsible for the rendering of all Game Objects in Phaser and they have had a complete rewrite in 3.50. This was to allow for the introduction of post processing pipelines, now readily available to be created from the new Post FX Pipeline class. The changes in this area have been extensive, so if you use custom WebGL Pipelines in your game already, you must update your code to use Phaser 3.50.
The WebGL.PipelineManager is a new class that is responsible for managing all of the WebGL Pipelines in Phaser. An instance of the Pipeline Manager is created by the WebGL Renderer and is available under the pipelines property. This means that the WebGL Renderer no longer handles pipelines directly, causing the following API changes:
WebGLRenderer.pipelinesis no longer a plain object containing pipeline instances. It's now an instance of thePipelineManagerclass. This instance is created during the init and boot phase of the renderer.- The
WebGLRenderer.currentPipelineproperty no longer exists, instead usePipelineManager.current. - The
WebGLRenderer.previousPipelineproperty no longer exists, instead usePipelineManager.previous. - The
WebGLRenderer.hasPipelinemethod no longer exists, instead usePipelineManager.has. - The
WebGLRenderer.getPipelinemethod no longer exists, instead usePipelineManager.get. - The
WebGLRenderer.removePipelinemethod no longer exists, instead usePipelineManager.remove. - The
WebGLRenderer.addPipelinemethod no longer exists, instead usePipelineManager.add. - The
WebGLRenderer.setPipelinemethod no longer exists, instead usePipelineManager.set. - The
WebGLRenderer.rebindPipelinemethod no longer exists, instead usePipelineManager.rebind. - The
WebGLRenderer.clearPipelinemethod no longer exists, instead usePipelineManager.clear.
The Pipeline Manager also offers the following new features:
- The
PipelineManager.resizemethod automatically handles resize events across all pipelines. - The
PipelineManager.preRendermethod calls the pre-render method of all pipelines. - The
PipelineManager.rendermethod calls the render method of all pipelines. - The
PipelineManager.postRendermethod calls the post-render method of all pipelines. - The
PipelineManager.setMultimethod automatically binds the Multi Texture Pipeline, Phasers default. - The
PipelineManager.clearmethod will clear the pipeline, store it inpreviousand free the renderer. - The
PipelineManager.rebindmethod will reset the rendering context and restore thepreviouspipeline, if set. - The
PipelineManager.copyFramemethod will copy asourceRender Target to thetargetRender Target, optionally setting the brightness of the copy. - The
PipelineManager.blitFramemethod will copy asourceRender Target to thetargetRender Target. UnlikecopyFrameno resizing takes place and you can optionally set the brightness and erase mode of the copy. - The
PipelineManager.copyFrameRectmethod binds thesourceRender Target and then copies a section of it to thetargetusinggl.copyTexSubImage2Drather than a shader, making it much faster if you don't need blending or preserving alpha details. - The
PipelineManager.copyToGamemethod pops the framebuffer from the renderers FBO stack and sets that as the active target, then draws thesourceRender Target to it. Use when you need to render the final result to the game canvas. - The
PipelineManager.drawFramemethod will copy asourceRender Target, optionally to atargetRender Target, using the given ColorMatrix, allowing for full control over the luminance values used during the copy. - The
PipelineManager.blendFramesmethod draws thesource1andsource2Render Targets to thetargetRender Target using a linear blend effect, which is controlled by thestrengthparameter. - The
PipelineManager.blendFramesAdditivemethod draws thesource1andsource2Render Targets to thetargetRender Target using an additive blend effect, which is controlled by thestrengthparameter. - The
PipelineManager.clearFramemethod clears the given Render Target.
New constants have been created to help you reference a pipeline without needing to use strings:
Phaser.Renderer.WebGL.Pipelines.BITMAPMASK_PIPELINEfor the Bitmap Mask Pipeline.Phaser.Renderer.WebGL.Pipelines.LIGHT_PIPELINEfor the Light 2D Pipeline.Phaser.Renderer.WebGL.Pipelines.SINGLE_PIPELINEfor the Single Pipeline.Phaser.Renderer.WebGL.Pipelines.MULTI_PIPELINEfor the Multi Pipeline.Phaser.Renderer.WebGL.Pipelines.ROPE_PIPELINEfor the Rope Pipeline.Phaser.Renderer.WebGL.Pipelines.POINTLIGHT_PIPELINEfor the Point Light Pipeline.Phaser.Renderer.WebGL.Pipelines.POSTFX_PIPELINEfor the Post FX Pipeline.Phaser.Renderer.WebGL.Pipelines.UTILITY_PIPELINEfor the Utility Pipeline.
All Game Objects have been updated to use the new constants and Pipeline Manager.
The Post FX Pipeline is a brand new and special kind of pipeline specifically for handling post processing effects in Phaser 3.50.
Where-as a standard Pipeline allows you to control the process of rendering Game Objects by configuring the shaders and attributes used to draw them, a Post FX Pipeline is designed to allow you to apply processing after the Game Object/s have been rendered.
Typical examples of post processing effects are bloom filters, blurs, light effects and color manipulation.
The pipeline works by creating a tiny vertex buffer with just one single hard-coded quad in it. Game Objects can have a Post Pipeline set on them, which becomes their own unique pipeline instance. Those objects are then rendered using their standard pipeline, but are redirected to the Render Targets owned by the post pipeline, which can then apply their own shaders and effects, before passing them back to the main renderer.
The following properties and methods are available in the new PostFXPipeline class:
- The
PostFXPipeline.gameObjectproperty is a reference to the Game Object that owns the Post Pipeline, if any. - The
PostFXPipeline.colorMatrixproperty is a Color Matrix instance used by the draw shader. - The
PostFXPipeline.fullFrame1property is a reference to thefullFrame1Render Target that belongs to the Utility Pipeline, as it's commonly used in post processing. - The
PostFXPipeline.fullFrame2property is a reference to thefullFrame2Render Target that belongs to the Utility Pipeline, as it's commonly used in post processing. - The
PostFXPipeline.halfFrame1property is a reference to thehalfFrame1Render Target that belongs to the Utility Pipeline, as it's commonly used in post processing. - The
PostFXPipeline.halfFrame2property is a reference to thehalfFrame2Render Target that belongs to the Utility Pipeline, as it's commonly used in post processing. - The
PostFXPipeline.copyFramemethod will copy asourceRender Target to thetargetRender Target, optionally setting the brightness of the copy. - The
PostFXPipeline.blitFramemethod will copy asourceRender Target to thetargetRender Target. UnlikecopyFrameno resizing takes place and you can optionally set the brightness and erase mode of the copy. - The
PostFXPipeline.copyFrameRectmethod binds thesourceRender Target and then copies a section of it to thetargetusinggl.copyTexSubImage2Drather than a shader, making it much faster if you don't need blending or preserving alpha details. - The
PostFXPipeline.copyToGamemethod pops the framebuffer from the renderers FBO stack and sets that as the active target, then draws thesourceRender Target to it. Use when you need to render the final result to the game canvas. - The
PostFXPipeline.drawFramemethod will copy asourceRender Target, optionally to atargetRender Target, using the given ColorMatrix, allowing for full control over the luminance values used during the copy. - The
PostFXPipeline.blendFramesmethod draws thesource1andsource2Render Targets to thetargetRender Target using a linear blend effect, which is controlled by thestrengthparameter. - The
PostFXPipeline.blendFramesAdditivemethod draws thesource1andsource2Render Targets to thetargetRender Target using an additive blend effect, which is controlled by thestrengthparameter. - The
PostFXPipeline.clearFramemethod clears the given Render Target. - The
PostFXPipeline.bindAndDrawmethod binds this pipeline and draws thesourceRender Target to thetargetRender Target. This is typically the final step taken in when post processing.
Due to the huge amount of work that has taken place in this area, all of the pipelines have been renamed. If you extend any of these pipelines or use them in your game code (referenced by name), then please update accordingly. The name changes are:
TextureTintPipelineis now called theMultiPipeline.TextureTintStripPipelineis now called theRopePipeline.ForwardDiffuseLightPipelineis now called theLightPipeline.
There is also the new GraphicsPipeline. Previously, the TextureTintPipeline was responsible for rendering all Sprites, Graphics, and Shape objects. Now, it only renders Sprites. All Graphics and Shapes are handled by the new GraphicsPipeline, which uses its own shaders. See below for details about this change.
To match the new pipeline names, the shader source code has also been renamed.
ForwardDiffuse.fragis now calledLight.frag.TextureTint.fragis now calledMulti.frag.TextureTint.vertis now calledMulti.vert.
Further pipeline changes are as follows:
- None of the shaders or pipelines use the
uViewMatrixanduModelMatrixuniforms any longer. These were always just plain identity matrices, so there is no point spending CPU and GPU time to set them as uniforms or use them in the shaders. Should you need these uniforms, you can add them to your own custom pipelines. Types.Renderer.WebGL.WebGLPipelineConfigis a new TypeDef that helps you easily configure your own Custom Pipeline when using TypeScript and also provides better JSDocs.Types.Renderer.WebGL.WebGLPipelineAttributesConfigis a new TypeDef that helps you easily configure the attributes for your own Custom Pipelines when using TypeScript and also provides better JSDocs.- All pipelines will now work out the
rendererproperty automatically, so it's no longer required in the config. - All pipelines will now work out the
glproperty automatically, so it's no longer required in the config. - All pipelines will now extract the
nameproperty from the config, allowing you to set it externally. - All pipelines will now extract the
vertexCapacityproperty from the config, allowing you to set it externally. - All pipelines will now extract the
vertexSizeproperty from the config, allowing you to set it externally. - All pipelines will now extract the
vertexDataproperty from the config, allowing you to set it externally. - All pipelines will now extract the
attributesproperty from the config, allowing you to set it externally. - All pipelines will now extract the
topologyproperty from the config, allowing you to set it externally. - The
WebGLPipeline.shouldFlushmethod now accepts an optional parameteramount. If given, it will returntrueif the amount to be added to the vertex count exceeds the vertex capacity. The Multi Pipeline has been updated to now use this method instead of performing the comparison multiple times itself. - The
RopePipelinenow extendsMultiPipelineand just changes the topology, vastly reducing the file size. - The
WebGLPipeline.flushLockedproperty has been removed. A pipeline can never flush in the middle of a flush anyway, so it was just wasting CPU cycles being set. WebGLPipeline.manageris a new property that is a reference to the WebGL Pipeline Manager.WebGLPipeline.currentUnitis a new property that holds the most recently assigned texture unit. Treat as read-only.WebGLPipeline.forceZerois a new boolean property that sets if the pipeline should force the use of texture zero.WebGLPipeline.hasBootedis a new boolean property that is set once the pipeline has finished setting itself up and has booted.WebGLPipeline.isPostFXis a new boolean property that is only set by Post FX Pipelines to help identify them.WebGLPipeline.renderTargetsis a new property that holds an array of WebGL Render Targets belonging to the pipeline.WebGLPipeline.currentRenderTargetis a new property that holds a reference to the currently bound Render Target.WebGLPipeline.shadersis a new property that holds an array of all WebGLShader instances that belong to the pipeline.WebGLPipeline.currentShaderis a new property that holds a reference to the currently active shader within the pipeline.WebGLPipeline.configis a new property that holds the pipeline configuration object used to create it.WebGLPipeline.projectionMatrixis a new property that holds a Matrix4 used as the projection matrix for the pipeline.WebGLPipeline.setProjectionMatrixis a new method that allows you to set the ortho projection matrix of the pipeline.WebGLPipeline.bootwill now check all of the attributes and store the pointer location within the attribute entry.WebGLPipeline.bindno longer looks-up and enables every attribute, every frame. Instead, it uses the cached pointer location stored in the attribute entry, cutting down on redundant WebGL operations.WebGLPipeline.setAttribPointersis a new method that will set the vertex attribute pointers for the pipeline.WebGLPipeline.setShaderis a new method that allows you to set the currently active shader within the pipeline.WebGLPipeline.getShaderByNameis a new method that allows you to get a shader from the pipeline based on its name.WebGLPipeline.setShadersFromConfigis a new method that destroys all current shaders and creates brand new ones parsed from the given config object. This is part of the pipeline boot process, but also exposed should you need to call it directly.WebGLPipeline.setGameObjectis a new method that custom pipelines can use in order to perform pre-batch tasks for the given Game Object.WebGLPipeline.setVertexBufferis a new method that checks if the pipelines vertex buffer is active, or not, and if not, binds it as the active buffer. This used to be performed by the WebGL Renderer, but pipelines now manage this directly.WebGLPipeline.preBatchis a new method that is called when a new quad is about to be added to the batch. This is used by Post FX Pipelines to set frame buffers.WebGLPipeline.postBatchis a new method that is called after a quad has been added to the batch. This is used by Post FX Pipelines to apply post processing.WebGLPipeline.unbindis a new method that unbinds the current Render Target, if one is set.WebGLPipeline.batchVertis a new method that adds a single vertex to the vertex buffer and increments the count by 1.WebGLPipeline.batchQuadis a new method that adds a single quad (6 vertices) to the vertex buffer and increments the count, flushing first if adding the quad would exceed the batch limit.WebGLPipeline.batchTriis a new method that adds a single tri (3 vertices) to the vertex buffer and increments the count, flushing first if adding the tri would exceed the batch limit.WebGLPipeline.drawFillRectis a new method that pushes a filled rectangle into the vertex batch.WebGLPipeline.setTexture2Dis a new method that sets the texture to be bound to the next available texture unit.WebGLPipeline.bindTextureis a new method that immediately activates the given WebGL Texture and binds it to the requested slot.WebGLPipeline.bindRenderTargetis a new method that binds the given Render Target to a given texture slot.WebGLPipeline.setTimeis a new method that gets the current game loop duration to the given shader uniform.
The WebGLPipeline class has lots of new hooks you can use. These are all empty by default so you can safely override them in your own classes to take advantage of them:
WebGLPipeline.onBootis a new hook you can override in your own pipelines that is called when the pipeline has booted.WebGLPipeline.onResizeis a new hook you can override in your own pipelines that is called when the pipeline is resized.WebGLPipeline.onDrawis a new hook you can override in your own pipelines that is called by Post FX Pipelines every timepostBatchis invoked.WebGLPipeline.onActiveis a new hook you can override in your own pipelines that is called every time the Pipeline Manager makes the pipeline the active pipeline.WebGLPipeline.onBindis a new hook you can override in your own pipelines that is called every time a Game Object asks the Pipeline Manager to use this pipeline, even if it's already active.WebGLPipeline.onRebindis a new hook you can override in your own pipelines that is called every time the Pipeline Manager needs to reset and rebind the current pipeline.WebGLPipeline.onBatchis a new hook you can override in your own pipelines that is called after a new quad (or tri) has been added to the batch.WebGLPipeline.onPreBatchis a new hook you can override in your own pipelines that is called before a new Game Object is about to process itself through the batch.WebGLPipeline.onPostBatchis a new hook you can override in your own pipelines that is called after a new Game Object has added itself to the batch.WebGLPipeline.onPreRenderis a new hook you can override in your own pipelines that is called once, per frame, right before anything has been rendered.WebGLPipeline.onRenderis a new hook you can override in your own pipelines that is called once, per frame, by every Camera in the Scene that wants to render, at the start of the render process.WebGLPipeline.onPostRenderis a new hook you can override in your own pipelines that is called once, per frame, after all rendering has happened and snapshots have been taken.WebGLPipeline.onBeforeFlushis a new hook you can override in your own pipelines that is called immediately before thegl.bufferDataandgl.drawArrayscalls are made, so you can perform any final pre-render modifications.WebGLPipeline.onAfterFlushis a new hook you can override in your own pipelines that is called aftergl.drawArrays, so you can perform additional post-render effects.
The WebGLPipeline class now extends the Event Emitter and emits the following new events:
- The
WebGL.Pipelines.Events.AFTER_FLUSHevent is dispatched by a WebGL Pipeline right after it has issued adrawArrayscommand. - The
WebGL.Pipelines.Events.BEFORE_FLUSHevent is dispatched by a WebGL Pipeline right before it is about to flush. - The
WebGL.Pipelines.Events.BINDevent is dispatched by a WebGL Pipeline when it is bound by the Pipeline Manager. - The
WebGL.Pipelines.Events.BOOTevent is dispatched by a WebGL Pipeline when it has finished booting. - The
WebGL.Pipelines.Events.DESTROYevent is dispatched by a WebGL Pipeline when it begins its destruction process. - The
WebGL.Pipelines.Events.REBINDevent is dispatched by a WebGL Pipeline when the Pipeline Manager resets and rebinds it. - The
WebGL.Pipelines.Events.RESIZEevent is dispatched by a WebGL Pipeline when it is resized, usually as a result of the Renderer.
WebGLShaders have a uniforms object that is automatically populated when the shader is created. It scans all of the active uniforms from the compiled shader and then builds an object containing their WebGLUniformLocation and a value cache.
This saves redundant gl operations for both looking-up uniform locations and setting their values if they're already the currently set values by using the local cache instead.
The WebGLPipeline classes offer a means to set uniform values on the shader (or shaders) belonging to the pipeline. Previously, calling a method such as setFloat3 on a pipeline would pass that call over to WebGLRenderer. The renderer would first check to see if the pipeline program was current, and if not, make it so, before then looking up the uniform location and finally setting it. This is a lot of steps to take for pipelines that potentially need to change uniforms for every Game Object they render.
Under the new methods, and using the new pre-cached uniform locations and values, these extra steps are skipped. The uniform value is set directly, no shader binding takes place and no location look-up happens. This dramatically reduces the number of WebGL ops being issued per frame. To clearly differentiate these pipeline methods, we have renamed them. The new method names are as follows:
WebGLPipeline.set1fwill set a 1f uniform based on the given name.WebGLPipeline.set2fwill set a 2f uniform based on the given name.WebGLPipeline.set3fwill set a 3f uniform based on the given name.WebGLPipeline.set4fwill set a 4f uniform based on the given name.WebGLPipeline.set1fvwill set a 1fv uniform based on the given name.WebGLPipeline.set2fvwill set a 2fv uniform based on the given name.WebGLPipeline.set3fvwill set a 3fv uniform based on the given name.WebGLPipeline.set4fvwill set a 4fv uniform based on the given name.WebGLPipeline.set1ivwill set a 1iv uniform based on the given name.WebGLPipeline.set2ivwill set a 2iv uniform based on the given name.WebGLPipeline.set3ivwill set a 3iv uniform based on the given name.WebGLPipeline.set4ivwill set a 4iv uniform based on the given name.WebGLPipeline.set1iwill set a 1i uniform based on the given name.WebGLPipeline.set2iwill set a 2i uniform based on the given name.WebGLPipeline.set3iwill set a 3i uniform based on the given name.WebGLPipeline.set4iwill set a 4i uniform based on the given name.WebGLPipeline.setMatrix2fvwill set a matrix 2fv uniform based on the given name.WebGLPipeline.setMatrix3fvwill set a matrix 3fv uniform based on the given name.WebGLPipeline.setMatrix4fvwill set a matrix 4fv uniform based on the given name.
If your code uses any of the old method names, please update them using the list below:
WebGLPipeline.setFloat1has been removed. Please useset1finstead.WebGLPipeline.setFloat2has been removed. Please useset2finstead.WebGLPipeline.setFloat3has been removed. Please useset3finstead.WebGLPipeline.setFloat4has been removed. Please useset4finstead.WebGLPipeline.setFloat1vhas been removed. Please useset1fvinstead.WebGLPipeline.setFloat2vhas been removed. Please useset2fvinstead.WebGLPipeline.setFloat3vhas been removed. Please useset3fvinstead.WebGLPipeline.setFloat4vhas been removed. Please useset4fvinstead.WebGLPipeline.setInt1has been removed. Please useset1iinstead.WebGLPipeline.setInt2has been removed. Please useset2iinstead.WebGLPipeline.setInt3has been removed. Please useset3iinstead.WebGLPipeline.setInt4has been removed. Please useset4iinstead.WebGLPipeline.setMatrix1has been removed. Please usesetMatrix2fvinstead.WebGLPipeline.setMatrix2has been removed. Please usesetMatrix3fvinstead.WebGLPipeline.setMatrix3has been removed. Please usesetMatrix4fvinstead.
To support the new Post Pipelines in 3.50, the Pipeline Component which most Game Objects inherit has been updated. That means the following new properties and methods are available on all Game Objects that have this component, such as Sprite, Layer, Rope, etc.
hasPostPipelineis a new boolean property that indicates if the Game Object has one, or more post pipelines set.postPipelinesis a new property that contains an array of Post Pipelines owned by the Game Object.pipelineDatais a new object object to store pipeline specific data in.- The
setPipelinemethod has been updated with 2 new parameters:pipelineDataandcopyData. These allow you to populate the pipeline data object during setting. - You can now pass a pipeline instance to the
setPipelinemethod, as well as a string. setPostPipelineis a new method that allows you to set one, or more, Post FX Pipelines on the Game Object. And optionally set the pipeline data with them.setPipelineDatais a new method that allows you to set a key/value pair into the pipeline data object in a chainable way.getPostPipelineis a new method that will return a Post Pipeline instance from the Game Object based on the given string, function or instance.- The
resetPipelinemethod has two new parametersresetPostPipelineandresetData, both false by default, that will reset the Post Pipelines and pipeline data accordingly. resetPostPipelineis a new method that will specifically reset just the Post Pipelines, and optionally the pipeline data.removePostPipelineis a new method that will destroy and remove the given Post Pipeline from the Game Object.
The Utility Pipeline is a brand new default special-use WebGL Pipeline that is created by and belongs to the Pipeline Manager.
It provides 4 shaders and handy associated methods:
- Copy Shader. A fast texture to texture copy shader with optional brightness setting.
- Additive Blend Mode Shader. Blends two textures using an additive blend mode.
- Linear Blend Mode Shader. Blends two textures using a linear blend mode.
- Color Matrix Copy Shader. Draws a texture to a target using a Color Matrix.
You do not extend this pipeline, but instead get a reference to it from the Pipeline Manager via the setUtility method. You can also access its methods, such as copyFrame, directly from both the Pipeline Manager and from Post FX Pipelines, where its features are most useful.
This pipeline provides methods for manipulating framebuffer backed textures, such as copying or blending one texture to another, copying a portion of a texture, additively blending two textures, flipping textures and more. All essential and common operations for post processing.
The following properties and methods are available in the new UtilityPipeline class:
- The
UtilityPipeline.colorMatrixproperty is an instance of a ColorMatrix class, used by the draw shader. - The
UtilityPipeline.copyShaderproperty is a reference to the Copy Shader. - The
UtilityPipeline.addShaderproperty is a reference to the additive blend shader. - The
UtilityPipeline.linearShaderproperty is a reference to the linear blend shader. - The
UtilityPipeline.colorMatrixShaderproperty is a reference to the color matrix (draw) shader. - The
UtilityPipeline.fullFrame1property is a full sized Render Target that can be used as a temporary buffer during post processing calls. - The
UtilityPipeline.fullFrame2property is a full sized Render Target that can be used as a temporary buffer during post processing calls. - The
UtilityPipeline.halfFrame1property is a half sized Render Target that can be used as a temporary buffer during post processing calls, where a small texture is required for more intensive operations. - The
UtilityPipeline.halfFrame2property is a half sized Render Target that can be used as a temporary buffer during post processing calls, where a small texture is required for more intensive operations. - The
UtilityPipeline.copyFramemethod will copy asourceRender Target to thetargetRender Target, optionally setting the brightness of the copy. - The
UtilityPipeline.blitFramemethod will copy asourceRender Target to thetargetRender Target. UnlikecopyFrameno resizing takes place and you can optionally set the brightness and erase mode of the copy. - The
UtilityPipeline.copyFrameRectmethod binds thesourceRender Target and then copies a section of it to thetargetusinggl.copyTexSubImage2Drather than a shader, making it much faster if you don't need blending or preserving alpha details. - The
UtilityPipeline.copyToGamemethod pops the framebuffer from the renderers FBO stack and sets that as the active target, then draws thesourceRender Target to it. Use when you need to render the final result to the game canvas. - The
UtilityPipeline.drawFramemethod will copy asourceRender Target, optionally to atargetRender Target, using the given ColorMatrix, allowing for full control over the luminance values used during the copy. - The
UtilityPipeline.blendFramesmethod draws thesource1andsource2Render Targets to thetargetRender Target using a linear blend effect, which is controlled by thestrengthparameter. - The
UtilityPipeline.blendFramesAdditivemethod draws thesource1andsource2Render Targets to thetargetRender Target using an additive blend effect, which is controlled by thestrengthparameter. - The
UtilityPipeline.clearFramemethod clears the given Render Target. - The
UtilityPipeline.setUVsmethod allows you to set the UV values for the 6 vertices that make-up the quad belonging to the Utility Pipeline. - The
UtilityPipeline.setTargetUVsmethod sets the vertex UV coordinates of the quad used by the shaders so that they correctly adjust the texture coordinates for a blit frame effect. - The
UtilityPipeline.flipXmethod horizontally flips the UV coordinates of the quad used by the shaders. - The
UtilityPipeline.flipYmethod vertically flips the UV coordinates of the quad used by the shaders. - The
UtilityPipeline.resetUVsmethod resets the quad vertice UV values to their default settings.
The Light Pipeline (previously called the Forward Diffuse Light Pipeline), which is responsible for rendering lights under WebGL, has been rewritten to work with the new Multi Pipeline features. Lots of redundant code has been removed and the following changes and improvements took place:
- The pipeline now works with Game Objects that do not have a normal map. They will be rendered using the new default normal map, which allows for a flat light effect to pass over them and merge with their diffuse map colors.
- Fixed a bug in the way lights were handled that caused Tilemaps to render one tile at a time, causing massive slow down. They're now batched properly, making a combination of lights and tilemaps possible again.
- The Bitmap Text (Static and Dynamic) Game Objects now support rendering with normal maps.
- The TileSprite Game Objects now support rendering with normal maps.
- Mesh Game Objects now support rendering with normal maps.
- Particle Emitter Game Object now supports rendering in Light2d.
- The Text Game Object now supports rendering in Light2d, no matter which font, stroke or style it is using.
- Tilemap Layer Game Objects now support the Light2d pipeline, with or without normal maps.
- The pipeline will no longer look-up and set all of the light uniforms unless the
Lightis dirty. - The pipeline will no longer reset all of the lights unless the quantity of lights has changed.
- The
ForwardDiffuseLightPipeline.defaultNormalMapproperty has changed, it's now an object with aglTextureproperty that maps to the pipelines default normal map. - The
ForwardDiffuseLightPipeline.bootmethod has been changed to now generate a default normal map. - The
ForwardDiffuseLightPipeline.onBindmethod has been removed as it's no longer required. - The
ForwardDiffuseLightPipeline.setNormalMapmethod has been removed as it's no longer required. ForwardDiffuseLightPipeline.bindis a new method that handles setting-up the shader uniforms.- The
ForwardDiffuseLightPipeline.batchTexturemethod has been rewritten to use the Texture Tint Pipeline function instead. - The
ForwardDiffuseLightPipeline.batchSpritemethod has been rewritten to use the Texture Tint Pipeline function instead. ForwardDiffuseLightPipeline.lightCountis a new property that stores the previous number of lights rendered.ForwardDiffuseLightPipeline.getNormalMapis a new method that will look-up and return a normal map for the given object.
The Point Light Pipeline is a brand new pipeline in 3.50 that was creates specifically for rendering the new Point Light Game Objects in WebGL.
It extends the WebGLPipeline and sets the required shader attributes and uniforms for Point Light rendering.
You typically don't access or set the pipeline directly, but rather create instances of the Point Light Game Object instead. However, it does have the following unique methods:
- The
PointLightPipeline.batchPointLightmethod is a special-case method that is called directly by the Point Light Game Object during rendering and allows it to add itself into the rendering batch. - The
PointLightPipeline.batchLightVertmethod is a special internal method, used bybatchPointLightthat adds a single Point Light vert into the batch.
The Graphics Pipeline is a new pipeline added in 3.50 that is responsible for rendering Graphics Game Objects and all of the Shape Game Objects, such as Arc, Rectangle, Star, etc. Due to the new pipeline some changes have been made:
- The Graphics Pipeline now uses much simpler vertex and fragment shaders with just two attributes (
inPositionandinColor), making the vertex size and memory-use 57% smaller. - The private
_tempMatrix1, 2, 3 and 4 properties have all been removed from the pipeline. - A new public
calcMatrixproperty has been added, which Shape Game Objects use to maintain transform state during rendering. - The Graphics Pipeline no longer makes use of
tintEffector any textures. - Because Graphics and Shapes now render with their own pipeline, you are able to exclude the pipeline and those Game Objects entirely from custom builds, further reducing the final bundle size.
As a result of these changes the following features are no longer available:
Graphics.setTexturehas been removed. You can no longer use a texture as a 'fill' for a Graphic. It never worked with any shape other than a Rectangle, anyway, due to UV mapping issues, so is much better handled via the new Mesh Game Object.Graphics._tempMatrix1, 2 and 3 have been removed. They're not required internally any longer.Graphics.renderWebGLnow uses the standardGetCalcMatrixfunction, cutting down on duplicate code significantly.
There is a new pipeline called SinglePipeline, created to emulate the old TextureTintPipeline. This special pipeline uses just a single texture and makes things a lot easier if you wish to create a custom pipeline, but not have to recode your shaders to work with multiple textures. Instead, just extend SinglePipeline, where-as before you extended the TextureTintPipeline and you won't have to change any of your shader code. However, if you can, you should update it to make it perform faster, but that choice is left up to you.
WebGLShader is a new class that is created and belongs to WebGL Pipeline classes. When the pipeline is created it will create a WebGLShader instance for each one of its shaders, as defined in the pipeline configuration.
This class encapsulates everything needed to manage a shader in a pipeline, including the shader attributes and uniforms, as well as lots of handy methods such as set2f, for setting uniform values on this shader. Uniform values are automatically cached to avoid unnecessary gl operations.
Typically, you do not create an instance of this class directly, as it works in unison with the pipeline to which it belongs. You can gain access to this class via a pipeline's shaders array, post-creation.
The following properties and methods are available in the new WebGLShader class:
- The
WebGLShader.pipelineproperty is a reference to the WebGL Pipeline that owns the WebGLShader instance. - The
WebGLShader.nameproperty is the name of the shader. - The
WebGLShader.rendererproperty is a reference to the WebGL Renderer. - The
WebGLShader.glproperty is a reference to the WebGL Rendering Context. - The
WebGLShader.programproperty is the WebGL Program created from the vertex and fragment shaders. - The
WebGLShader.attributesproperty is an array of objects that describe the vertex attributes of the shader. - The
WebGLShader.vertexComponentCountproperty is the total amount of vertex attribute components of 32-bit length. - The
WebGLShader.vertexSizeproperty is the size, in bytes, of a single vertex. - The
WebGLShader.uniformsproperty is an object that is automatically populated with all active uniforms in the shader. - The
WebGLShader.createAttributesmethod takes the vertex attributes config and parses it, creating the shader attributes. This is called automatically. - The
WebGLShader.bindmethod sets the program the shader uses as being active. Called automatically when the parent pipeline needs this shader. - The
WebGLShader.rebindmethod sets the program the shader uses as being active and resets all of the vertex attribute pointers. - The
WebGLShader.setAttribPointersmethod sets the vertex attribute pointers. Called automatically duringbind. - The
WebGLShader.createUniformsmethod populates theuniformsobject with details about all active uniforms. - The
WebGLShader.hasUniformmethod returns a boolean if the given uniform exists. - The
WebGLShader.resetUniformmethod resets the cached value for the given uniform. - The
WebGLShader.setUniform1method is an internal method used for setting a single value uniform on the shader. - The
WebGLShader.setUniform2method is an internal method used for setting a double value uniform on the shader. - The
WebGLShader.setUniform3method is an internal method used for setting a triple value uniform on the shader. - The
WebGLShader.setUniform4method is an internal method used for setting a quadruple value uniform on the shader. - The
WebGLShader.set1fmethod sets a 1f uniform based on the given name. - The
WebGLShader.set2fmethod sets a 2f uniform based on the given name. - The
WebGLShader.set3fmethod sets a 3f uniform based on the given name. - The
WebGLShader.set4fmethod sets a 4f uniform based on the given name. - The
WebGLShader.set1fvmethod sets a 1fv uniform based on the given name. - The
WebGLShader.set2fvmethod sets a 2fv uniform based on the given name. - The
WebGLShader.set3fvmethod sets a 3fv uniform based on the given name. - The
WebGLShader.set4fvmethod sets a 4fv uniform based on the given name. - The
WebGLShader.set1ivmethod sets a 1iv uniform based on the given name. - The
WebGLShader.set2ivmethod sets a 2iv uniform based on the given name. - The
WebGLShader.set3ivmethod sets a 3iv uniform based on the given name. - The
WebGLShader.set4ivmethod sets a 4iv uniform based on the given name. - The
WebGLShader.set1imethod sets a 1i uniform based on the given name. - The
WebGLShader.set2imethod sets a 2i uniform based on the given name. - The
WebGLShader.set3imethod sets a 3i uniform based on the given name. - The
WebGLShader.set4imethod sets a 4i uniform based on the given name. - The
WebGLShader.setMatrix2fvmethod sets a matrix 2fv uniform based on the given name. - The
WebGLShader.setMatrix3fvmethod sets a matrix 3fv uniform based on the given name. - The
WebGLShader.setMatrix4fvmethod sets a matrix 4fv uniform based on the given name. - The
WebGLShader.destroymethod removes all external references and deletes the program and attributes.
RenderTarget is a brand new class that encapsulates a WebGL framebuffer and the WebGL Texture that displays it. Instances of this class are typically created by, and belong to WebGL Pipelines, however other Game Objects and classes can take advantage of Render Targets as well.
The following properties and methods are available in the new RenderTexture class:
- The
RenderTarget.rendererproperty is a reference to the WebGL Renderer. - The
RenderTarget.framebufferproperty is the WebGLFramebuffer belonging to the Render Target. - The
RenderTarget.textureproperty is a WebGLTexture belonging to the Render Target and bound to the framebuffer. - The
RenderTarget.widthproperty is the width of the Render Target. - The
RenderTarget.heightproperty is the height of the Render Target. - The
RenderTarget.scaleproperty is the scale of the Render Target, applied to the dimensions during resize. - The
RenderTarget.minFilterproperty is the min filter of the texture. - The
RenderTarget.autoClearproperty is a boolean that controls if the Render Target is automatically cleared when bound. - The
RenderTarget.autoResizeproperty is a boolean that controls if the Render Target is automatically resized if the WebGLRenderer resizes. - The
RenderTarget.setAutoResizemethod lets you set the auto resize of the Render Target. - The
RenderTarget.resizemethod lets you resize the Render Target. - The
RenderTarget.bindmethod sets the Render Target as being the active fbo in the renderer and optionally clears and adjusts the viewport. - The
RenderTarget.adjustViewportmethod sets the viewport to match the Render Target dimensions. - The
RenderTarget.clearmethod disables the scissors, clears the Render Target and resets the scissors again. - The
RenderTarget.unbindmethod flushes the renderer and pops the Render Target framebuffer from the stack. - The
RenderTarget.destroymethod removes all external references and deletes the framebuffer and texture.
The Multi Pipeline (previously called the Texture Tint Pipeline) has had its core flow rewritten to eliminate the need for constantly creating batch objects. Instead, it now supports the new multi-texture shader, vastly increasing rendering performance, especially on draw-call bound systems.
All of the internal functions, such as batchQuad and batchSprite have been updated to use the new method of texture setting. The method signatures all remain the same unless indicated below.
Config.render.maxTexturesis a new game config setting that allows you to control how many texture units will be used in WebGL.WebGL.Utils.checkShaderMaxis a new function, used internally by the renderer, to determine the maximum number of texture units the GPU + browser supports.- The property
WebGLRenderer.currentActiveTextureUnithas been renamed tocurrentActiveTexture. WebGLRenderer.startActiveTextureis a new read-only property contains the current starting active texture unit.WebGLRenderer.maxTexturesis a new read-only property that contains the maximum number of texture units WebGL can use.WebGLRenderer.textureIndexesis a new read-only array that contains all of the available WebGL texture units.WebGLRenderer.tempTexturesis a new read-only array that contains temporary WebGL textures.- The
WebGLRenderer.currentTexturesproperty has been removed, as it's no longer used. TextureSource.glIndexis a new property that holds the currently assigned texture unit for the Texture Source.TextureSource.glIndexCounteris a new property that holds the time the index was assigned to the Texture Source.WebGLRenderer.currentTextureshas been removed, as it's no longer used internally.WebGLRenderer.setBlankTextureno longer has aforceparameter, as it's set by default.- The Mesh Game Object WebGL Renderer function has been updated to support multi-texture units.
- The Blitter Game Object WebGL Renderer function has been updated to support multi-texture units.
- The Bitmap Text Game Object WebGL Renderer function has been updated to support multi-texture units.
- The Dynamic Bitmap Text Game Object WebGL Renderer function has been updated to support multi-texture units.
- The Particle Emitter Game Object WebGL Renderer function has been updated to support multi-texture units.
- The Texture Tint vertex and fragment shaders have been updated to support the
inTexIdfloat attribute and dynamic generation. - The Texture Tint Pipeline has a new attribute,
inTexIdwhich is agl.FLOAT. TextureTintPipeline.bindis a new method that sets theuMainSampleruniform.- The
TextureTintPipeline.requireTextureBatchmethod has been removed, as it's no longer required. - The
TextureTintPipeline.pushBatchmethod has been removed, as it's no longer required. - The
TextureTintPipeline.maxQuadsproperty has been removed, as it's no longer required. - The
TextureTintPipeline.batchesproperty has been removed, as it's no longer required. TextureTintPipeline.flushhas been rewritten to support multi-textures.TextureTintPipeline.flushno longer creates a sub-array if the batch is full, but instead usesbufferDatafor speed.WebGLRenderer.setTextureSourceis a new method, used by pipelines and Game Objects, that will assign a texture unit to the given Texture Source.- The
WebGLRenderer.setTexture2Dmethod has been updated to use the new texture unit assignment. It no longer takes thetextureUnitorflushparameters and these have been removed from its method signature. WebGLRenderer.setTextureZerois a new method that activates texture zero and binds the given texture to it. Useful for fbo backed game objects.WebGLRenderer.clearTextureZerois a new method that clears the texture that was bound to unit zero.WebGLRenderer.textureZerois a new property that holds the currently bound unit zero texture.WebGLRenderer.normalTextureis a new property that holds the currently bound normal map (texture unit one).WebGLRenderer.setNormalMapis a new method that sets the current normal map texture.WebGLRenderer.clearNormalMapis a new method that clears the current normal map texture.WebGLRenderer.resetTexturesis a new method that flushes the pipeline, resets all textures back to the temporary ones, and resets the active texture counter.WebGLRenderer.isNewNormalMapis a new method that returns a boolean if the given parameters are not currently used.WebGLRenderer.unbindTexturesis a new method that will activate and then null bind all WebGL textures.Renderer.WebGL.Utils.parseFragmentShaderMaxTexturesis a new function that will take fragment shader source and search it for%count%and%forloop%declarations, replacing them with the required GLSL for multi-texture support, returning the modified source.- The
WebGL.Utils.getComponentCountfunction has been removed as this is no longer required internally.
WebGLRenderer.instancedArraysExtensionis a new property that holds the WebGL Extension for instanced array drawing, if supported by the browser.WebGLRenderer.vaoExtensionis a new property that holds a reference to the Vertex Array Object WebGL Extension, if supported by the browser.WebGLRenderer.resetProgramis a new method that will rebind the current program, without flushing or changing any properties.WebGLRenderer.textureFlushis a new property that keeps track of the total texture flushes per frame.WebGLRenderer.finalTypeis a new boolean property that signifies if the current Game Object being rendered is the final one in the list.- The
WebGLRenderer.updateCanvasTexturemethod will now setgl.UNPACK_PREMULTIPLY_ALPHA_WEBGLto true, which should stop issues where you update a Text Game Object, having added a Render Texture or Spine Game Object to the Scene after it, which switches the PMA setting. Fix #5064 #5155 (thanks @hugoruscitti @immangrove-supertree) WebGLRenderer.previousPipelineis a new property that is set during a call toclearPipelineand used during calls torebindPipeline, allowing the renderer to rebind any previous pipeline, not just the Multi Pipeline.- The
WebGLRenderer.rebindPipelinemethod has been changed slightly. Previously, you had to specify thepipelineInstance, but this is now optional. If you don't, it will use the newpreviousPipelineproperty instead. If not set, or none given, it will now return without throwing gl errors as well. WebGLRenderer.defaultScissoris a new property that holds the default scissor dimensions for the renderer. This is modified duringresizeand avoids continuous array generation in thepreRenderloop.- The
WebGLRenderer.nativeTexturesarray has been removed and any WebGLTextures created by the renderer are no longer stored within it. All WebGLTexture instances are stored in theTextureSourceobjects anyway, or by local classes such as RenderTexture, so there was no need to have another array taking up memroy. - The
WebGLRenderer.deleteTexturemethod has a new optional boolean parameterresetwhich allows you to control if theWebGLRenderer.resetTexturesmethod is called, or not, after the texture is deleted. - The
WebGLRenderer.getMaxTexturesmethod has been removed. This is no longer needed as you can use theWebGLRenderer.maxTexturesproperty instead. - The
WebGLRenderer.setProgrammethod now returns a boolean.trueif the program was set, otherwisefalse. WebGLRenderer.setFloat1has been removed. UseWebGLPipeline.set1forWebGLShader.set1finstead.WebGLRenderer.setFloat2has been removed. UseWebGLPipeline.set2forWebGLShader.set2finstead.WebGLRenderer.setFloat3has been removed. UseWebGLPipeline.set3forWebGLShader.set3finstead.WebGLRenderer.setFloat4has been removed. UseWebGLPipeline.set4forWebGLShader.set4finstead.WebGLRenderer.setFloat1vhas been removed. UseWebGLPipeline.set1fvorWebGLShader.set1fvinstead.WebGLRenderer.setFloat2vhas been removed. UseWebGLPipeline.set1fvorWebGLShader.set2fvinstead.WebGLRenderer.setFloat3vhas been removed. UseWebGLPipeline.set1fvorWebGLShader.set3fvinstead.WebGLRenderer.setFloat4vhas been removed. UseWebGLPipeline.set1fvorWebGLShader.set4fvinstead.WebGLRenderer.setInt1has been removed. UseWebGLPipeline.set1fiorWebGLShader.set1iinstead.WebGLRenderer.setInt2has been removed. UseWebGLPipeline.set1fiorWebGLShader.set2iinstead.WebGLRenderer.setInt3has been removed. UseWebGLPipeline.set1fiorWebGLShader.set3iinstead.WebGLRenderer.setInt4has been removed. UseWebGLPipeline.set1fiorWebGLShader.set4iinstead.WebGLRenderer.setMatrix2has been removed. UseWebGLPipeline.setMatrix2fvorWebGLShader.setMatrix2fvinstead.WebGLRenderer.setMatrix3has been removed. UseWebGLPipeline.setMatrix3fvorWebGLShader.setMatrix3fvinstead.WebGLRenderer.setMatrix4has been removed. UseWebGLPipeline.setMatrix4fvorWebGLShader.setMatrix4fvinstead.- The
WebGLRenderer._tempMatrix1,_tempMatrtix2,_tempMatrix3and_tempMatrix4properties have been removed. They were all flagged as private, yet used in lots of places. Instead, Game Objects now manager their own matrices, or use the globalGetCalcMatrixfunction instead. WebGLRenderer.fboStackis a new property that maintains a stack of framebuffer objects, used for pipelines supporting multiple render targets.WebGLRenderer.pushFramebufferis a new method that is used to push a framebuffer onto the fbo stack before setting it as the current framebuffer. This should now be called in place ofsetFramebuffer. Remember to callpopFramebufferafter using it.WebGLRenderer.popFramebufferis a new method that will pop the current framebuffer off the fbo stack and set the previous one as being active.WebGLRenderer.setFramebufferhas a new optional boolean parameterresetTextureswhich will reset the WebGL Textures, if set totrue(which is the default).WebGLRenderer.isBootedis a new boolean property that lets you know if the renderer has fully finished booting.- The
WebGLRenderernow extends the Event Emitter, allowing you to listen to renderer specific events. WebGLRenderer.defaultCamerahas been removed as it's not used anywhere internally any longer.- The
WebGLRenderer.setVertexBuffermethod has been removed along with theWebGLRenderer.currentVertexBufferproperty. This is now set directly by the WebGL Pipeline, as needed. - The
WebGLRenderer.setIndexBuffermethod has been removed along with theWebGLRenderer.currentIndexBufferproperty. This is now set directly by the WebGL Pipeline, as needed. WebGLRenderer.resetScissoris a new method that will reset the gl scissor state to be the current scissor, if there is one, without modifying the stack.WebGLRenderer.resetViewportis a new method that will reset the gl viewport to the current renderer dimensions.WebGLRenderer.renderTargetis a new property that contains a Render Target that is bound to the renderer and kept resized to match it.WebGLRenderer.beginCaptureis a new method that will bind the renderers Render Target, so everything drawn is redirected to it.WebGLRenderer.endCaptureis a new method that will unbind the renderers Render Target and return it, preventing anything else from being drawn to it.WebGLRenderer.setProjectionMatrixis a new method that sets the global renderer projection matrix to the given dimensions.WebGLRenderer.resetProjectionMatrixis a new method that resets the renderer projection matrix back to match the renderer size.WebGLRenderer.getAspectRatiois a new method that returns the aspect ratio of the renderer.
The ModelViewProjection object contained a lot of functions that Phaser never used internally. Instead, the functions available in them were already available in the Math.Matrix4 class. So the pipelines have been updated to use a Matrix4 instead and all of the MVP functions have been removed. The full list of removed functions is below:
projIdentityhas been removed.projPersphas been removed.modelRotateXhas been removed.modelRotateYhas been removed.modelRotateZhas been removed.viewLoadhas been removed.viewRotateXhas been removed.viewRotateYhas been removed.viewRotateZhas been removed.viewScalehas been removed.viewTranslatehas been removed.modelIdentityhas been removed.modelScalehas been removed.modelTranslatehas been removed.viewIdentityhas been removed.viewLoad2Dhas been removed.projOrthohas been removed.
Phaser.Renderer.Eventsis a new namespace for events emitted by the Canvas and WebGL Renderers.Renderer.Events.PRE_RENDERis a new event dispatched by the Phaser Renderer. This happens right at the start of the render process.Renderer.Events.RENDERis a new event dispatched by the Phaser Renderer. This happens once for every camera, in every Scene at the start of its render process.Renderer.Events.POST_RENDERis a new event dispatched by the Phaser Renderer. This happens right at the end of the render process.Renderer.Events.RESIZEis a new event dispatched by the Phaser Renderer whenever it is resized.
CanvasRenderer.isBootedis a new boolean property that lets you know if the renderer has fully finished booting.- The
CanvasRenderernow extends the Event Emitter, allowing you to listen to renderer specific events.
The Camera API has changed in line with the new pipeline updates. To this end, the following changes have taken place:
The Camera class now inherits the Pipeline Component. This gives it new features, in line with the other pipelines changes in 3.50, such as Camera.setPipeline, Camera.setPostPipeline, Camera.setPipelineData and so on. This is a much more powerful and flexible way of setting camera effects, rather than it managing its own framebuffer and texture directly.
To that end, the following properties and methods have been removed to tidy things up:
- The
Camera.renderToTextureproperty has been removed. Effects are now handled via pipelines. - The
Camera.renderToGameproperty has been removed. Effects are now handled via pipelines. - The
Camera.canvasproperty has been removed. Textures are handled by pipelines. - The
Camera.contextproperty has been removed. Textures are handled by pipelines. - The
Camera.glTextureproperty has been removed. GL Textures are handled by pipelines. - The
Camera.framebufferproperty has been removed. GL Framebuffers are handled by pipelines. - The
Camera.setRenderToTexturemethod has been removed. Effects are now handled via pipelines. - The
Camera.clearRenderToTexturemethod has been removed. Effects are now handled via pipelines.
These changes mean that you can no longer render a Camera to a canvas in Canvas games.
Other changes and fixes:
Camera.zoomXis a new property that allows you to specifically set the horizontal zoom factor of a Camera.Camera.zoomYis a new property that allows you to specifically set the vertical zoom factor of a Camera.- The
Camera.setZoommethod now allows you to pass two parameters:xandy, to control thezoomXandzoomYvalues accordingly. - The
Camera.zoomproperty now returns an average of thezoomXandzoomYproperties. Cameras.Scene2D.Events.FOLLOW_UPDATEis a new Event that is dispatched by a Camera when it is following a Game Object. It is dispatched every frame, right after the final Camera position and internal matrices have been updated. Use it if you need to react to a camera, using its most current position and the camera is following something. Fix #5253 (thanks @rexrainbow)- If the Camera has
roundPixelsset it will now round the internal scroll factors andworldViewduring thepreRenderstep. Fix #4464 (thanks @Antriel)
- The Spine Runtimes have been updated to 3.8.99, which are the most recent non-beta versions. Please note, you will need to re-export your animations if you're working in a version of Spine lower than 3.8.20. We do not impose this requirement, the Spine editor does.
SpineContaineris a new Game Object available viathis.add.spineContainerto which you can add Spine Game Objects only. It uses a special rendering function to retain batching, even across multiple container or Spine Game Object instances, resulting in dramatically improved performance compared to using regular Containers. You can still use regular Containers if you need, but they do not benefit from the new batching.- A Spine Game Object with
setVisible(false)will no longer still cause internal gl commands and is now properly skipped, retaining any current batch in the process. Fix #5174 (thanks @Kitsee) - The Spine Game Object WebGL Renderer will no longer clear the type if invisible and will only end the batch if the next type doesn't match.
- The Spine Game Object WebGL Renderer will no longer rebind the pipeline if it was the final object on the display list, saving lots of gl commands.
- The Webpack build scripts have all been updated for Webpack 4.44.x. Fix #5243 (thanks @RollinSafary)
- There is a new npm script
npm run plugin.spine.runtimeswhich will build all of the Spine runtimes, for ingestion by the plugin. Note: You will need to check-out the Esoteric Spine Runtimes repo intoplugins/spine/in order for this to work and then runnpm i. - Spine Game Objects can now be rendered to Render Textures. Fix #5184 (thanks @Kitsee)
- Using > 128 Spine objects in a Container would cause a
WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zeroerror if you added any subsequent Spine objects to the Scene. There is now no limit. Fix #5246 (thanks @d7561985) - The Spine Plugin will now work in HEADLESS mode without crashing. Fix #4988 (thanks @raimon-segura)
- Spine Game Objects now use -1 as their default blend mode, which means 'skip setting it', as blend modes should be handled by the Spine skeletons directly.
- The Spine TypeScript defs have been updated for the latest version of the plugin and to add SpineContainers.
- The
SpineGameObject.setAnimationmethod will now use thetrackIndexparameter ifignoreIfPlayingis set and run the check against this track index. Fix #4842 (thanks @vinerz) - The
SpineFilewill no longer throw a warning if adding a texture into the Texture Manager that already exists. This allows you to have multiple Spine JSON use the same texture file, however, it also means you now get no warning if you accidentally load a texture that exists, so be careful with your keys! Fix #4947 (thanks @Nomy1) - The Spine Plugin
destroymethod will now no longer remove the Game Objects from the Game Object Factory, or dispose of the Scene Renderer. This means when a Scene is destroyed, it will keep the Game Objects in the factory for other Scenes to use. Fix #5279 (thanks @Racoonacoon) SpinePlugin.gameDestroyis a new method that is called if the Game instance emits adestroyevent. It removes the Spine Game Objects from the factory and disposes of the Spine scene renderer.SpineFilewill now check to see if another identical atlas in the load queue is already loading the texture it needs and will no longer get locked waiting for a file that will never complete. This allows multiple skeleton JSONs to use the same atlas data. Fix #5331 (thanks @Racoonacoon)SpineFilenow uses a!character to split the keys, instead of an underscore, preventing the plugin from incorrectly working out the keys for filenames with underscores in them. Fix #5336 (thanks @Racoonacoon)SpineGameObject.willRenderis no longer hard-coded to returntrue. It instead now takes a Camera parameter and performs all of the checks needed before returning. Previously, this happened during the render functions.- The Spine Plugin now uses a single instance of the Scene Renderer when running under WebGL. All instances of the plugin (installed per Scene) share the same base Scene Renderer, avoiding duplicate allocations and resizing events under multi-Scene games. Fix #5286 (thanks @spayton BunBunBun)
Lots of the core Phaser Game Objects have been improved in 3.50 and there are several new Game Objects as well.
The Render Texture Game Object has been rewritten to use the new RenderTarget class internally, rather than managing its own framebuffer and gl textures directly. The core draw methods are now a lot simpler and no longer require manipulating render pipelines.
As a result of these changes the following updates have happened:
RenderTexture.renderTargetis a new property that contains aRenderTargetinstance, which is used for all drawing.- The
RenderTexture.framebufferproperty has been removed. You can now access this viaRenderTexture.renderTarget.framebuffer. - The
RenderTexture.glTextureproperty has been removed. You can now access this viaRenderTexture.renderTarget.texture. - The
RenderTexture.glproperty has been removed.
Render Textures have the following new features:
RenderTexture.beginDrawis a new method that allows you to create a batched draw to the Render Texture. Use this method to begin the batch.RenderTexture.batchDrawis a new method that allows you to batch the drawing of an object to the Render Texture. You should never call this method unless you have previously started a batch withbeginDraw. You can call this method as many times as you like, to draw as many objects as you like, without causing a framebuffer bind.RenderTexture.batchDrawFrameis a new method that allows you to batch the drawing of a texture frame to the Render Texture. You should never call this method unless you have previously started a batch withbeginDraw. You can call this method as many times as you like, to draw as many frames as you like, without causing a framebuffer bind.RenderTexture.endDrawis a new method that ends a previously created batched draw on the Render Texture. Use it to write all of your batch changes to the Render Texture.- You can now draw a
Groupto aRenderTexture. Previously, it failed to pass the camera across, resulting in none of the Group children being drawn. Fix #5330 (thanks @somnolik)
Render Textures have the following bug fixes:
RenderTexture.resize(which is called fromsetSize) wouldn't correctly set theTextureSource.glTextureproperty, leading tobindTexture: attempt to use a deleted objecterrors under WebGL.RenderTexture.fillwould fail to fill the correct area under WebGL if the RenderTexture wasn't the same size as the Canvas. It now fills the given region properly.RenderTexture.erasehas never worked when using the Canvas Renderer and a texture frame, only with Game Objects. It now works with both. Fix #5422 (thanks @vforsh)
The Point Light Game Object is brand new in 3.50 and provides a way to add a point light effect into your game, without the expensive shader processing requirements of the traditional Light Game Object.
The difference is that the Point Light renders using a custom shader, designed to give the impression of a radial light source, of variable radius, intensity and color, in your game. However, unlike the Light Game Object, it does not impact any other Game Objects, or use their normal maps for calculations. This makes them extremely fast to render compared to Lights and perfect for special effects, such as flickering torches or muzzle flashes.
For maximum performance you should batch Point Light Game Objects together. This means ensuring they follow each other consecutively on the display list. Ideally, use a Layer Game Object and then add just Point Lights to it, so that it can batch together the rendering of the lights. You don't have to do this, and if you've only a handful of Point Lights in your game then it's perfectly safe to mix them into the display list as normal. However, if you're using a large number of them, please consider how they are mixed into the display list.
The renderer will automatically cull Point Lights. Those with a radius that does not intersect with the Camera will be skipped in the rendering list. This happens automatically and the culled state is refreshed every frame, for every camera.
The PointLight Game Object has the following unique properties and methods:
- The
PointLight.colorproperty is an instance of the Color object that controls the color value of the light. - The
PointLight.intensityproperty sets the intensity of the light. The colors of the light are multiplied by this value during rendering. - The
PointLight.attenuationproperty sets the attenuation of the light, which is the force with which the light falls off from its center. - The
PointLight.radiusproperty sets the radius of the light, in pixels. This value is also used for culling.
Point Lights also have corresponding Factory and Creator functions, available from within a Scene:
this.add.pointlight(x, y, color, radius, intensity, attenuation);and
this.make.pointlight({ x, y, color, radius, intensity, attenuation });The Mesh Game Object has been rewritten from scratch in v3.50 with a lot of changes to make it much more useful. It is accompanied by the new Geom.Mesh set of functions.
Geom.Meshis a new namespace that contains the Mesh related geometry functions. These are stand-alone functions that you may, or may not require, depending on your game.Geom.Mesh.Vertexis a new class that encapsulates all of the data required for a single vertex, including position, uv, normals, color and alpha.Geom.Mesh.Faceis a new class that consists of references to the threeVertexinstances that construct a single Face in a Mesh and provides methods for manipulating them.Geom.Mesh.GenerateVertsis a new function that will return an array ofVertexandFaceobjects generated from the given data. You can provide index, or non-index vertex lists, along with UV data, normals, colors and alpha which it will parse and return the results from.Geom.Mesh.GenerateGridVertsis a new function that will generate a series ofVertexobjects in a grid format, based on the givenGenerateGridConfigconfig file. You can set the size of the grid, the number of segments to split it into, translate it, color it and tile the texture across it. The resulting data can be easily used by a Mesh Game Object.Geom.Mesh.GenerateObjVertsis a new function that will generate a series ofVertexobjects based on the given parsed Wavefront Obj Model data. You can optionally scale and translate the generated vertices and add them to a Mesh.Geom.Mesh.ParseObjis a new function that will parse a triangulated Wavefront OBJ file into model data into a format that theGenerateObjVertsfunction can consume.Geom.Mesh.ParseObjMaterialis a new function that will parse a Wavefront material file and extract the diffuse color data from it, combining it with the parsed object data.Geom.Mesh.RotateFaceis a new function that will rotate a Face by a given amount, based on an optional center of rotation.Loader.OBJFileis a new File Loader type that can load triangulated Wavefront OBJ files, and optionally material files, which are then parsed and stored in the OBJ Cache.- The Mesh constructor and
MeshFactorysignatures have changed toscene, x, y, texture, frame, vertices, uvs, indicies, containsZ, normals, colors, alphas. Note the way the Texture and Frame parameters now comes first.indiciesis a new parameter that allows you to provide indexed vertex data to create the Mesh from, where theindiciesarray holds the vertex index information. The final list of vertices is built from this index along with the provided vertices and uvs arrays. Theindiciesarray is optional. If your data is not indexed, then simply passnullor an empty array for this parameter. - The
MeshGame Object now has the Animation State Component. This allows you to create and play animations across the texture of a Mesh, something that previously wasn't possible. As a result, the Mesh now adds itself to the Update List when added to a Scene. Mesh.addVerticesis a new method that allows you to add vertices to a Mesh Game Object based on the given parameters. This allows you to modify a mesh post-creation, or populate it with data at a later stage.Mesh.addVerticesFromObjis a new method that will add the model data from a loaded Wavefront OBJ file to a Mesh. You load it via the newOBJFilewith athis.load.objcall, then you can use the key with this method. This method also takes an optional scale and position parameters to control placement of the created model within the Mesh.Mesh.hideCCWis a new boolean property that, when enabled, tells a Face to not render if it isn't counter-clockwise. You can use this to hide backward facing Faces.Mesh.modelPositionis a new Vector3 property that allows you to translate the position of all vertices in the Mesh.Mesh.modelRotationis a new Vector3 property that allows you to rotate all vertices in the Mesh.Mesh.modelScaleis a new Vector3 property that allows you to scale all vertices in the Mesh.Mesh.panXis a new function that will translate the view position of the Mesh on the x axis.Mesh.panYis a new function that will translate the view position of the Mesh on the y axis.Mesh.panZis a new function that will translate the view position of the Mesh on the z axis.Mesh.setPerspectiveis a new method that allows you to set a perspective projection matrix based on the given dimensions, fov, near and far values.Mesh.setOrthois a new method that allows you to set an orthographic projection matrix based on the given scale, near and far values.Mesh.clearis a new method that will destroy all Faces and Vertices and clear the Mesh.Mesh.depthSortis a new method that will run a depth sort across all Faces in the Mesh by sorting them based on their average depth.Mesh.addVertexis a new method that allows you to add a new single Vertex into the Mesh.Mesh.addFaceis a new method that allows you to add a new Face into the Mesh. A Face must consist of 3 Vertex instances.Mesh.getFaceCountnew is a new method that will return the total number of Faces in the Mesh.Mesh.getVertexCountnew is a new method that will return the total number of Vertices in the Mesh.Mesh.getFacenew is a new method that will return a Face instance from the Mesh based on the given index.Mesh.getFaceAtnew is a new method that will return an array of Face instances from the Mesh based on the given position. The position is checked against each Face, translated through the optional Camera and Mesh matrix. If more than one Face intersects, they will all be returned but the array will be depth sorted first, so the first element will be that closest to the camera.Mesh.verticesis now an array ofGameObject.Vertexinstances, not a Float32Array.Mesh.facesis a new array ofGameObject.Faceinstances, which is populated during a call to methods likeaddVerticesoraddModel.Mesh.totalRenderedis a new property that holds the total number of Faces that were rendered in the previous frame.Mesh.setDebugis a new method that allows you to render a debug visualization of the Mesh vertices to a Graphics Game Object. You can provide your own Graphics instance and optionally callback that is invoked during rendering. This allows you to easily visualize the vertices of your Mesh to help debug UV mapping.- The Mesh now renders by iterating through the Faces array, not the vertices. This allows you to use Array methods such as
BringToTopto reposition a Face, thus changing the drawing order without having to repopulate all of the vertices. Or, for a 3D model, you can now depth sort the Faces. - The
MeshGame Object now extends theSingleAlphacomponent and the alpha value is factored into the final alpha value per vertex during rendering. This means you can now set the whole alpha across the Mesh using the standardsetAlphamethods. But, if you wish to, you can still control the alpha on a per-vertex basis as well. - The Mesh renderer will now check to see if the pipeline capacity has been exceeded for every Face added, allowing you to use Meshes with vertex counts that exceed the pipeline capacity without causing runtime errors.
- You can now supply just a single numerical value as the
colorsparameter in the constructor, factory method andaddVerticesmethod. If a number, instead of an array, it will be used as the color for all vertices created. - You can now supply just a single numerical value as the
alphasparameter in the constructor, factory method andaddVerticesmethod. If a number, instead of an array, it will be used as the alpha for all vertices created. Mesh.debugGraphicis a new property that holds the debug Graphics instance reference.Mesh.debugCallbackis a new property that holds the debug render callback.Mesh.renderDebugVertsis a new method that acts as the default render callback forsetDebugif none is provided.Mesh.preDestroyis a new method that will clean-up the Mesh arrays and debug references on destruction.Mesh.isDirtyis a new method that will check if any of the data is dirty, requiring the vertices to be transformed. This is called automatically inpreUpdateto avoid generating lots of math when nothing has changed.- The
Mesh.uvarray has been removed. All UV data is now bound in the Vertex instances. - The
Mesh.colorsarray has been removed. All color data is now bound in the Vertex instances. - The
Mesh.alphasarray has been removed. All color data is now bound in the Vertex instances. - The
Mesh.tintFillproperty is now abooleanand defaults tofalse.
A Layer is a special type of Game Object that acts as a Display List. You can add any type of Game Object to a Layer, just as you would to a Scene. Layers can be used to visually group together 'layers' of Game Objects:
const spaceman = this.add.sprite(150, 300, 'spaceman');
const bunny = this.add.sprite(400, 300, 'bunny');
const elephant = this.add.sprite(650, 300, 'elephant');
const layer = this.add.layer();
layer.add([ spaceman, bunny, elephant ]);The 3 sprites in the example above will now be managed by the Layer they were added to. Therefore, if you then set layer.setVisible(false) they would all vanish from the display.
You can also control the depth of the Game Objects within the Layer. For example, calling the setDepth method of a child of a Layer will allow you to adjust the depth of that child within the Layer itself, rather than the whole Scene. The Layer, too, can have its depth set as well.
The Layer class also offers many different methods for manipulating the list, such as the methods moveUp, moveDown, sendToBack, bringToTop and so on. These allow you to change the display list position of the Layers children, causing it to adjust the order in which they are rendered. Using setDepth on a child allows you to override this.
Layers can have Post FX Pipelines set, which allows you to easily enable a post pipeline across a whole range of children, which, depending on the effect, can often be far more efficient that doing so on a per-child basis.
Layers have no position or size within the Scene. This means you cannot enable a Layer for physics or input, or change the position, rotation or scale of a Layer. They also have no scroll factor, texture, tint, origin, crop or bounds.
If you need those kind of features then you should use a Container instead. Containers can be added to Layers, but Layers cannot be added to Containers.
However, you can set the Alpha, Blend Mode, Depth, Mask and Visible state of a Layer. These settings will impact all children being rendered by the Layer.
BitmapText.setCharacterTintis a new method that allows you to set a tint color (either additive or fill) on a specific range of characters within a static Bitmap Text. You can specify the start and length offsets and per-corner tint colors.BitmapText.setWordTintis a new method that allows you to set a tint color (either additive or fill) on all matching words within a static Bitmap Text. You can specify the word by string, or numeric offset, and the number of replacements to tint.BitmapText.setDropShadowis a new method that allows you to apply a drop shadow effect to a Bitmap Text object. You can set the horizontal and vertical offset of the shadow, as well as the color and alpha levels. Call this method with no parameters to clear a shadow.BitmapTextWebGLRendererhas been rewritten from scratch to make use of the new pre-cached WebGL uv texture and character location data generated byGetBitmapTextSize. This has reduced the number of calculations made in the function dramatically, as it no longer has to work out glyph advancing or offsets during render, but only when the text content updates.BitmapText.getCharacterAtis a new method that will return the character data from the BitmapText at the givenxandycoordinates. The character data includes the code, position, dimensions, and glyph information.- The
BitmapTextSizeobject returned byBitmapText.getTextBoundshas a new property calledcharacterswhich is an array that contains the scaled position coordinates of each character in the BitmapText, which you could use for tasks such as determining which character in the BitmapText was clicked. ParseXMLBitmapFontwill now calculate the WebGL uv data for the glyphs during parsing. This avoids it having to be done during rendering, saving CPU cycles on an operation that never changes.ParseXMLBitmapFontwill now create a Frame object for each glyph. This means you could, for example, create a Sprite using the BitmapText texture and the glyph as the frame key, i.e.:this.add.sprite(x, y, fontName, 'A').BitmapTextWord,BitmapTextCharacterandBitmapTextLinesare three new type defs that are now part of theBitmapTextSizeconfig object, as returned bygetTextBounds. This improves the TypeScript defs and JS Docs for this object.- The signature of the
ParseXMLBitmapFontfunction has changed. Theframeparameter is no longer optional, and is now the second parameter in the list, instead of being the 4th. If you call this function directly, please update your code. - The
BitmapText.getTextBoundsmethod was being called every frame, even if the bounds didn't change, potentially costing a lot of CPU time depending on the text length and quantity of them. It now only updates the bounds if they change. - The
GetBitmapTextSizefunction usedMath.roundon the values, if theroundparameter wastrue, which didn't create integers. It now usesMath.ceilinstead to give integer results. - The
GetBitmapTextSizefunction has a new boolean parameterupdateOrigin, which will adjust the origin of the parent BitmapText if set, based on the new bounds calculations. BitmapText.preDestroyis a new method that will tidy-up all of the BitmapText data during object destruction.BitmapText.dropShadowXis a new property that controls the horizontal offset of the drop shadow on the Bitmap Text.BitmapText.dropShadowYis a new property that controls the vertical offset of the drop shadow on the Bitmap Text.BitmapText.dropShadowColoris a new property that sets the color of the Bitmap Text drop shadow.BitmapText.dropShadowAlphais a new property that sets the alpha of the Bitmap Text drop shadow.BatchCharis a new internal private function for batching a single character of a Bitmap Text to the pipeline.- If you give an invalid Bitmap Font key, the Bitmap Text object will now issue a
console.warn. - Setting the
colorvalue in theDynamicBitmapText.setDisplayCallbackwould inverse the red and blue channels if the color was not properly encoded for WebGL. It is now encoded automatically, meaning you can pass normal hex values as the colors in the display callback. Fix #5225 (thanks @teebarjunk) - If you apply
setSizeto the Dynamic BitmapText the scissor is now calculated based on the parent transforms, not just the local ones, meaning you can crop Bitmap Text objects that exist within Containers. Fix #4653 (thanks @lgibson02) ParseXMLBitmapFonthas a new optional parametertexture. If defined, this Texture is populated with Frame data, one frame per glyph. This happens automatically when loading Bitmap Text data in Phaser.- You can now use
setMaxWidthonDynamicBitmapText, which wasn't previously possible. Fix #4997 (thanks @AndreaBoeAbrahamsen)
The Quad Game Object has been removed from v3.50.0.
You can now create your own Quads easily using the new Geom.Mesh.GenerateGridVerts function, which is far more flexible than the old quads were.
If you use Animations in your game, please read the following important API changes in 3.50:
The Animation API has had a significant overhaul to improve playback handling. Instead of just playing an animation based on its global key, you can now supply a new PlayAnimationConfig object instead, which allows you to override any of the default animation settings, such as duration, delay and yoyo (see below for the full list). This means you no longer have to create lots of duplicate animations just to change properties such as duration, and can now set them dynamically at run-time as well.
- The
Animationclass no longer extendsEventEmitter, as it no longer emits any events directly. This means you cannot now listen for events directly from an Animation instance. All of the events are now dispatched by the Game Objects instead. - All of the
SPRITE_ANIMATION_KEYevents have been removed. Instead, please use the new events which all carry theframeKeyparameter, which can be used to handle frame specific events. The only exception to this isANIMATION_COMPLETE_KEY, which is a key specific version of the completion event. ANIMATION_UPDATE_EVENTis a new event that is emitted from a Sprite when an animation updates, i.e. its frame changes.ANIMATION_STOP_EVENTis a new event that is emitted from a Sprite when its current animation is stopped. This can happen if any of thestopmethods are called, or a new animation is played prior to this one reaching completion. Fix #4894 (thanks @scott20145)- The Game Object
Component.Animationcomponent has been renamed toAnimationStateand has moved namespace. It's now inPhaser.Animationsinstead ofGameObjects.Componentsto help differentiate it from theAnimationclass when browsing the documentation. - The
play,playReverse,playAfterDelay,playAfterRepeatandchainSprite and Animation Component methods can now all take aPhaser.Types.Animations.PlayAnimationConfigconfiguration object, as well as a string, as thekeyparameter. This allows you to override any default animation setting with those defined in the config, giving you far greater control over animations on a Game Object level, without needing to globally duplicate them. AnimationState.createis a new method that allows you to create animations directly on a Sprite. These are not global and never enter the Animation Manager, instead residing within the Sprite itself. This allows you to use the same keys across both local and global animations and set-up Sprite specific local animations.AnimationState.generateFrameNumbersis a new method that is a proxy for the same method available under the Animation Manager. It's exposed in the Animation State so you're able to access it from within a Sprite (thanks @juanitogan)AnimationState.generateFrameNamesis a new method that is a proxy for the same method available under the Animation Manager. It's exposed in the Animation State so you're able to access it from within a Sprite (thanks @juanitogan)- All playback methods:
play,playReverse,playAfterDelayandplayAfterRepeatwill now check to see if the given animation key exists locally on the Sprite first. If it does, it's used, otherwise it then checks the global Animation Manager for the key instead. AnimationState.skipMissedFramesis now used when playing an animation, allowing you to create animations that run at frame rates far exceeding the refresh rate, or that will update to the correct frame should the game lag. Feature #4232 (thanks @colorcube)AnimationManager.addMixis a new method that allows you to create mixes between two animations. Mixing allows you to specify a unique delay between a pairing of animations. When playing Animation A on a Game Object, if you then play Animation B, and a mix exists, it will wait for the specified delay to be over before playing Animation B. This allows you to customise smoothing between different types of animation, such as blending between an idle and a walk state, or a running and a firing state.AnimationManager.getMixis a new method that will return the mix duration between the two given animations.AnimationManager.removeMixis a new method that will remove the mixture between either two animations, or all mixtures for the given animation.AnimationState.removeis a new method that will remove a locally stored Animation instance from a Sprite.AnimationState.getis a new method that will return a locally stored Animation instance from the Sprite.AnimationState.existsis a new method that will check if a locally stored Animation exists on the Sprite.- The internal
AnimationState.removemethod has been renamed toglobalRemove. AnimationState.textureManageris a new property that references the global Texture Manager.AnimationState.animsis a new property that contains locally created Animations in a Custom Map.AnimationState.playandSprite.playno longer accept astartFrameparameter. Please set it via thePlayAnimationConfiginstead.AnimationState.playReverseandSprite.playReverseno longer accept astartFrameparameter. Please set it via thePlayAnimationConfiginstead.- The
AnimationState.delayedPlaymethod has been renamed toplayAfterDelay. The parameter order has also changed, so the key now comes first instead of the duration. - The
AnimationState.stopOnRepeatmethod has been renamed tostopAfterRepeat - The
AnimationState.getCurrentKeymethod has been renamed togetName. AnimationState.getFrameNameis a new method that will return the key of the current Animation Frame, if an animation has been loaded.AnimationState.playAfterDelayandSprite.playAfterDelayare new methods that will play the given animation after the delay in ms expires.AnimationState.playAfterRepeatandSprite.playAfterRepeatare new methods that will play the given animation after the current animation finishes repeating. You can also specify the number of repeats allowed left to run.- The
AnimationState.chainmethod is now available on the Sprite class. - The
AnimationState.stopAfterDelaymethod is now available on the Sprite class. - The
AnimationState.stopAfterRepeatmethod is now available on the Sprite class. - The
AnimationState.stopOnFramemethod is now available on the Sprite class. AnimationManager.createFromAsepriteis a new method that allows you to use animations created in the Aseprite editor directly in Phaser. Please see the comprehensive documentation for this method for full details on how to do this.AnimationStatenow handles all of the loading of the animation. It no longer has to make calls out to the Animation Manager or Animation instance itself and will load the animation data directly, replacing as required from the optionalPlayAnimationConfig. This improves performance and massively reduces CPU calls in animation heavy games.- The
PlayAnimationConfig.frameRateproperty lets you optionally override the animation frame rate. - The
PlayAnimationConfig.durationproperty lets you optionally override the animation duration. - The
PlayAnimationConfig.delayproperty lets you optionally override the animation delay. - The
PlayAnimationConfig.repeatproperty lets you optionally override the animation repeat counter. - The
PlayAnimationConfig.repeatDelayproperty lets you optionally override the animation repeat delay value. - The
PlayAnimationConfig.yoyoproperty lets you optionally override the animation yoyo boolean. - The
PlayAnimationConfig.showOnStartproperty lets you optionally override the animation show on start value. - The
PlayAnimationConfig.hideOnCompleteproperty lets you optionally override the animation hide on complete value. - The
PlayAnimationConfig.startFrameproperty lets you optionally set the animation frame to start on. - The
PlayAnimationConfig.timeScaleproperty lets you optionally set the animation time scale factor. AnimationState.delayCounteris a new property that allows you to control the delay before an animation will start playing. Only once this delay has expired, will the animationSTARTevents fire. Fix #4426 (thanks @bdaenen)AnimationState.hasStartedis a new boolean property that allows you to tell if the current animation has started playing, or is still waiting for a delay to expire.AnimationState.showOnStartis a new boolean property that controls if the Game Object should havesetVisible(true)called on it when the animation starts.AnimationState.hideOnCompleteis a new boolean property that controls if the Game Object should havesetVisible(false)called on it when the animation completes.- The
AnimationState.chainmethod docs said it would remove all pending animations if called with no parameters. However, it didn't - and now does! - The
AnimationState.setDelaymethod has been removed. It never actually worked and you can now perform the same thing by calling eitherplayAfterDelayor setting thedelayproperty in the play config. - The
AnimationState.getDelaymethod has been removed. You can now read thedelayproperty directly. - The
AnimationState.setRepeatmethod has been removed. You can achieve the same thing by setting therepeatproperty in the play config, or adjusting the publicrepeatCounterproperty if the animation has started. AnimationState.handleStartis a new internal private method that handles the animation start process.AnimationState.handleRepeatis a new internal private method that handles the animation repeat process.AnimationState.handleStopis a new internal private method that handles the animation stop process.AnimationState.handleCompleteis a new internal private method that handles the animation complete process.AnimationState.emitEventsis a new internal private method that emits animation events, cutting down on duplicate code.- The
AnimationState.restartmethod has a new optional boolean parameterresetRepeatswhich controls if you want to reset the repeat counter during the restart, or not. Animation.getTotalFramesis a new method that will return the total number of frames in the animation. You can access it viathis.anims.currentAnim.getTotalFramesfrom a Sprite.Animation.calculateDurationis a new method that calculates the duration, frameRate and msPerFrame for a given animation target.- The
BuildGameObjectAnimationfunction now uses thePlayAnimationConfigobject to set the values. Sprite.playReverseis a new method that allows you to play the given animation in reverse on the Sprite.Sprite.playAfterDelayis a new method that allows you to play the given animation on the Sprite after a delay.Sprite.stopis a new method that allows you to stop the current animation on the Sprite.AnimationManager.loadhas been removed as it's no longer required.AnimationManager.staggerPlayhas been fixed so you can now pass in negative stagger values.AnimationManager.staggerPlayhas a new optional boolean parameterstaggerFirst, which allows you to either include or exclude the first child in the stagger calculations.- The
Animation.completeAnimationmethod has been removed as it's no longer required. - The
Animation.loadmethod has been removed as it's no longer required. - The
Animation.setFramemethod has been removed as it's no longer required. - The
Animation.getFirstTickmethod has no longer needs theincludeDelayparameter, as it's handled byAnimationStatenow. - The
Animation.getFramesmethod has a new optional boolean parametersortFrameswhich will run a numeric sort on the frame names after constructing them, if a string-based frame is given. Types.Animations.Animationhas a new boolean propertysortFrames, which lets Phaser numerically sort the generated frames.AnimationState.timeScaleis a new public property that replaces the old private_timeScaleproperty.AnimationState.delayis a new public property that replaces the old private_delayproperty.AnimationState.repeatis a new public property that replaces the old private_repeatproperty.AnimationState.repeatDelayis a new public property that replaces the old private_repeatDelayproperty.AnimationState.yoyois a new public property that replaces the old private_yoyoproperty.AnimationState.inReverseis a new public property that replaces the old private_reverseproperty.AnimationState.startAnimationis a new public method that replaces the old private_startAnimationmethod.- The
AnimationState.getProgressmethod has been fixed so it will return correctly if the animation is playing in reverse. - The
AnimationState.globalRemovemethod will now always be called when an animation is removed from the global Animation Manager, not just once. - The
AnimationState.getRepeatmethod has now been removed. You can get the value from therepeatproperty. - The
AnimationState.setRepeatDelaymethod has now been removed. You can set the value using therepeatDelayconfig property, or changing it at run-time. AnimationState.completeis a new method that handles the completion in animation playback.- The
AnimationState.setTimeScalemethod has now been removed. You can set the value using thetimeScaleconfig property, or changing it at run-time. - The
AnimationState.getTimeScalemethod has now been removed. You can read the value using thetimeScaleproperty. - The
AnimationState.getTotalFramesmethod has been fixed and won't error if called when no animation is loaded. - The
AnimationState.setYoyomethod has now been removed. You can set the value using theyoyoconfig property, or changing it at run-time. - The
AnimationState.getYoyomethod has now been removed. You can read the value using theyoyoproperty. - The
AnimationState.stopAfterRepeatmethod now has an optional parameterrepeatCount, so you can tell the animation to stop after a specified number of repeats, not just 1. - When playing an animation in reverse, if it reached the first frame and had to repeat, it would then jump to the frame before the final frame and carry on, skipping out the final frame.
- The
AnimationState.updateFramemethod has now been removed. Everything is handled bysetCurrentFrameinstead, which removes one extra step out of the update process. GenerateFrameNameswill nowconsole.warnif the generated frame isn't present in the texture, which should help with debugging animation creation massively.GenerateFrameNumberswill nowconsole.warnif the generated frame isn't present in the texture, which should help with debugging animation creation massively.GenerateFrameNumberswould include the__BASEframe by mistake in its calculations. This didn't end up in the final animation, but did cause a cache miss when building the animation.GenerateFrameNumberscan now accept thestartandendparameters in reverse order, meaning you can now do{ start: 10, end: 1 }to create the animation in reverse.GenerateFrameNamescan now accept thestartandendparameters in reverse order, meaning you can now do{ start: 10, end: 1 }to create the animation in reverse.
There are three large changes to Tilemaps in 3.50. If you use tilemaps, you must read this section:
- The first change is that there are no longer
DynamicTilemapLayerandStaticTilemapLayerclasses. They have both been removed and replaced with the newTilemapLayerclass. This new class consolidates features from both and provides a lot cleaner API experience, as well as speeding up internal logic.
In your game where you use map.createDynamicLayer or map.createStaticLayer replace it with map.createLayer instead.
-
The second change is that the Tilemap system now supports isometric, hexagonal and staggered isometric map types, along with the previous orthogonal format, thanks to a PR from @svipal. You can now export maps using any of these orientations from the Tiled Map Editor and load them into Phaser using the existing tilemap loading API. No further changes need to take place in the way your maps are loaded.
-
The
Tilemap.createFromObjectsmethod has been overhauled to make it much more useful. The method signature has changed and it now takes a newCreateFromObjectLayerConfigconfiguration object, or an array of them, which allows much more fine-grained control over which objects in the Tiled Object Layers are converted and what they are converted to. Previously it could only convert to Sprites, but you can now pass in a custom class, filter based on id, gid or name, even provide a Container to add the created Game Objects to. Please see the new documentation for this method and the config object for more details. Fix #3817 #4613 (thanks @georgzoeller @Secretmapper)
- The
Tilemap.createDynamicLayermethod has been renamed tocreateLayer. - The
Tilemap.createStaticLayermethod has been removed. UsecreateLayerinstead. - The
Tilemap.createBlankDynamicLayermethod has been renamed tocreateBlankLayer. - The
Tilemap.convertLayerToStaticmethod has been removed as it is no longer required. - The
TilemapLayerWebGLRendererfunction will no longer iterate through the layer tilesets, drawing tiles from only that set. Instead all it does now is iterate directly through only the tiles. This allows it to take advantage of the new Multi Texturing pipeline and also draw multi-tileset isometric layers correctly. Phaser.Types.Tilemaps.TilemapOrientationTypeis a new type def that holds the 4 types of map orientation now supported.- The
Tile.updatePixelXYmethod now updates the tile XY position based on map type. ParseTilesetswill now correctly handle non-consecutive tile IDs. It also now correctly sets themaxIdproperty, fixing a bug where tiles wouldn't render if from IDs outside the expected range. Fix #4367 (thanks @jackfreak)Tilemap.hexSideLengthis a new property that holds the length of the hexagon sides, if using Hexagonal Tilemaps.LayerData.orientationis a new property that holds the tilemap layers orientation constant.LayerData.hexSideLengthis a new property that holds the length of the hexagon sides, if using Hexagonal Tilemaps.MapData.orientationis a new property that holds the tilemap layers orientation constant.MapData.hexSideLengthis a new property that holds the length of the hexagon sides, if using Hexagonal Tilemaps.Tilemaps.Components.HexagonalWorldToTileYis a new function that converts a world Y coordinate to hexagonal tile Y coordinate.Tilemaps.Components.StaggeredWorldToTileYis a new function that converts a world Y coordinate to staggered tile Y coordinate.Tilemaps.Components.HexagonalWorldToTileXYis a new function that converts world coordinates to hexagonal tile coordinates.Tilemaps.Components.IsometricWorldToTileXYis a new function that converts world coordinates to isometric tile coordinates.Tilemaps.Components.StaggeredWorldToTileXYis a new function that converts world coordinates to staggered tile coordinates.Tilemaps.Components.HexagonalTileToWorldYis a new function that converts a hexagonal Y coordinate to a world coordinate.Tilemaps.Components.StaggeredTileToWorldYis a new function that converts a staggered Y coordinate to a world coordinate.Tilemaps.Components.HexagonalTileToWorldXYis a new function that converts hexagonal tile coordinates to world coordinates.Tilemaps.Components.IsometricTileToWorldXYis a new function that converts isometric tile coordinates to world coordinates.Tilemaps.Components.StaggeredTileToWorldXYis a new function that converts staggered tile coordinates to world coordinates.Tilemaps.Components.GetTileToWorldXFunctionis a new function that returns the correct conversion function to use.Tilemaps.Components.GetTileToWorldYFunctionis a new function that returns the correct conversion function to use.Tilemaps.Components.GetTileToWorldXXFunctionis a new function that returns the correct conversion function to use.Tilemaps.Components.GetWorldToTileXFunctionis a new function that returns the correct conversion function to use.Tilemaps.Components.GetWorldToTileYFunctionis a new function that returns the correct conversion function to use.Tilemaps.Components.GetWorldToTileXYFunctionis a new function that returns the correct conversion function to use.Tilemaps.Components.GetCullTilesFunctionis a new function that returns the correct culling function to use.Tilemaps.Components.HexagonalCullTilesis a new function that culls tiles in a hexagonal map.Tilemaps.Components.StaggeredCullTilesis a new function that culls tiles in a staggered map.Tilemaps.Components.IsometricCullTilesis a new function that culls tiles in a isometric map.Tilemaps.Components.CullBoundsis a new function that calculates the cull bounds for an orthogonal map.Tilemaps.Components.HexagonalCullBoundsis a new function that calculates the cull bounds for a hexagonal map.Tilemaps.Components.StaggeredCullBoundsis a new function that calculates the cull bounds for a staggered map.Tilemaps.Components.RunCullis a new function that runs the culling process from the combined bounds and tilemap.Tilemap._convertis a new internal private hash of tilemap conversion functions used by the public API.- The
Tilemap._isStaticCallmethod has been removed and no Tilemap methods now check this, leading to faster execution. - The Arcade Physics Sprites vs. Tilemap Layers flow has changed. Previously, it would iterate through a whole bunch of linked functions, taking lots of jumps in the process. It now just calls the
GetTilesWithinWorldXYcomponent directly, saving lots of overhead. - The method
Tilemap.weightedRandomizehas changed so that the parameterweightedIndexesis now first in the method and is non-optional. Previously, it was the 5th parameter and incorrectly flagged as optional. - The method
TilemapLayer.weightedRandomizehas changed so that the parameterweightedIndexesis now first in the method and is non-optional. Previously, it was the 5th parameter and incorrectly flagged as optional.
The way in which Game Objects add themselves to the Scene Update List has changed. Instead of being added by the Factory methods, they will now add and remove themselves based on the new ADDED_TO_SCENE and REMOVED_FROM_SCENE events. This means, you can now add Sprites directly to a Container, or Group, and they'll animate properly without first having to be part of the Update List. The full set of changes and new features relating to this follow:
GameObjects.Events.ADDED_TO_SCENEis a new event, emitted by a Game Object, when it is added to a Scene, or a Container that is part of the Scene.GameObjects.Events.REMOVED_FROM_SCENEis a new event, emitted by a Game Object, when it is removed from a Scene, or a Container that is part of the Scene.Scenes.Events.ADDED_TO_SCENEis a new event, emitted by a Scene, when a new Game Object is added to the display list in the Scene, or a Container that is on the display list.Scenes.Events.REMOVED_FROM_SCENEis a new event, emitted by a Scene, when it a Game Object is removed from the display list in the Scene, or a Container that is on the display list.GameObject.addedToSceneis a new method that custom Game Objects can use to perform additional set-up when a Game Object is added to a Scene. For example, Sprite uses this to add itself to the Update List.GameObject.removedFromSceneis a new method that custom Game Objects can use to perform additional tear-down when a Game Object is removed from a Scene. For example, Sprite uses this to remove themselves from the Update List.- Game Objects no longer automatically remove themselves from the Update List during
preDestroy. This should be handled directly in theremovedFromScenemethod now. - The
Containerwill now test to see if any Game Object added to it is already on the display list, or not, and emit its ADDED and REMOVED events accordingly. Fix #5267 #3876 (thanks @halgorithm @mbpictures) DisplayList.eventsis a new property that references the Scene's Event Emitter. This is now used internally.DisplayList.addChildCallbackis a new method that overrides the List callback and fires the new ADDED events.DisplayList.removeChildCallbackis a new method that overrides the List callback and fires the new REMOVED events.GameObjectCreator.eventsis a new property that references the Scene's Event Emitter. This is now used internally.GameObjectFactory.eventsis a new property that references the Scene's Event Emitter. This is now used internally.ProcessQueue.checkQueueis a new boolean property that will make sure only unique objects are added to the Process Queue.- The
Update Listnow uses the newcheckQueueproperty to ensure no duplicate objects are on the active list. DOMElementFactory,ExternFactory,ParticleManagerFactor,RopeFactoryandSpriteFactoryall no longer add the objects to the Update List, this is now handled by the ADDED events instead.Sprite,Rope,ParticleEmitterManager,ExternandDOMElementnow all override theaddedToSceneandremovedFromScenecallbacks to handle further set-up tasks.
ScaleManager.refreshis now called when theGame.READYevent fires. This fixes a bug where the Scale Manager would have the incorrect canvas bounds, because they were calculated before a previous canvas was removed from the DOM. Fix #4862 (thanks @dranitski)- The Game Config property
inputMouseCapturehas been removed, as this is now split into 3 new config options: inputMousePreventDefaultDownis a new config option that allows you to controlpreventDefaultcalls specifically on mouse down events. Set it viainput.mouse.preventDefaultDownin the Game Config. It defaults totrue, the same as the previouscaptureproperty did.inputMousePreventDefaultUpis a new config option that allows you to controlpreventDefaultcalls specifically on mouse up events. Set it viainput.mouse.preventDefaultUpin the Game Config. It defaults totrue, the same as the previouscaptureproperty did.inputMousePreventDefaultMoveis a new config option that allows you to controlpreventDefaultcalls specifically on mouse move events. Set it viainput.mouse.preventDefaultMovein the Game Config. It defaults totrue, the same as the previouscaptureproperty did.inputMousePreventDefaultWheelis a new config option that allows you to controlpreventDefaultcalls specifically on mouse wheel events. Set it viainput.mouse.preventDefaultWheelin the Game Config. It defaults totrue, the same as the previouscaptureproperty did.- The
MouseManager.captureproperty has been removed, as this is now split into 3 new config options (see below) MouseManager.preventDefaultDownis a new boolean property, set via theinputMousePreventDefaultDownconfig option that allows you to toggle capture of mouse down events at runtime.MouseManager.preventDefaultUpis a new boolean property, set via theinputMousePreventDefaultUpconfig option that allows you to toggle capture of mouse up events at runtime.MouseManager.preventDefaultMoveis a new boolean property, set via theinputMousePreventDefaultMoveconfig option that allows you to toggle capture of mouse move events at runtime.MouseManager.preventDefaultWheelis a new boolean property, set via theinputMousePreventDefaultWheelconfig option that allows you to toggle capture of mouse wheel at runtime.- In the
MouseManagerthe up, down and move events are no longer set as being passive if captured. Over, Out, Wheel and the Window level Down and Up events are always flagged as being passive. Wheel events are non-passive if capturing is enabled. - The
GamepadPluginwill now callrefreshPadsas part of its start process. This allows you to use Gamepads across multiple Scenes, without having to wait for a connected event from each one of them. If you've already had a connected event in a previous Scene, you can now just read the pads directly viathis.input.gamepad.pad1and similar. Fix #4890 (thanks @Sytten) - Shutting down the Gamepad plugin (such as when sleeping a Scene) no longer calls
GamepadPlugin.disconnectAll, but destroying it does. Gamepad._createdis a new private internal property that keeps track of when the instance was created. This is compared to the navigator timestamp in the update loop to avoid event spamming. Fix #4890.Pointer.downwill now check if the browser is running under macOS and if the ctrl key was also pressed, if so, it will flag the down event as being a right-click instead of a left-click, as per macOS conventions. Fix #4245 (thanks @BigZaphod)- When destroying an interactive Game Object that had
useHandCursorenabled, it would reset the CSS cursor to default, even if the cursor wasn't over that Game Object. It will now only reset the cursor if it's over the Game Object being destroyed. Fix #5321 (thanks @JstnPwll) - The
InputPlugin.shutdownmethod will now reset the CSS cursor, in case it was set by any Game Objects in the Scene that have since been destroyed. - The
InputPlugin.processOverEventshas had a duplicate internal loop removed from it (thanks KingCosmic)
Phaser has had the ability to apply an additive tint to a Game Object since the beginning, and gained 'filled tints', with and without texture alpha, in v3.11. While this was handy, it introduced a 3-way if-else condition to the shaders to handle the different modes. Plus, setting tint colors was also generating rgb order Float32 color values for each Game Object, making reading those colors back again difficult (as they'd return in BGR order).
This has all changed in 3.50, as outlined below. Tint values are now used directly in the shader and don't pass through a color conversion function first. Lots of private properties have been removed and the shaders no longer have a 3-way if-else block. All of this means improved performance and a slight reduction in memory overhead.
Tint.tintTopLeftis now a normal property in RGB order, not a setter, and no longer passes through theGetColorFromValuefunction. This directly replaces the private property_tintTLwhich has now been removed.Tint.tintTopRightis now a normal property in RGB order, not a setter, and no longer passes through theGetColorFromValuefunction. This directly replaces the private property_tintTRwhich has now been removed.Tint.tintBottomLeftis now a normal property in RGB order, not a setter, and no longer passes through theGetColorFromValuefunction. This directly replaces the private property_tintBLwhich has now been removed.Tint.tintBottomRightis now a normal property in RGB order, not a setter, and no longer passes through theGetColorFromValuefunction. This directly replaces the private property_tintBRwhich has now been removed.- The property
Tint._isTintedhas been removed as it's no longer required. - The
Single.frag,Light.fragandMulti.fragshaders have all been updated so they now read the color value asoutTint.bgrinstead ofoutTint.rgb. This allows the colors to remain in RGB order within the Tint component. - The
Single.frag,Light.fragandMulti.fragshaders have all been updated so they no longer have a 3-way check on theoutTintEffectvalue. - The
Multi Pipeline,Bitmap Text,Render Texture,Text,TileSpriteandCameranow all read the tint values from the public properties instead of the private_tintTLetc ones. They also now set thetintEffectvalue directly from thetintFillproperty, removing another conditional check. - The function
GetColorFromValuehas been removed as it's no longer used internally. - The
Rope.tintFillproperty is now a boolean, not an integer, and can no longer take2as a value for a complete fill. Instead, you should provide a solid color texture with no alpha. - As a result of the change to the shader, all uses of the WebGL Util function
getTintAppendFloatAlphaAndSwaphave been replaced withgetTintAppendFloatAlphainstead. - As a result of the change to the shader, the Multi Pipeline now uses the
WebGLRenderer.whiteTextureandtintEffectmode of 1 by default, instead of mode 2 (which has been removed) and a transparent texture. This ensures Graphics and Shapes objects still render correctly under the new smaller shader code. WebGLRenderer.whiteTextureis a new property that is a reference to a pure white 4x4 texture that is created during Boot by the Texture Manager. The Graphics Pipeline uses this internally for all geometry fill rendering.- The
TextureManagernow generates a new texture with the key__WHITEduring its boot process. This is a pure white 4x4 texture used by the Graphics pipelines. Config.images.whiteis a new Game Config property that specifies the 4x4 white PNG texture used by Graphics rendering. You can override this via the config, but only do so if needed.
Prior to v3.50 an Arcade Physics Body could be one of two states: immovable, or movable. An immovable body could not receive any impact from another Body. If something collided with it, it wouldn't even separate to break free from the collision (the other body had to take the full separation value). It was intended for objects such as platforms, ground or walls, there they absolutely shouldn't move under any circumstances. As a result, two immovable bodies could never be collided together. While this worked for scenery-like items, it didn't work if you required maybe 2 players who could collide with each other, but should never be able to push one another. As of 3.50 all physics bodies now have a new property pushable that allows this. A pushable body can share separation with its collider, as well as take on mass-based velocity from the impact. A non-pushable body will behave differently depending on what it collides with. For example, a pushable body hitting a non-pushable (or immovable) body will rebound off it.
- The Arcade Physics
Bodyclass has a new boolean propertypushable(true, by default). This allows you to set if a Body can be physically pushed by another Body, or not. Fix #4175 #4415 (thanks @inmylo @CipSoft-Components) Body.setPushableis a new chainable method that allows you to set thepushablestate of a Body.Arcade.Components.Pushableis a new component, inherited by the standard Arcade Physics Image and Sprite classes.- Bodies will now check to see if they are blocked in the direction they're being pushed, before resolving the collision. This helps stop some bodies from being pushed into other objects.
- Bodies will now check which direction they were moving and separate accordingly. This helps stop some bodies from being pushed into other objects.
ArcadePhysics.disableUpdateis a new method that will prevent the Arcade Physics Worldupdatemethod from being called when the Scene updates. By disabling it, you're free to call the update method yourself, passing in your own delta and time values.ArcadePhysics.enableUpdateis a new method that will make the Arcade Physics World update in time with the Scene update. This is the default, so only call this if you have specifically disabled it previously.ArcadeWorldConfig.customUpdateis a new boolean property you can set in the Arcade Physics config object, either in the Scene or in the Game Config. Iftruethe World update will never be called, allowing you to call it yourself from your own component. Close #5190 (thanks @cfortuner)Physics.Arcade.Body.setCollideWorldBoundsnow has a new optional parameteronWorldBoundswhich allows you to enable the Body'sonWorldBoundsproperty in the same call (thanks @samme)ArcadePhysics.Body.setMaxVelocityXis a new method that allows you to set the maximum horizontal velocity of a Body (thanks @samme)ArcadePhysics.Body.setMaxVelocityYis a new method that allows you to set the maximum vertical velocity of a Body (thanks @samme)- The
PhysicsGroupconfig now has two new optional propertiesmaxVelocityXandmaxVelocityYwhich allows you to set the maximum velocity on bodies added to the Group (thanks @samme) - The
Arcade.Body.resetFlagsmethod has a new optional boolean parameterclear. If set, it clears thewasTouchingflags on the Body. This happens automatically whenBody.resetis called. Previous to this, the flags were not reset until the next physics step (thanks @samme) Physics.Arcade.ProcessXis a new set of functions, called by theSeparateXfunction, that handles all of the different collision tests, checks and resolutions. These functions are not exposed in the public API.Physics.Arcade.ProcessYis a new set of functions, called by theSeparateYfunction, that handles all of the different collision tests, checks and resolutions. These functions are not exposed in the public API.Arcade.Body.centervalues were incorrect after collisions with the world bounds or (for rectangular bodies) after collisions with another body. The body center is now updated after those separations (thanks @samme)- The Arcade Physics
WORLD_STEPevent now has a new parameter: the delta argument (thanks @samme) - The Arcade Body
dragproperty has been redefined when damping is used and scales the damping multiplier by the physics step delta. Drag is now the velocity retained after 1 second instead of after 1 step, when damping is used. This makes damping consistent for different physics step rates and more accurate when fixedStep is off. If you usedragyou will need to change any existing drag values to get the same effects as before. Convertdragtodrag ^ 60ordrag ^ fpsif you use a different step rate (thanks @samme)
Geom.Intersects.GetLineToLineis a new function that will return a Vector3 containing the point of intersection between 2 line segments, with thezproperty holding the distance value.Geom.Intersects.GetLineToPolygonis a new function that checks for the closest point of intersection between a line segment and an array of polygons.Geom.Intersects.GetLineToPointsis a new function that checks for the closest point of intersection between a line segment and an array of points, where each pair of points form a line segment.Geom.Intersects.GetRaysFromPointToPolygonis a new function that emits rays out from the given point and detects for intersection against all given polygons, returning the points of intersection in the results array.Geom.Polygon.Translateis a new function that allows you to translate all the points of a polygon by the given values.Geom.Polygon.Simplifyis a new function that takes a polygon and simplifies the points by running them through a combination of Douglas-Peucker and Radial Distance algorithms, potentially dramatically reducing the number of points while retaining its shape.Phaser.Types.Math.Vector3Likeis a new data type representing as Vector 3 like object.Phaser.Types.Math.Vector4Likeis a new data type representing as Vector 4 like object.Transform.getLocalPointis a new method, available on all Game Objects, that takes anx/ypair and translates them into the local space of the Game Object, factoring in parent transforms and display origins.- The
KeyboardPluginwill now track the key code and timestamp of the previous key pressed and compare it to the current event. If they match, it will skip the event. On some systems, if you were to type quickly, you would sometimes get duplicate key events firing (the exact same event firing more than once). This is now prevented from happening. Display.Color.GetColorFromValueis a new function that will take a hex color value and return it as an integer, for use in WebGL. This is now used internally by the Tint component and other classes.Utils.String.RemoveAtis a new function that will remove a character from the given index in a string and return the new string.Frame.setUVsis a new method that allows you to directly set the canvas and UV data for a frame. Use this if you need to override the values set automatically during frame creation.TweenManager.getTweensOfhas a new parameterincludePending. If set, it will also check the pending tweens for the given targets and return those in the results as well. Fix #5260 (thanks @pcharest2000)WebGLPipeline.hasBootedis a new boolean property that tracks if the pipeline has been booted or not, which is now far more important in 3.5 than in previous versions. This is checked in theWebGLRenderer.addPipelinemethod, and if not set, the pipeline is booted. Fix #5251 #5255 (thanks @telinc1 @rexrainbow)- The WebGL Renderer will now add the pipelines during the
bootmethod, instead ofinit. - You can now use
this.rendererfrom within a Scene, as it's now a Scene-level property and part of the Injection Map. Clock.addEventcan now take an existingTimerEventobject, as well as a config object. If aTimerEventis given it will be removed from the Clock, reset and then added. This allows you to pool TimerEvents rather than constantly create and delete them. Fix #4115 (thanks @jcyuan)Clock.removeEventis a new method that allows you to remove aTimerEvent, or an array of them, from all internal lists of the current Clock.Group.getMatchingis a new method that will return any members of the Group that match the given criteria, such asgetMatching('visible', true)(thanks @atursams)Utils.Array.SortByDigitsis a new function that takes the given array of strings and runs a numeric sort on it, ignoring any non-digits.GroupCreateConfig, which is used when callingGroup.createMultipleorGroup.createFromConfig, can now accept the following new properties:setOrigin: { x, y, stepX, stepY }which are applied to the items created by the Group.Transform.copyPositionis a new method that will copy the position from the given object to the Game Object (thanks @samme)- The
Text.MeasureTextfunction, which is used to calculate the ascent and descent of Text Game Objects whenever the style, or font size, is changed, has been updated to use the newactualBoundingBoxAscentfunctions present in modern browsers. This allows for significantly faster ascent calculations than previously. Older browsers, such as IE, will still fall back (thanks @rexrainbow) GameObjects.GetCalcMatrixis a new function that is used to calculate the transformed Game Object matrix, based on the given Game Object, Camera and Parent. This function is now used by the following Game Objects:BitmapText(Static and Dynamic),Graphics,Extern,Mesh,Rope,Shader,Arc,Curve,Ellipse,Grid,IsoBox,IsoTriangle,Line,Polygon,Rectangle,StarandTriangle. This dramatically reduces the amount of duplicate code across the API.Utils.Array.Matrix.Translateis a new function that will translate an Array Matrix by horizontally and vertically by the given amounts.Vertor3.addScaleis a new method that will add the given vector and multiply it in the process.- When defining the ease used with a Particle Emitter you can now set
easeParamsin the config object, allowing you to pass custom ease parameters through to an ease function (thanks @vforsh) BitmapMask.createMaskis a new method that will internally create the WebGL textures and framebuffers required for the mask. This is now used by the constructor and if the context is lost. It now also clears any previous textures/fbos that may have been created first, helping prevent memory leaks.BitmapMask.clearMaskwill delete any WebGL textures or framebuffers the mask is using. This is now called when the mask is destroyed, or a new mask is created upon it.Quaternionnow has a new propertyonChangeCallbackwhich, if set, will be invoked each time the quaternion is updated. This allows you to link change events to other objects.- The
Quaternion.setmethod has a new optional boolean parameterupdate(defaults totrue), which will call theonChangeCallbackif set. Quaternion.setFromEuleris a new method that will set the quaternion from the givenEulerobject, optionally calling theonChangeCallbackin the process.Quaternion.setFromRotationMatrixis a new method that will set the rotation of the quaternion from the given Matrix4.Vector3.setFromMatrixPositionis a new method that will set the components of the Vector3 based on the position of the given Matrix4.Vector3.setFromMatrixColumnis a new method that will set the components of the Vector3 based on the specified Matrix4 column.Vector3.fromArrayis a new method that will set the components of the Vector3 based on the values in the given array, at the given offset.Vector3.minis a new method that will set the components of the Vector3 based on theMain.minbetween it and the given Vector3.Vector3.maxis a new method that will set the components of the Vector3 based on theMain.maxbetween it and the given Vector3.Vector3.addVectorsis a new method that will set the components of the Vector3 based on the addition of the two Vector3s given.Vector3.addScalaris a new method that will multiply the components of the Vector3 by the scale value given.Vector3.applyMatrix3is a new method that will take a Matrix3 and apply it to the Vector3.Vector3.applyMatrix4is a new method that will take a Matrix4 and apply it to the Vector3.Vector3.projectViewMatrixis a new method that multiplies the Vector3 by the given view and projection matrices.Vector3.unprojectViewMatrixis a new method that multiplies the Vector3 by the given inversed projection matrix and world matrix.Matrix4.setValuesis a new method that allows you to set all of the matrix components individually. Most internal methods now use this.Matrix.multiplyToMat4is a new method that multiplies a Matrix4 by the givensrcMatrix4 and stores the results in theoutMatrix4.Matrix4.fromRotationXYTranslationis a new method that takes the rotation and position vectors and builds this Matrix4 from them.Matrix4.getMaxScaleOnAxisis a new method that will return the maximum axis scale from the Matrix4.Matrix4.lookAtRHis a new method that will generate a right-handed look-at matrix from the given eye, target and up positions.Matrix4.transformis a new method that will generate a transform matrix from the given position and scale vectors and a rotation quaternion.Matrix4.multiplyMatricesis a new method that multiplies two given Matrix4 objects and stores the results in the Matrix4.Matrix4.premultiplyis a new method that takes a Matrix4 and multiplies it by the current Matrix4.Matrix4.getInverseis a new method that takes a Matrix4, copies it to the current matrix, then returns the inverse of it.CameraManager.getVisibleChildrenis a new method that is called internally by theCameraManager.rendermethod. It filters the DisplayList, so that Game Objects that pass thewillRendertest for the given Camera are added to a sub-list, which is then passed to the renderer. This avoids the renderer having to do any checks on the children, it just renders each one in turn.Physics.Arcade.Body.setDampingis a new method that allows you to set theuseDampingproperty of a Body in a chainable way. Fix #5352 (thanks @juanitogan)- The
GameObjects.Graphics.fillGradientStylemethod can now accept a different alpha value for each of the fill colors. The default is still 1. If you only provide a single alpha, it'll be used for all colors. Fix #5044 (thanks @zhangciwu) Types.Core.PipelineConfigis a new configuration object that you can set in the Game Config under thepipelineproperty. It allows you to define custom WebGL pipelines as part of the Game Config, so they're automatically installed and ready for use by all Scenes in your game. You can either set thepipelineobject, or set it under therendersub-config.Utils.Object.DeepCopyis a new function that will recursively deep copy an array of object.Time.TimerEvent.getRemainingis a new method that returns the time interval until the next iteration of the Timer Event (thanks @samme)Time.TimerEvent.getRemainingSecondsis a new method that returns the time interval until the next iteration of the Timer Event in seconds (thanks @samme)Time.TimerEvent.getOverallRemainingis a new method that returns the time interval until the last iteration of the Timer Event (thanks @samme)Time.TimerEvent.getOverallRemainingSecondsis a new method that returns the time interval until the last iteration of the Timer Event in seconds (thanks @samme)GameObjects.Video.loadMediaStreamis a new method that allows you to hook a Video Game Object up to a Media Stream, rather than a URL, allowing you to stream video from a source such as a webcam (thanks @pirateksh)Display.Color.ColorSpectrumis a new function that will return an array of 1024 Color Object elements aligned in a Color Spectrum layout, where the darkest colors have been omitted.AsepriteFileis a new File Type for the Loader that allows you to load Aseprite images and animation data for use with the new Aseprite animation features. You can call this viathis.load.asesprite(png, json).GameObject.displayListis a new property that contains a reference to the Display List to which the Game Object has been added. This will typically either by the Display List owned by a Scene, or a Layer Game Object. You should treat this property as read-only.- The
ShaderGame Object now supports being able to use a Render Texture as asampler2Dtexture on the shader #5423 (thanks @ccaleb) BaseSound.pan,HTMLAudioSound.panandWebAudioSound.panare new properties that allow you to get or set the pan value of a sound, a value between -1 (full left pan) and 1 (full right pan). Note that pan only works under Web Audio, but the property and event still exists under HTML5 Audio for compatibility (thanks @pi-kei)WebAudioSound.setPanis a new method that allows you to set the pan of the sound. A value between -1 (full left pan) and 1 (full right pan) (thanks @pi-kei)Sound.Events.PANis a new event dispatched by both Web Audio and HTML5 Audio Sound objects when their pan changes (thanks @pi-kei)
Phaser.Display.ColorMatrixis a new class that allows you to create and manipulate a 5x4 color matrix, which can be used by shaders or graphics operations.- The
ColorMatrix.setmethod allows you to set the values of a ColorMatrix. - The
ColorMatrix.resetmethod will reset the ColorMatrix to its default values. - The
ColorMatrix.getDatamethod will return the data in the ColorMatrix as a Float32Array, useful for setting in a shader uniform. - The
ColorMatrix.brightnessmethod lets you set the brightness of the ColorMatrix. - The
ColorMatrix.saturatemethod lets you set the saturation of the ColorMatrix. - The
ColorMatrix.desaturatemethod lets you desaturate the colors in the ColorMatrix. - The
ColorMatrix.huemethod lets you rotate the hues of the ColorMatrix by the given amount. - The
ColorMatrix.grayscalemethod converts the ColorMatrix to grayscale. - The
ColorMatrix.blackWhitemethod converts the ColorMatrix to black and whites. - The
ColorMatrix.contrastmethod lets you set the contrast of the ColorMatrix. - The
ColorMatrix.negativemethod converts the ColorMatrix to negative values. - The
ColorMatrix.desaturateLuminancemethod applies a desaturated luminance to the ColorMatrix. - The
ColorMatrix.sepiamethod applies a sepia tone to the ColorMatrix. - The
ColorMatrix.nightmethod applies a night time effect to the ColorMatrix. - The
ColorMatrix.lsdmethod applies a trippy color effect to the ColorMatrix. - The
ColorMatrix.brownmethod applies a brown tone to the ColorMatrix. - The
ColorMatrix.vintagePinholemethod applies a vintage pinhole color effect to the ColorMatrix. - The
ColorMatrix.kodachromemethod applies a kodachrome color effect to the ColorMatrix. - The
ColorMatrix.technicolormethod applies a technicolor color effect to the ColorMatrix. - The
ColorMatrix.polaroidmethod applies a polaroid color effect to the ColorMatrix. - The
ColorMatrix.shiftToBGRmethod shifts the values of the ColorMatrix into BGR order. - The
ColorMatrix.multiplymethod multiplies two ColorMatrix data sets together.
- Earcut, used for polygon triangulation, has been updated from 2.1.4 to 2.2.2.
- Earcut has now been exposed and is available via
Geom.Polygon.Earcutand is fully documented. Config.batchSizehas been increased from 2000 to 4096.- Removed the Deferred Diffuse fragment and vertex shaders from the project, as they're not used.
StaticTilemapLayer.uploadwill now set the vertex attributes and buffer the data, and handles internal checks more efficiently.StaticTilemapLayernow includes theModelViewProjectionmixin, so it doesn't need to modify the pipeline during rendering.TransformMatrix.getXRoundis a new method that will return the X component, optionally passed viaMath.round.TransformMatrix.getYRoundis a new method that will return the Y component, optionally passed viaMath.round.- The
KeyboardPluginno longer emitskeydown_events. These were replaced withkeydown-events in v3.15. The previous event string was deprecated in v3.20. - The
KeyboardPluginno longer emitskeyup_events. These were replaced withkeyup-events in v3.15. The previous event string was deprecated in v3.20. - The
ScaleManager.updateBoundsmethod is now called every time the browser fires a 'resize' or 'orientationchange' event. This will update the offset of the canvas element Phaser is rendering to, which is responsible for keeping input positions correct. However, if you change the canvas position, or visibility, via any other method (i.e. via an Angular route) you should call theupdateBoundsmethod directly, yourself. - The constant
Phaser.Renderer.WebGL.BYTEvalue has been removed as it wasn't used internally. - The constant
Phaser.Renderer.WebGL.SHORTvalue has been removed as it wasn't used internally. - The constant
Phaser.Renderer.WebGL.UNSIGNED_BYTEvalue has been removed as it wasn't used internally. - The constant
Phaser.Renderer.WebGL.UNSIGNED_SHORTvalue has been removed as it wasn't used internally. - The constant
Phaser.Renderer.WebGL.FLOATvalue has been removed as it wasn't used internally. Pointer.downTimenow stores the event timestamp of when the first button on the input device was pressed down, not just when button 1 was pressed down.Pointer.upTimenow stores the event timestamp of when the final depressed button on the input device was released, not just when button 1 was released.- The
Pointer.getDurationmethod now uses the new PointerdownTimeandupTimevalues, meaning it will accurately report the duration of when any button is being held down, not just the primary one. Fix #5112 (thanks @veleek) - The
BaseShaderdefault vertex shader now includes theoutTexCoordvec2 varying, mapped to be the same as that found in the pipeline shaders. Fix #5120 (@pavel-shirobok) - When using the
GameObjectCreatorforContainersyou can now specify thechildrenproperty in the configuration object. Textures.Parsers.JSONHashwill now perform ahasOwnPropertycheck when iterating the frames, skipping anything that isn't a direct property. This should allow you to use generated atlas data that comes fromJSON.parse. Fix #4768 (thanks @RollinSafary)- The
Camera3DPlugin has been rebuilt for Phaser 3.50 and the webpack config updated. This plugin is now considered deprecated and will not be updated beyond this release. Tween.seekwill no longer issue a console warning for'Tween.seek duration too long', it's now up to you to check on the performance of tween seeking.- If
inputWindowEventsis set in the Game Config, then theMouseManagerwill now listen for the events onwindow.topinstead of justwindow, which should help in situations where the pointer is released outside of an embedded iframe. This check is wrapped in atry/catchblock, as not all sites allow access towindow.top(specifically in cross-origin iframe situations) Fix #4824 (thanks @rexrainbow) MouseManager.isTopis a new boolean read-only property that flags if the mouse event listeners were attached towindow.top(true), or justwindow(false). By default Phaser will attemptwindow.top, but this isn't possible in all environments, such as cross-origin iframes, so it will fall back towindowin those cases and set this property to false (thanks BunBunBun)Types.GameObjects.Text.GetTextSizeObjectis a new type def for the GetTextSize function results.Utils.Array.StableSorthas been recoded. It's now based on Two-Screens stable sort 0.1.8 and has been updated to fit into Phaser better and no longer create any window bound objects. Theinplacefunction has been removed, just callStableSort(array)directly now. All classes that usedStableSort.inplacehave been updated to call it directly.- If a Scene is paused, or sent to sleep, it will automatically call
Keyboard.resetKeys. This means that if you hold a key down, then sleep or pause a Scene, then release the key and resume or wake the Scene, it will no longer think it is still being held down (thanks @samme) Actions.setOriginwill now callupdateDisplayOriginon the items array, otherwise the effects can't be seen when rendering.- You can now set the
ArcadeWorld.fixedStepproperty via theArcadeWorldConfigobject (thanks @samme) Utils.Array.NumerArraycan now accept thestartandendparameters in reverse order, i.e.10, 1will generate a number array running from 10 to 1. Internally it has also been optimized to skip string based returns.DataManager.Events.DESTROYis a new event that the Data Manager will listen for from its parent and then call its owndestroymethod when received.- The
Quaternionclass constructor will now default the values to0,0,0,1if they're not provided, making it an identity quaternion, rather than the0,0,0,0it was before. - You can now set the
ParticleEmitter.reservevalue via the emitter configuration object (thanks @vforsh) - Setting the
pixelArtconfig option will now setantialiasGLtofalse, as well asantialias. Fix #5309 (thanks @Vegita2) - The
Shapeclass now includes theComputedSizecomponent properties and methods directly in the class, rather than applying as a mixin.setSizeis now flagged as beingprivate, because it shouldn't be used on Shape classes, which was leading to confusion as it appeared in the public-facing API. Fix #4811 (thanks @aolsx) - The
Loader.maxParallelDownloadsvalue is now set to 6 if running on Android, or 32 on any other OS. This avoidsnet::ERR_FAILEDissues specifically on Android. You can still override this in the Game Config if you wish. Fix #4957 (thanks @RollinSafary) - When running an Arcade Physics
overlaptest against aStaticBody, it will no longer set theblockedstates of the dynamic body. If you are doing a collision test, they will still be set, but they're skipped for overlap-only tests. Fix #4435 (thanks @samme) - The
LineGame Object will now default its width and height to 1, rather than zero. This allows you to give Line objects a physics body (although you will still need to re-adjust the center of the body manually). Fix #4596 (thanks @andrewaustin) - Internally, the
Quaternionclass now has 4 new private properties:_x,_y,_zand_wand 4 new getters and setters for the public versions. It also now passes most methods viasetto allow for the onChange callback to be invoked. This does not change the public-facing API. Groupnow extendsEventEmitter, allowing you to emit custom events from within a Group.Device.Audio.wavnow usesaudio/wavas thecanPlayTypecheck string, instead ofaudio/wav; codecs="1", which should allow iOS13 to play wav files again.- In the
Loader.FileTypes.TextFileconfig you can now override the type and cache destination for the file. Loader.MultiFilewill now parse the given files array and only add valid entries into the file list, allowing multifiles to now have optional file entries.- The
ParticleEmitter.tintvalue is now0xffffff(previously, it was0xffffffff) to allow particle tints to work in the correct RGB order including alpha (thanks @vforsh) SceneManager.startwill now reset theSceneSystems.sceneUpdatereference toNOOP. This gets set back to the Scene update method again duringbootScene(if it has one) and stops errors with external plugins and multi-part files that may triggerupdatebeforecreatehas been called. Fix #4629 (thanks @Osmose)Phaser.Scene.rendereris a new property available in every Phaser.Scene that gives you a reference to the renderer, either Canvas or WebGL.- The
CanvasRenderer._tempMatrix1,_tempMatrtix2,_tempMatrix3and_tempMatrix4properties have been removed. They were all flagged as private, yet used in lots of places. Instead, Game Objects now manager their own matrices, or use the globalGetCalcMatrixfunction instead. - Since iOS 13, iPads now identify as MacOS devices. A new maxTouchPoint check is now part of the
Device.OStests, stopping iPads from being flagged as desktop devices. Fix #5389 (thanks @SBCGames) - The
BitmapMask.prevFramebufferproperty has been removed as it's no longer required, due to the fbo stack in the renderer. - The
TextureManager.addGLTexturemethod has been updated so that thewidthandheightparameters are now optional. If not provided, and if available, they will be read from the given WebGLTexture instead (thanks @hexus) GameObjects.Components.Depth.depthListis a new property that all Game Objects that have the Depth Component now have. It contains a reference to the List responsible for managing the depth sorting of the Game Object. This is typically the Scene Display List, but can also be a Layer. It allows the Depth component to queue a depth sort directly on the list it belongs to now, rather than just the Scene.- The
WebAudioSoundManagerwill no longer try to unlock itself if the Game hasn't already booted and been added to the DOM. It will now wait for theBOOTevent and unlock based on that. Fix #5439 (thanks @samme)
- The
MatterAttractorsplugin, which enables attractors between bodies, has been fixed. The original plugin only worked if the body with the attractor was first in the world bodies list. It can now attract any body, no matter where in the world list it is. Fix #5160 (thanks @strahius) - The
KeyboardManagerandKeyboardPluginwere both still checking for theInputManager.useQueueproperty, which was removed several versions ago. - In Arcade Physics, Dynamic bodies would no longer hit walls when riding on horizontally moving platforms. The horizontal (and vertical) friction is now re-applied correctly in these edge-cases. Fix #5210 (thanks @Dercetech @samme)
- Calling
Rectangle.setSize()wouldn't change the underlying geometry of the Shape Game Object, causing any stroke to be incorrectly rendered after a size change. - The
ProcessQueuewas emitting the wrong events internally. It now emits 'add' and 'remove' correctly (thanks @halilcakar) - The
GridAlignaction didn't work if only theheightparameter was set. Fix #5019 (thanks @halilcakar) - The
Color.HSVToRGBfunction has been rewritten to use the HSL and HSV formula from Wikipedia, giving much better results. Fix #5089 (thanks @DiamondeX) - Previously, the
easeParamsarray within a Tweenspropsobject, or a multi-object tween, were ignored and it was only used if set on the root Tween object. It will now work correctly set at any depth. Fix #4292 (thanks @willblackmore) - When using
Camera.setRenderToTextureitszoomandrotationvalues would be applied twice. Fix #4221 #4924 #4713 (thanks @wayfu @DanMcgraw @pavel-shirobok) GameObjects.Shape.Gridwould render a white fill even if you passedundefinedas the fill color in the constructor. It now doesn't render cells if no fill color is given.- The
onMouseevents in the Input Manager didn't reset theactivePointerproperty to the mouse, meaning on dual-input systems such as Touch Screen devices, the active pointer would become locked to whichever input method was used first. Fix #4615 #5232 (thanks @mmolina01 @JstnPwll @Legomite) - The Scale Managers
GetScreenOrientationfunction will now check forwindow.orientationfirst, because iOS mobile browsers have an incomplete implementation of the Screen API, forcing us to use the window value as a priority. This means the Scale Manager will now emitorientationchangeevents correctly on iOS. Fix #4361 #4914 (thanks @pfdtravalmatic @jackfreak @cuihu) Time.Clock.addEventcan now take an instance of aTimerEventas its parameter. Fix #5294 (thanks @samme @EmilSV)GameConfig.audionow defaults to an empty object, which simplifies access to the config in later checks (thanks @samme)- The
Loader.pathwas being added to the File URL even if the URL was absolute. This is now checked for and the path is not applied unless the URL is relative (thanks @firesoft) Group.getMatchingwould always return an empty array. It now returns matching children (thanks @samme)- The
ParticleManagerWebGLRenderernow calculates its transform matrix differently, splitting out the parent matrix and factoring in follow offsets separately. This fixes numerous issues with particle emitters being incorrectly offset when added to Containers. Fix #5319 #5195 #4739 #4691 (thanks @vforsh @condeagustin @IvanDem @Formic) - The
ParticleManagerCanvasRenderernow calculates its transform matrix differently, splitting out the parent matrix and factoring in the follow offsets separately. It also usessetToContextinternally. This fixes numerous issues with particle emitters being incorrectly offset when added to Containers, or having the Camera zoomed, running under Canvas. Fix #4908 #4531 #4131 (thanks @smjnab @SirLink @jhooper04) - The
GraphicsWebGL Renderer will now default topathOpen = true. This fixes issues under WebGL where, for example, adding an arc and callingstrokePath, without first callingbeginPathwill no longer cause rendering artefacts when WebGL tries to close the path with a single tri. Graphics.strokeRoundedRectnow issuesmoveTocommands as part of the drawing sequence, preventing issues under WebGL where on older Android devices it would project additional vertices into the display. Fix #3955 (thanks @alexeymolchan)- Creating a Bitmap Mask from a texture atlas that was then used to mask another Game Object also using that same texture atlas would throw the error
GL_INVALID_OPERATION : glDrawArrays: Source and destination textures of the draw are the same.. It now renders as expected. Fix #4675 (thanks @JacobCaron) - When using the same asset for a Game Object to be used as a mask, it would make other Game Objects using the same asset, that appeared above the mask in the display list, to not render. Fix #4767 (thanks @smjnab)
- When taking a
snapshotin WebGL it would often have an extra line of empty pixels at the top of the resulting image, due to a rounding error in theWebGLSnapshotfunction. Fix #4956 (thanks @gammafp @telinc1) Particles.EmitterOp.setMethodswill now reset bothonEmitandonUpdateto their default values. This allows you to reconfigure an emitter op with a new type of value and not have it stuck on the previous one. Fix #3663 (thanks @samme)Particles.EmitterOpnow cleanly separates between the different types of property configuration options.start | endwill now ease between the two values,min | maxwill pick a random value between them andrandom: []will pick a random element. They no longer get mixed together. Fix #3608 (thanks @samme)- When setting both
transparent: trueandbackgroundColorin the Game Config, it would ignore the transparency and use the color anyway. If transparent, the game is now fully transparent. Fix #5362 (thanks @Hoshinokoe) - The
EllipseGame Object now will update the width, height, and geometric position in thesetSizemethod (thanks @PhaserEditor2D) - When measuring the last word in a line in a
TextGame Object, it no longer adds extra white space to the end (thanks @rexrainbow) Utils.Array.Removewould return an incorrect array of removed elements if one of the items to be removed was skipped in the array. Fix #5398 (thanks @year221)Geom.Intersects.TriangleToLinewouldn't returntrueif the start or end of the Line fell inside the Triangle, only if the entire Line did. It now checks the start and end points correctly. (thanks @wiserim)- Using a Bitmap Mask and a Blend Mode in WebGL would reset the blend mode when the mask was rendered, causing the Game Object to have no blend mode. Fix #5409 (thanks @jcyuan)
BitmapMaskwould become corrupted when resizing the Phaser Game, either via the Scale Manager or directly, because the framebuffer and texture it used for rendering was still at the old dimensions. The BitmapMask now listens for the Renderer RESIZE event and re-creates itself accordingly. Fix #5399 (thanks @Patapits)
When loading any of the file types listed below it will no longer store the data file in the cache. For example, when loading a Texture Atlas using a JSON File, it used to store the parsed image data in the Texture Manager and also store the JSON in the JSON Cache under the same key. This has changed in 3.50. The data files are no longer cached, as they are not required by the textures once parsing is completed, which happens during load. This helps free-up memory. How much depends on the size of your data files. And also allows you to easily remove textures based on just their key, without also having to clear out the corresponding data cache.
AtlasJSONFileno longer stores the JSON in the JSON Cache once the texture has been created.AtlasXMLFileno longer stores the XML in the XML Cache once the texture has been created.UnityAtlasFileno longer stores the Text in the Text Cache once the texture has been created.BitmapFontFileno longer stores the XML in the XML Cache once the texture has been created.- You can now use
TextureManager.removeto remove a texture and not have to worry about clearing the corresponding JSON or XML cache entry as well in order to reload a new texture using the same key. Fix #5323 (thanks @TedGriggs)
The Light Game Object has been rewritten so it now extends the Geom.Circle object, as they shared lots of the same properties and methods anyway. This has cut down on duplicate code massively.
Light.dirtyis a new property that controls if the light is dirty, or not, and needs its uniforms updating.Lighthas been recoded so that all of its properties are now setters that activate itsdirtyflag.LightsManager.destroywill now clear thelightPoolarray when destroyed, where-as previously it didn't.LightsManager.cullnow takes the viewport height from the renderer instead of the game config (thanks zenwaichi)
For legacy reasons, Phaser 3 has never properly supported HighDPI devices. It will render happily to them of course, but wouldn't let you set a 'resolution' for the Canvas beyond 1. Earlier versions of 3.x had a resolution property in the Game Config, but it was never fully implemented (for example, it would break zooming cameras). When the Scale Manager was introduced in v3.16 we forced the resolution to be 1 to avoid it breaking anything else internally.
For a long time, the 'resolution' property has been present - taunting developers and confusing new comers. In this release we have finally gone through and removed all references to it. The Game Config option is now gone, it's removed from the Scale Manager, Base Camera and everywhere else where it matters. As much as we would have liked to implement the feature, we've spent too long without it, and things have been built around the assumption it isn't present. The API just wouldn't cope with having it shoe-horned in at this stage. As frustrating as this is, it's even more annoying to just leave the property there confusing people and wasting CPU cycles. Phaser 4 has been built with HighDPI screens in mind from the very start, but it's too late for v3. The following changes are a result of this removal:
- The
Phaser.Scale.Events#RESIZEevent no longer sends theresolutionas a parameter. - The
BaseCamera.resolutionproperty has been removed. - The internal private
BaseCamera._cx,_cy,_cwand_chproperties has been removed, usex,y,widthandheightinstead. - The
BaseCamera.preRendermethod no longer receives or uses theresolutionparameter. - The
Camera.preRendermethod no longer receives or uses theresolutionparameter. - The
CameraManager.onResizemethod no longer receives or uses theresolutionparameter. - The
Core.Config.resolutionproperty has been removed. - The
TextStyle.resolutionproperty is no longer read from the Game Config. You can still set it via the Text Style config to a value other than 1, but it will default to this now. - The
CanvasRendererno longer reads or uses the Game Config resolution property. - The
PipelineManager.resizemethod along withWebGLPipeline.resizeand anything else that extends them no longer receives or uses theresolutionparameter. - The
WebGLRenderer.resizeandonResizemethods no longer receives or uses theresolutionparameter. - The
ScaleManager.resolutionproperty has been removed and all internal use of it.
Since v3.0.0 the Game Object render functions have received a parameter called interpolationPercentage that was never used. The renderers do not calculate this value and no Game Objects apply it, so for the sake of clairty, reducing code and removing complexity from the API it has been removed from every single function that either sent or expected the parameter. This touches every single Game Object and changes the parameter order as a result, so please be aware of this if you have your own custom Game Objects, or plugins, that implement their own render methods. In terms of surface API changes, you shouldn't notice anything at all from this removal.
- The
Phaser.Curves.MoveTofunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.DOM.GetInnerHeightfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.Bobclass has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.LightsManagerclass has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.LightsPluginclass has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.Particles.EmitterOpclass has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.GetTextSizefunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.MeasureTextfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.GameObjects.TextStylefunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Input.CreatePixelPerfectHandlerfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Arcade.Components.OverlapCircfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Arcade.Components.OverlapRectfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Arcade.Tilemapnamespace has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Matter.Componentsnamespace has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Matter.Eventsnamespace has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Matter.MatterGameObjectclass has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Physics.Matter.PointerConstraintclass has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Scenes.GetPhysicsPluginsfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Scenes.GetScenePluginsfunction has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Structs.Eventsnamespace has now been exposed on the Phaser namespace (thanks @samme) - The
Phaser.Tilemaps.Parsers.Tiledfunction has now been exposed on the Phaser namespace (thanks @samme) - Every single
Tilemap.Componentfunction has now been made public. This means you can call the Component functions directly, should you need to, outside of the Tilemap system.
My thanks to the following for helping with the Phaser 3 Examples, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:
@samme @16patsle @scott20145 @khasanovbi @mk360 @volkans80 @jaabberwocky @maikthomas @atursams @LearningCode2023 @DylanC @BenjaminDRichards @rexrainbow @Riderrr @spwilson2 @EmilSV @PhaserEditor2D @Gangryong @vinerz @trynx @usufruct99 @pirateksh @justin-calleja @monteiz
A special mention to the following who submitted feedback on the 3.50 Beta releases:
@gammafp Acorn @BlunT76 @PhaserEditor2D @samme @rexrainbow @vforsh @kainage @ccaleb @spayton @FloodGames @buzzjeux @jcyuan @MadDogMayCry0 @Patapits @MMontalto @SBCGames @juanitogan @Racoonacoon @EmilSV @telinc1 @d7561985 @RollinSafary
Sorry if I forgot you!