Repository navigation
Phaser v3.60 Beta 23 #6452
photonstorm
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Version 3.60.0 - Miku - in development
New Features - Timeline Class
Phaser 3.60 has a new Timeline Class which allows for fine-grained control of sequenced events. Previously in 3.55 the Timeline was part of the Tween system and it never quite worked as intended. In 3.60 it has been removed from Tweens entirely, replaced with the much more solid and reliable Tween Chains and Timeline has now becomes its own first-class citizen within Phaser. It allows you to sequence any event you like, not just tweens.
A Timeline is a way to schedule events to happen at specific times in the future. You can think of it as an event sequencer for your game, allowing you to schedule the running of callbacks, events and other actions at specific times in the future.
A Timeline is a Scene level system, meaning you can have as many Timelines as you like, each belonging to a different Scene. You can also have multiple Timelines running at the same time.
If the Scene is paused, the Timeline will also pause. If the Scene is destroyed, the Timeline will be automatically destroyed. However, you can control the Timeline directly, pausing, resuming and stopping it at any time.
Create an instance of a Timeline via the Game Object Factory:
The Timeline always starts paused. You must call
playon it to start it running.You can also pass in a configuration object on creation, or an array of them:
In this example we sequence a few different events:
There are lots of options available to you via the configuration object. See the
TimelineEventConfigtypedef for more details.New Features - ESM Support
Phaser 3.60 uses the new release of Webpack 5 in order to handle the builds. The configurations have been updated to follow the new format this upgrade introduced. As a bonus, Webpack 5 also bought a new experimental feature called 'output modules', which will take a CommonJS code-base, like Phaser uses and wrap the output in modern ES Module declarations.
We are now using this as part of our build. You will find in the
distfolder a newphaser.esm.jsfile, which is also linked in from ourpackage.jsonmodule property. Using this build you can access any of the Phaser modules directly via named imports, meaning you can code like this:Note that we're importing from the local esm bundle. By using this approach you don't need to even use a bundler for quick local prototyping or testing, you can simply import and code directly.
The dist folder still also contains
phaser.jswhich, as before, uses a UMD export.Because the Webpack feature is experimental we won't make the ESM version the default just yet, but if you're curious and want to explore, please go ahead!
New Features - Built-in Special FX
We have decided to bundle a selection of highly flexible special effect shaders in to Phaser 3.60 and provide access to them via an easy to use set of API calls. The FX included are:
sepia,greyscale,lsdand lots more.What's more, the FX can be stacked up. You could add, for example, a
Barrelfollowed by aBlurand then topped-off with aCircleeffect. Just by adjusting the ordering you can achieve some incredible and unique effects, very quickly.We've worked hard to make the API as easy to use as possible, too. No more messing with pipelines or importing plugins. You can simply do:
This will add a 32 pixel red glow around the
playerSprite.Each effect returns a new FX Controller instance, allowing you to easily adjust the special effects in real-time via your own code, tweens and similar:
This will add a Wipe Effect to a Container instance and then tween its progress value from 0 to 1, causing the wipe to play out.
All texture-based Game Objects have access to
Pre FX(so that includes Images, Sprites, TileSprites, Text, RenderTexture and Video). However, all Game Objects have access toPost FX, as do cameras. The difference is just when the effect is applied. For a 'pre' effect, it is applied before the Game Object is drawn. For a 'post' effect, it's applied after it has been drawn. All of the same effects are available to both.For example, this will apply a Tilt Shift effect to everything being rendered by the Camera. Which is a much faster way of doing it than applying the same effect to every child in a Scene. You can also apply them to Containers, allowing more fine-grained control over the display.
The full list of new methods are as follows:
Available only to texture-based Game Objects:
GameObject.preFXan instance of the FX Controller, which allows you to add and remove Pre FX from the Game Object. It features methods such asadd,removeandclear. Plus the following:GameObject.preFX.addGlowadds a Glow Pre FX effect to the Game Object.GameObject.preFX.addShadowadds a Shadow Pre FX effect to the Game Object.GameObject.preFX.addPixelateadds a Pixelate Pre FX effect to the Game Object.GameObject.preFX.addVignetteadds a Vignette Pre FX effect to the Game Object.GameObject.preFX.addShineadds a Shine Pre FX effect to the Game Object.GameObject.preFX.addBluradds a Blur Pre FX effect to the Game Object.GameObject.preFX.addGradientadds a Gradient Pre FX effect to the Game Object.GameObject.preFX.addBloomadds a Bloom Pre FX effect to the Game Object.GameObject.preFX.addColorMatrixadds a ColorMatrix Pre FX effect to the Game Object.GameObject.preFX.addCircleadds a Circle Pre FX effect to the Game Object.GameObject.preFX.addBarreladds a Barrel Pre FX effect to the Game Object.GameObject.preFX.addDisplacementadds a Displacement Pre FX effect to the Game Object.GameObject.preFX.addWipeadds a Wipe Pre FX effect to the Game Object.GameObject.preFX.addRevealadds a Reveal Pre FX effect to the Game Object.GameObject.preFX.addBokehadds a Bokeh Pre FX effect to the Game Object.GameObject.preFX.addTiltShiftadds a TiltShift Pre FX effect to the Game Object.Available to all Game Objects:
GameObject.clearFXremoves both Pre and Post FX from the Game Object.GameObject.postFXan instance of the FX Controller, which allows you to add and remove Post FX from the Game Object. It features methods such asadd,removeandclear. Plus the following:GameObject.postFX.addGlowadds a Glow Post FX effect to the Game Object.GameObject.postFX.addShadowadds a Shadow Post FX effect to the Game Object.GameObject.postFX.addPixelateadds a Pixelate Post FX effect to the Game Object.GameObject.postFX.addVignetteadds a Vignette Post FX effect to the Game Object.GameObject.postFX.addShineadds a Shine Post FX effect to the Game Object.GameObject.postFX.addBluradds a Blur Post FX effect to the Game Object.GameObject.postFX.addGradientadds a Gradient Post FX effect to the Game Object.GameObject.postFX.addBloomadds a Bloom Post FX effect to the Game Object.GameObject.postFX.addColorMatrixadds a ColorMatrix Post FX effect to the Game Object.GameObject.postFX.addCircleadds a Circle Post FX effect to the Game Object.GameObject.postFX.addBarreladds a Barrel Post FX effect to the Game Object.GameObject.postFX.addDisplacementadds a Displacement Post FX effect to the Game Object.GameObject.postFX.addWipeadds a Wipe Post FX effect to the Game Object.GameObject.postFX.addRevealadds a Reveal Post FX effect to the Game Object.GameObject.postFX.addBokehadds a Bokeh Post FX effect to the Game Object.GameObject.postFX.addTiltShiftadds a TiltShift Post FX effect to the Game Object.New Features - Spatial Sound
Thanks to a contribution from @alxwest the Web Audio Sound system now supports spatial sound. The Web Audio Sound Manager now has the ability to set the listener position and each sound can be positioned in 3D space:
This allows you to create a 3D sound environment in your game. The following new methods and properties have been added to the Web Audio Sound Manager and Web Audio Sound classes:
SpatialSoundConfigis a new configuration object that contains the properties required to create and set the values of a spatial sound:SpatialSoundConfig.xsets the horizontal position of the audio in a right-hand Cartesian coordinate system.SpatialSoundConfig.ysets the vertical position of the audio in a right-hand Cartesian coordinate system.SpatialSoundConfig.zsets the longitudinal (back and forth) position of the audio in a right-hand Cartesian coordinate system.SpatialSoundConfig.panningModelis an enumerated value determining which spatialization algorithm to use to position the audio in 3D space. Can be eitherequalpowerorHRTF. The default value isequalpower.SpatialSoundConfig.distanceModelsets which algorithm to use to reduce the volume of the audio source as it moves away from the listener. Possible values are "linear", "inverse" and "exponential". The default value is "inverse".SpatialSoundConfig.orientationXsets the horizontal position of the audio source's vector in a right-hand Cartesian coordinate system.SpatialSoundConfig.orientationYsets the vertical position of the audio source's vector in a right-hand Cartesian coordinate system.SpatialSoundConfig.orientationZsets the longitudinal (back and forth) position of the audio source's vector in a right-hand Cartesian coordinate system.SpatialSoundConfig.refDistanceis a double value representing the reference distance for reducing volume as the audio source moves further from the listener. For distances greater than this the volume will be reduced based onrolloffFactoranddistanceModel.SpatialSoundConfig.maxDistanceis the maximum distance between the audio source and the listener, after which the volume is not reduced any further.SpatialSoundConfig.rolloffFactoris a double value describing how quickly the volume is reduced as the source moves away from the listener. This value is used by all distance models.SpatialSoundConfig.coneInnerAnglesets the angle, in degrees, of a cone inside of which there will be no volume reduction.SpatialSoundConfig.coneOuterAnglesets the angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by theconeOuterGainproperty.SpatialSoundConfig.coneOuterGainsets the amount of volume reduction outside the cone defined by theconeOuterAngleattribute. Its default value is 0, meaning that no sound can be heard. A value between 0 and 1.SpatialSoundConfig.followsets this Sound object to automatically track the x/y position of this object. Can be a Phaser Game Object, Vec2 or anything that exposes public x/y properties.WebAudioSoundManager.setListenerPositionis a new method that allows you to set the position of the Spatial Audio listener.BaseSoundManager.listenerPositionis a new Vector2 that stores the position of the Spatial Audio listener.WebAudioSound.spatialNodeis a new property that holds thePanNodethat is used to position the sound in 3D space.WebAudioSound.spatialSourceis a new property that holds a Vector2 that stores the position of the sound in 3D space.WebAudioSound.xis a new property that sets the x position of the sound in 3D space. This only works if the sound was created with a SpatialSoundConfig object.WebAudioSound.yis a new property that sets the y position of the sound in 3D space. This only works if the sound was created with a SpatialSoundConfig object.New Features - Spine 4 Support
Thanks to a contribution from @justintien we now have a Spine 4 Plugin available.
You can find it in the
plugins/spine4.1folder in the main repository. There are also a bunch of new npm scripts to help build this plugin:npm run plugin.spine4.1.full.dist- To build new dist files for both canvas and WebGL.npm run plugin.spine4.1.dist- To build new dist files.npm run plugin.spine4.1.watch- To enter watch mode when doing dev work on the plugin.npm run plugin.spine4.1.runtimes- To build new versions of the Spine 4 runtimes.The core plugin API remains largely the same. You can find lots of updated examples in the Phaser 3 Examples repo in the
3.60/spine4.1folder.We will maintain both the Spine 3 and 4 plugins for the forseeable future.
Additional Spine 3 Bug Fixes
drawDebugon a Spine Game Object to view its skeleton would cause the next object in the display list to be skipped for rendering, if it wasn't a Spine Game Object too. This is because the Spine 3 skeleton debug draw ends the spine batch but the Scene Renderer wasn't rebound. Fix image after invisible spine isn't drawn #6380 (thanks @spayton)addandmakefunctions didn't clear and rebind the WebGL pipeline. This could cause two different visual issues: The first is that a Phaser Game Object (such as a Sprite) could be seen to change its texture to display the Spine atlas texture instead for a single frame, and then on the next pass revert back to normal again. The second issue is that if the Spine skeleton wasn't added to the display list, but just created (viaaddToScene: false) then the Sprite would take on the texture frame entirely from that point on. Fix Creating a Spine object without adding it to the scene results in Spine atlas PNG being displayed #6362 (thanks @frissonlabs)SpineFileloader has now been updated so that the always-unique Spine key is pre-pended to the filename, for example if the key wasbonusand the PNG in the atlas wascoin.pngthen the final key (as stored in the Texture Manager) is nowbonus:coin.png. TheSpinePlugin.getAtlasCanvasandgetAtlasWebGLmethods have been updated to reflect this change. Fix Spine objects cannot have the same texture atlas filename #6022 (thanks @orjandh)SpineContainerhad a mask applied to it and the next immediate item on the display list was another Spine object (outside of the Container) then it would fail to rebind the WebGL pipeline, causing the mask to break. It will now rebind the renderer at the end of the SpineContainer batch, no matter what, if it has a mask. Fix SpineContainer delayed masking, or not masking at all, with lower depth spine below #5627 (thanks @FloodGames)New Features - Plane Game Object
Phaser v3.60 contains a new native Plane Game Object. The Plane Game Object is a helper class that takes the Mesh Game Object and extends it, allowing for fast and easy creation of Planes. A Plane is a one-sided grid of cells, where you specify the number of cells in each dimension. The Plane can have a texture that is either repeated (tiled) across each cell, or applied to the full Plane.
The Plane can then be manipulated in 3D space, with rotation across all 3 axis.
This allows you to create effects not possible with regular Sprites, such as perspective distortion. You can also adjust the vertices on a per-vertex basis. Plane data becomes part of the WebGL batch, just like standard Sprites, so doesn't introduce any additional shader overhead. Because the Plane just generates vertices into the WebGL batch, like any other Sprite, you can use all of the common Game Object components on a Plane too, such as a custom pipeline, mask, blend mode or texture.
You can use the
uvScrollanduvScalemethods to adjust the placement and scaling of the texture if this Plane is using a single texture, and not a frame from a texture atlas or sprite sheet.The Plane Game Object also has the Animation component, allowing you to play animations across the Plane just as you would with a Sprite.
As of Phaser 3.60 this Game Object is WebGL only. Please see the new examples and documentation for how to use it.
New Features - Nine Slice Game Object
Phaser v3.60 contains a new native Nine Slice Game Object. A Nine Slice Game Object allows you to display a texture-based object that can be stretched both horizontally and vertically, but that retains fixed-sized corners. The dimensions of the corners are set via the parameters to the class. When you resize a Nine Slice Game Object only the middle sections of the texture stretch. This is extremely useful for UI and button-like elements, where you need them to expand to accommodate the content without distorting the texture.
The texture you provide for this Game Object should be based on the following layout structure:
When changing this objects width and / or height:
You can also create a 3 slice Game Object:
This works in a similar way, except you can only stretch it horizontally. Therefore, it requires less configuration:
When changing this objects width (you cannot change its height)
The above configuration concept is adapted from the Pixi NineSlicePlane.
To specify a 3 slice object instead of a 9 slice you should only provide the
leftWidthandrightWidthparameters. To create a 9 sliceyou must supply all parameters.
The minimum width this Game Object can be is the total of
leftWidth+rightWidth. The minimum height this Game Objectcan be is the total of
topHeight+bottomHeight. If you need to display this object at a smaller size, you can scale it.In terms of performance, using a 3 slice Game Object is the equivalent of having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent of having 9 Sprites in a row. The vertices of this object are all batched together and can co-exist with other Sprites and graphics on the display list, without incurring any additional overhead.
As of Phaser 3.60 this Game Object is WebGL only. Please see the new examples and documentation for how to use it.
New Features - Pre FX Pipeline
renderTargetsin a WebGL Pipeline config, you can now set optionalwidthandheightproperties, which will create a Render Target of that exact size, ignoring thescalevalue (if also given).WebGLPipeline.isPreFXis a new boolean property that defines if the pipeline is a Sprite FX Pipeline, or not. The default isfalse.GameObjects.Components.FXis a new component that provides access to FX specific properties and methods. The Image and Sprite Game Objects have this component by default.fxPaddingand its related methodsetFXPaddingallow you to set extra padding to be added to the texture the Game Object renders with. This is especially useful for Pre FX shaders that modify the sprite beyond its bounds, such as glow or shadow effects.WebGLPipeline.setShadermethod has a new optional parameterbufferthat allows you to set the vertex buffer to be bound before the shader is activated.WebGLPipeline.setVertexBuffermethod has a new optional parameterbufferthat allows you to set the vertex buffer to be bound if you don't want to bind the default one.WebGLRenderer.createTextureFromSourcemethod has a new optional boolean parameterforceClampthat will for the clamp wrapping mode even if the texture is a power-of-two.RenderTargetwill now automatically set the wrapping mode to clamp.WebGLPipeline.flipProjectionMatrixis a new method that allows you to flip the y and bottom projection matrix values via a parameter.PipelineManager.renderTargetsis a new property that holds an array ofRenderTargetobjects that allPreFXpipelines can share, to keep texture memory as low as possible.PipelineManager.maxDimensionis a new property that holds the largest possible target dimension.PipelineManager.frameIncis a new property that holds the amount theRenderTargets will increase in size in each iteration. The default value is 32, meaning it will create targets of size 32, 64, 96, etc. You can control this via the pipeline config object.PipelineManager.targetIndexis a new property that holds the internal target array offset index. Treat it as read-only.RenderTargetobjects during itsbootmethod. These are sized incrementally from 32px and up (use theframeIncvalue to alter this). These targets are shared by all Sprite FX Pipelines.PipelineManager.getRenderTargetis a new method that will return the aRenderTargetthat best fits the dimensions given. This is typically called by Pre FX Pipelines, rather than directly.PipelineManager.getSwapRenderTargetis a new method that will return a 'swap'RenderTargetthat matches the size of the main target. This is called by Pre FX pipelines and not typically called directly.PipelineManager.getAltSwapRenderTargetis a new method that will return a 'alternative swap'RenderTargetthat matches the size of the main target. This is called by Pre FX pipelines and not typically called directly.WebGLPipeline.setTimemethod has a new optional parametershader, which allows you to control the shader on which the time value is set.#define SHADER_NAMEto the start of your shader then it will be picked up as theWebGLShadername during thesetShadersFromConfigprocess withinWebGLPipeline.setPostPipelineon a Game Object will now pass thepipelineDataconfiguration object (if provided) to the pipeline instance being created.PipelineManager.getPostPipelinenow has an optional 3rd parameter, aconfigobject that is passed to the pipeline instance in its constructor, which can be used by the pipeline during its set-up.New Features - Compressed Texture Support
Phaser 3.60 contains support for Compressed Textures. It can parse both KTX and PVR containers and within those has support for the following formats: ETC, ETC1, ATC, ASTC, BPTC, RGTC, PVRTC, S3TC and S3TCSRB. Compressed Textures differ from normal textures in that their structure is optimized for fast GPU data reads and lower memory consumption. Popular tools that can create compressed textures include PVRTexTool, ASTC Encoder and Texture Packer.
Compressed Textures are loaded using the new
this.load.texturemethod, which takes a texture configuration object that maps the formats to the files. The browser will then download the first file in the object that it knows it can support. You can also provide Texture Atlas JSON data, or Multi Atlas JSON data, too, so you can use compressed texture atlases. Currently, Texture Packer is the best tool for creating these type of files.TextureSoure.compressionAlgorithmis now populated with the compression format used by the texture.Types.Textures.CompressedTextureDatais the new compressed texture configuration object type.TextureManager.addCompressedTextureis a new method that will add a compressed texture, and optionally atlas data into the Texture Manager and return aTextureobject than any Sprite can use.Textures.Parsers.KTXParseris a new parser for the KTX compression container format.Textures.Parsers.PVRParseris a new parser for the PVR compression container format.WebGLRenderer.compressionproperty now holds a more in-depth object containing supported compression formats.WebGLRenderer.createTextureFromSourcemethod now accepts theCompressedTextureDatadata objects and creates WebGL textures from them.WebGLRenderer.getCompressedTexturesis a new method that will populate theWebGLRenderer.compressionobject and return its value. This is called automatically when the renderer boots.WebGLRenderer.getCompressedTextureNameis a new method that will return a compressed texture format GLenum based on the given format.New Features - Updated Particle System
The Particle system has been mostly rewritten to give it a much needed overhaul. This makes the API cleaner, the Game Objects a lot more memory efficient and also introduces several great new features. In order to do this, we had to make some breaking changes. The largest being the way in which particles are now created.
Previously when you used the
this.add.particlescommand it would create aParticleEmitterManagerinstance. You would then use this to create an Emitter, which would actually emit the particles. While this worked and did allow a Manager to control multiple emitters we found that in discussion developers seldom used this feature and it was common for a Manager to own just one single Emitter.In order to streamline memory and the display list we have removed the
ParticleEmitterManagerentirely. When you callthis.add.particlesyou're now creating aParticleEmitterinstance, which is being added directly to the display list and can be manipulated just like any other Game Object, i.e. scaled, rotated, positioned, added to a Container, etc. It now extends theGameObjectbase class, meaning it's also an event emitter, which allowed us to create some handy new events for particles.So, to create an emitter, you now give it an xy coordinate, a texture and an emitter configuration object (you can also set this later, but most commonly you'd do it on creation). I.e.:
This will create a 'red flare' emitter at 100 x 300.
Prior to 3.60 it would have looked like:
The change is quite subtle but makes a big difference internally.
The biggest real change is with the particle x/y coordinates. It's important to understand that if you define x/y coordinates within the emitter configuration, they will be relative to those given in the
add.particlescall:In the above example the particles will emit from 200 x 400 in world space, because the emitter is at 100 x 300 and the particles emit from an offset of 100 x 100.
By making this change it now means you're able to do things like tween the x/y coordinates of the emitter (something you couldn't do before), or add a single emitter to a Container.
Other new features include:
Animated Particles
The Particle class now has an instance of the
Animation Statecomponent within it. This allows a particle to play an animation when it is emitted, simply by defining it in the emitter config.For example, this will make each particle play the 'Prism' animation on emission:
You can also allow it to select a random animation by providing an array:
You've also the ability to cycle through the animations in order, so each new particle gets the next animation in the array:
Or even set a quantity. For example, this will emit 10 'prism' particles, then 10 'ruby' particles and then repeat:
The Animations must have already been created in the Global Animation Manager and must use the same texture as the one bound to the Particle Emitter. Aside from this, you can still control them in the same way as any other particle - scaling, tinting, rotation, alpha, lifespan, etc.
Fast Forward Particle Time
advanceproperty, or by calling the newParticleEmitter.fastForwardmethod. If, for example, you have an emitter that takes a few seconds to 'warm up' and get all the particles into position, this allows you to 'fast forward' the emitter to a given point in time. The value is given in ms. All standard emitter events and callbacks are still handled, but no rendering takes place during the fast-forward until it has completed.ParticleEmitter.startmethod has a new optional parameteradvancethat allows you to fast-forward the given amount of ms before the emitter starts flowing.Particle Interpolation
This will interpolate the
xproperty of each particle through the data set given, using a catmull rom interpolation function. You can also uselinearorbezierfunctions. Interpolation can be combined with aneasetype, which controls the progression through the time value. The relatedEmitterOpInterpolationConfigtypes have also been added.Particle Emitter Duration
duration:This parameter is used for 'flow' emitters only and controls how many milliseconds the emitter will run for before automatically turning itself off.
ParticleEmitter.durationis a new property that contains the duration that the Emitter will emit particles for in flow mode.ParticleEmitter.startmethod has a new optional parameterduration, which allows you to set the emitter duration when you call this method. If you do this, it will override any value set in the emitter configuration.ParticleEmitter.stopmethod has a new optional parameterkill. If set it will kill all alive particles immediately, rather than leaving them to die after their lifespan expires.Stop After a set number of Particles
stopAfterproperty. This, combined with thefrequencyproperty allows you to control exactly how many particles are emitted before the emitter then stops:In the above code the emitter will launch 1 particle (set by the
quantityproperty) every 250 ms (set by thefrequencyproperty) and move it to xy 0x0. Once it has fired 6 particles (thestopAfterproperty) the emitter will stop and emit theCOMPLETEevent.stopAftercounter is reset each time you call thestartorflowmethods.Particle Hold
holdconfiguration option:The above will scale a Particle in from 0 to 1 over the course of its lifespan (2 seconds). It will then
holdit on-screen for another second (1000 ms) before the Emitter recycles it and removes it from display.Particle Emitter Events
Particles.Events.STARTevent is fired whenever the Emitter begins emission of particles in flow mode. A reference to theParticleEmitteris included as the only parameter.Particles.Events.EXPLODEevent is fired whenever the Emitter explodes a bunch of particles via theexplodemethod. A reference to theParticleEmitterand a reference to the most recently firedParticleinstance are the two parameters.Particles.Events.DEATH_ZONEevent is fired whenever a Particle is killed by a Death Zone. A reference to theParticleEmitter, the killedParticleand theDeathZonethat caused it are the 3 parameters.Particles.Events.STOPevent is fired whenever the Emitter finishes emission of particles in flow mode. This happens either when you call thestopmethod, or when an Emitter hits its duration or stopAfter limit. A reference to theParticleEmitteris included as the only parameter.Particles.Events.COMPLETEevent is fired when the final alive particle expires.Multiple Emit Zones
ParticleEmitter.addEmitZonemethod:totalproperty.EdgeZone.totalandRandomZone.totalare new properties that control the total number of particles the zone will emit, before passing control over to the next zone in the list, if any. The default is -1.setEmitZonenow performs a different task than before. It's now an alias foraddEmitZone. This means if you call it multiple times, it will add multiple zones to the emitter, where-as before it would just replace the zone each time.ParticleEmitter#removeEmitZoneis a new method that allows you to remove an Emit Zone from an Emitter without needing to modify the internal zones array.ParticleEmitter.getEmitZoneis a new method that Particles call when they are 'fired' in order to set their starting position, if any.ParticleEmitter.emitZonehas been removed. It has been replaced with the newParticleEmitter.emitZonesarray-based property.Multiple Death Zones
ParticleEmitter.addDeathZonemethod:setEmitZonenow performs a different task than before. It's now an alias foraddEmitZone. This means if you call it multiple times, it will add multiple zones to the emitter, where-as before it would just replace the zone each time.ParticleEmitter#removeDeathZoneis a new method that allows you to remove a Death Zone from an Emitter without needing to modify the internal zones array.ParticleEmitter.getDeathZoneis a new method that Particles call when they are updated in order to check if they intersect with any of the Death Zones.ParticleEmitter.deathZonehas been removed. It has been replaced with the newParticleEmitter.deathZonesarray-based property.Particle Colors
colorproperty in the Emitter configuration. This takes the form of an array of hex color values that the particles will linearly interpolate between during theif lifetime. This allows you to now change the color of a particle from birth to death, which gives you far more control over your emitter visuals than ever before. You'd use it as follows:Here you can see the array of 4 colors it will interpolate through.
colorEaseconfiguration property allows you to define the ease used to calculate the route through the interpolation. This can be set to any valid ease string, such assine.outorquad.in, etc. If left undefined it will uselinearas default.EmitterColorOpis a brand new Emitter Op class that specifically controls the handling of color values, it extendsEmitterOpand uses the same methods but configured for faster color interpolation.colorin your config it will override any Emitter tint values you may have set. In short, usecolorif you wish to adjust the color of the particles during their lifespan and usetintif you wish to modify either the entire emitter at once, or the color of the particles on birth only.ParticleEmitter.particleColoris a new property that allows you to get and set the particle color op value.ParticleEmitter.colorEaseis a new property that allows you to get and set the ease function used by the color op.Particle Sort Order
ParticleEmitter.sortPropertyandsortOrderAscproperties to set how (and if) particles should be sorted prior to rendering. For example, settingsortPropertytoywould mean that the particles will be sorted based on their y value prior to rendering. The sort order controls the order in which the particles are rendered. For example:ParticleEmitter.setSortPropertymethod allows you to modify the sort property and order at run-time.ParticleEmitter.setSortCallbackmethod allows you to set a callback that will be invoked in order to sort the particles, rather than using the built-in one. This gives you complete freedom over the logic applied to particle render sorting.Particle Bounds, Renderer Culling and Overlap
Particle.getBoundsmethod to return the bounds, which also gets stored in the newParticle.boundsRectangle property.ParticleEmitter.getBoundsis a new method that will return the bounds of the Emitter based on all currently active particles. Optional parameters allow you to pad out the bounds and/or advance time in the particle flow, to allow for a more accurate overall bounds generation.ParticleEmitter.viewBoundsis a new property that is a Geom Rectangle. Set this Rectangle to define the overall area the emitter will render to. If this area doesn't intersect with the Camera then the emitter will be culled from rendering. This allows you to populate large Scenes with active emitters that don't consume rendering resources even though they are offscreen. Use the newgetBoundsmethod to help define theviewBoundsarea.ParticleEmitter.overlapis a new method that will run a rectangle intersection test against the given target and all alive particles, returning those that overlap in an array. The target can be a Rectangle Geometry object or an Arcade Physics Body.Particle.killis a new method that will set the life of the particle to zero, forcing it to be immediately killed on the next Particle Emitter update.ParticleEmitter.getWorldTransformMatrixis a new method that allows a Particle Emitter to calculate its world transform, factoring in any parents.ParticleEmitter.worldMatrixis a new property that holds a TransformMatrix used for bounds calculations.Particle Emitter Bounds
boundsproperty. This was a Rectangle and if a Particle hit any of its edges it would rebound off it based on the Particlesbouncevalue. In v3.60 this action has been moved to a Particle Processor. You can still configure the bounds via the Emitter config using theboundsproperty, as before. And you can configure which faces collide via thecollideLeftetc properties. However, the following internal changes have taken place:ParticleBoundsis a new Particle Processor class that handles updating the particles.ParticleEmitter.setBoundsmethod has been replaced withParticleEmitter.addParticleBoundswhich now returns a newParticleBoundsParticle Processor instance.ParticleEmitter.boundsproperty has been removed. Please see theaddParticleBoundsmethod if you wish to retain this object.ParticleEmitter.collideLeftproperty has been removed. It's now part of theParticleBoundsParticle Processor.ParticleEmitter.collideRightproperty has been removed. It's now part of theParticleBoundsParticle Processor.ParticleEmitter.collideTopproperty has been removed. It's now part of theParticleBoundsParticle Processor.ParticleEmitter.collideBottomproperty has been removed. It's now part of theParticleBoundsParticle Processor.Particle.checkBoundsmethod has been removed as it's now handled by the Particle Processors.Particle Processors
ParticleProcessoris a new base class that you can use to create your own Particle Processors, which are special processors capable of manipulating the path of Particles based on your own logic or math. It provides the structure required to handle the processing of particles and should be used as a base for your own classes.GravityWellnow extends the newParticleProcessorclass.ParticleEmitter.addParticleProcessoris a new method that allows you to add a Particle Processor instance to the Emitter. The oldcreateGravityWellmethod now uses this.ParticleEmitter.removeParticleProcessoris a new method that will remove a Particle Processor from an Emitter.ParticleEmitter.processorsis a new List property that contains all of the Particle Processors belonging to the Emitter.ParticleEmitter.wellsproperty has been removed. You should now use the newprocessorsproperty instead, they are functionally identical.ParticleProcessor.updateis the method that handles all of the particle manipulation. It now has a new 4th parametertthat is the normalized lifespan of the Particle being processed.Particle System EmitterOp Breaking Changes and Updates:
All of the following properties have been replaced on the
ParticleEmitterclass. Previously they wereEmitterOpinstances. They are now public getter / setters, so calling, for example,emitter.particleXwill now return a numeric value - whereas before it would return theEmitterOpinstance. This gives developers a lot more freedom when using Particle Emitters. Before v3.60 it was impossible to do this, for example:I.e. you couldn't tween an emitters particle spawn position by directly accessing its x and y properties. However, now that all EmitterOps are getters, you're free to do this, allowing you to be much more creative and giving a nice quality-of-life improvement.
If, however, your code used to access EmitterOps, you'll need to change it as follows:
All of following EmitterOp functions can now be found in the new
ParticleEmitter.opsproperty and have been replaced with getters:Which means you can now directly access, modify and tween any of the above emitter properties at run-time while the emitter is active.
Another potentially breaking change is the removal of two internal private counters. These should never have been used directly anyway, but they are:
ParticleEmitter._counter- Now available viaParticleEmitter.flowCounterParticleEmitter._frameCounter- Now available viaParticleEmitter.frameCounterEmitterOp._onEmitis a new private reference to the emit callback function, if specified in the emitter configuration. It is called by the newEmitterOp.proxyEmitmethod, to ensure that the Emittercurrentproperty remains current.EmitterOp._onUpdateis a new private reference to the update callback function, if specified in the emitter configuration. It is called by the newEmitterOp.proxyUpdatemethod, to ensure that the Emittercurrentproperty remains current.EmitterOp.destroyis a new method that nulls all references. This is called automatically when aParticleEmitteris itself destroyed.Further Particle System Updates and Fixes:
DeathZone.willKillmethod now takes aParticleinstance as its only parameter, instead of x and y coordinates, allowing you to perform more complex checks before deciding if the Particle should be killed, or not.Particle.resetPositionmethod has been renamed tosetPositionand it now takes optional x/y parameters. If not given, it performs the same task asresetPositiondid in earlier versions.ParticleEmitterclass now has theAlphaSingleComponent. This allows you to callsetAlphaon the Emitter instance itself and have it impact all particles being rendered by it, allowing you to now 'fade in/out' a whole Emitter.frequencywasn't working correctly in earlier versions. It should allow you to specify a time, in ms, between which each 'quantity' of particles is emitted. However, thepreUpdateloop was calculating the value incorrectly. It will now count down the right amount of time before emiting another batch of particles.ParticleEmitter.startwouldn't reset the_frameCountervalue internally, meaning the new emission didn't restart from the first texture frame again.ParticleEmitter.countersis a new Float32Array property that is used to hold all of the various internal counters required for emitter operation. Both the previous_counterand_frameCounterproperties have been merged into this array, along with new ones required for new features.setQuadfeature of the Transform Matrix. This vastly reduces the amount of math and function calls per particle, from 8 down to 1, increasing performance.ParticleEmitter.preDestroyis a new method that will now clean-up all resources and internal arrays and destroy all Particles that the Emitter owns and clean-up all external references.Particle.destroyis a new method that will clean up all external references and destroy the Animation State controller.ParticleEmitter._frameLengthproperty is now specified on the class, rather than added dynamically at run-time, helping preserve class shape.ParticleEmitter.defaultFrameproperty has been removed as it's not required.ParticleEmitter.setFrameno longer resets the internal_frameCountervalue to zero. Instead, the counter comparison has been hardened to>=instead of===to allow this value to change mid-emission and never reach the total.ParticleEmitter.configFastMapproperty has been moved to a local var within theParticleEmitterJS file. It didn't need to be a property on the class itself, reducing the overall size of the class and saving memory.ParticleEmitter.configOpMapproperty has been moved to a local var within theParticleEmitterJS file. It didn't need to be a property on the class itself, reducing the overall size of the class and saving memory.Particle.sceneis a new property that references the Scene the Particle Emitter belongs to.Particle.animsis a new property that is an instance of theAnimationStatecomponent.Particle.emitis a new proxy method that passes all Animation related events through to the Particle Emitter Manager to emit, as Particles cannot emit events directly.Particle.isCroppedis a new read-only property. Do not modify.Particle.setSizeToFrameis a new internal NOOP method. Do not call.ParticleEmitter.animsis a new property that contains the Animation keys that can be assigned to Particles.ParticleEmitter.currentAnimis a new property that contains the index of the current animation, as tracked in cycle playback.ParticleEmitter.randomAnimis a new boolean property that controls if the animations are selected randomly, or in a cycle.ParticleEmitter.animQuantityis a new property that controls the number of consecutive particles that are emitted with the current animation.ParticleEmitter.countersis a new internal Float32Array that holds all the counters the Emitter uses.ParticleEmitter.getAnimis a new method, called by Particles when they are emitted, that will return the animation to use, if any.ParticleEmitter.setAnimis a new method, called with the Emitter Manager, that sets the animation data into the Emitter.Particles.EmitterOp.toJSONmethod will now JSON stringify the property value before returning it.Particles.EmitterOp.methodis a new property that holds the current operation method being used. This is a read-only numeric value.Particles.EmitterOp.activeis a new boolean property that defines if the operator is alive, or not. This is now used by the Emitter instead of nulling Emitter properties, helping maintain class shape.Particles.EmitterOp.getMethodis a new internal method that returns the operation function being used as a numeric value. This is then cached in themethodproperty.Particles.EmitterOp.setMethodsmethod has been updated so it now has a non-optional 'method' parameter. It has also been rewritten to be much more efficient, now being just a single simple select/case block.Particles.EmitterOp.onChangemethod will now use the cached 'method' property to avoid running through thesetMethodsfunction if not required, allowing each Particle EmitterOp to skip a huge chunk of code.ParticleEmitter.setConfigis a new method that allows you to set the configuration of the Emitter. Previously this was known asfromJSON.ParticleEmitter.setPositionmethod no longer changes the position of the particle emission point, but of the Emitter itself.ParticleEmitter.setBoundsmethod has been renamed tosetParticleBounds.ParticleEmitter.setSpeedmethod has been renamed tosetParticleSpeed.ParticleEmitter.setScalemethod has been renamed tosetParticleScaleassetScalewill now set the scale of the whole Emitter.ParticleEmitter.setScaleXandsetScaleYmethods have been removed. Please usesetParticleScale.ParticleEmitter.setGravitymethod has been renamed tosetParticleGravity.ParticleEmitter.setGravityXandsetGravityYmethods have been removed. Please usesetParticleGravity.ParticleEmitter.setAlphamethod has been renamed tosetParticleAlphaassetAlphawill now set the alpha of the whole Emitter.ParticleEmitter.setTintmethod has been renamed tosetParticleTint.ParticleEmitter.setLifespanmethod has been renamed tosetParticleLifespan.ParticleEmitter.onproperty has been renamed toemittingto avoid conflicts with the Event Emitter.ParticleEmitter.xproperty has been renamed toparticleXand is a new EmitterOp capable of being tweened.ParticleEmitter.yproperty has been renamed toparticleYand is a new EmitterOp capable of being tweened.ParticleEmitter.scaleXproperty has been renamed toparticleScaleXand is a new EmitterOp capable of being tweened.ParticleEmitter.scaleYproperty has been renamed toparticleScaleYand is a new EmitterOp capable of being tweened.ParticleEmitter.tintproperty has been renamed toparticleTintand is a new EmitterOp capable of being tweened.ParticleEmitter.alphaproperty has been renamed toparticleAlphaand is a new EmitterOp capable of being tweened.ParticleEmitter.angleproperty has been renamed toparticleAngleand is a new EmitterOp capable of being tweened.ParticleEmitter.rotateproperty has been renamed toparticleRotateand is a new EmitterOp capable of being tweened.New Features - Vastly Improved Mobile Performance and WebGL Pipeline Changes
TODO
WebGL Renderer Updates
Due to all of the changes with how WebGL texture batching works a lot of mostly internal methods and properties have been removed. This is the complete list:
WebGLRenderer.currentActiveTextureproperty has been removed.WebGLRenderer.startActiveTextureproperty has been removed.WebGLRenderer.tempTexturesproperty has been removed.WebGLRenderer.textureZeroproperty has been removed.WebGLRenderer.normalTextureproperty has been removed.WebGLRenderer.textueFlushproperty has been removed.WebGLRenderer.isTextureCleanproperty has been removed.WebGLRenderer.setBlankTexturemethod has been removed.WebGLRenderer.setTextureSourcemethod has been removed.WebGLRenderer.isNewNormalMapmethod has been removed.WebGLRenderer.setTextureZeromethod has been removed.WebGLRenderer.clearTextureZeromethod has been removed.WebGLRenderer.setNormalMapmethod has been removed.WebGLRenderer.clearNormalMapmethod has been removed.WebGLRenderer.unbindTexturesmethod has been removed.WebGLRenderer.resetTexturesmethod has been removed.WebGLRenderer.setTexture2Dmethod has been removed.WebGLRenderer.pushFramebuffermethod has had theresetTexturesargument removed.WebGLRenderer.setFramebuffermethod has had theresetTexturesargument removed.WebGLRenderer.popFramebuffermethod has had theresetTexturesargument removed.WebGLRenderer.deleteTexturemethod has had theresetargument removed.Textures.TextureSource.glIndexproperty has been removed.Textures.TextureSource.glIndexCounterproperty has been removed.Previously,
WebGLRenderer.whiteTextureandWebGLRenderer.blankTexturehad a data-type ofWebGLTexturebut they were actuallyPhaser.Textures.Frameinstances. This has now been corrected and the two properties are now actuallyWebGLTextureinstances, not Frames. If your code relies on this mistake being present, please adapt it.RenderTargetclass will now create a Framebuffer that includes a Depth Stencil Buffer attachment by default. Previously, it didn't. By attaching a stencil buffer it allows things like Geometry Masks to work in combination with Post FX and other Pipelines. Fix Geometry Mask does not work at the same time as PostFxPipeline #5802 (thanks @mijinc0)PipelineManager.clearandrebindit will now check if the vao extension is available, and if so, it'll bind a null vertex array. This helps clean-up from 3rd party libs that don't do this directly, such as ThreeJS.mipmapFilterproperty in the Game Config now defaults to '' (an empty string) instead of 'LINEAR'. The WebGLRenderer has been updated so that it will no longer create mipmaps at all with a default config. This potential saves a lot of VRAM (if your game has a lot of power-of-two textures) where before it was creating mipmaps that may never have been used. However, you may notice scaling doesn't look as crisp as it did before if you were using this feature without knowing it. To get it back, just addmipmapFilter: 'LINEAR'to your game config. Remember, as this is WebGL1 it only works with power-of-two sized textures.Mobile Pipeline
shaders/Mobile.vertandshaders/Mobile.fragare the two shaders used for the Mobile Pipeline.PipelineManager#MOBILE_PIPELINEis a new constant-style reference to the Mobile Pipeline instance.autoMobilePipelineis a new Game Configuration boolean that toggles if the Mobile Pipeline should be automatically deployed, or not. By default it is enabled, but you can set it tofalseto force use of the Multi Tint pipeline (or if you need more advanced conditions to check when to enable it)defaultPipelineis a new Game Configuration property that allows you to set the default Game Object Pipeline. This is set to Multi Tint as standard, but you can set it to your own pipeline from this value.PipelineManager.defaultis a new propery that is used by most Game Objects to determine which pipeline they will init with.PipelineManager.setDefaultPipelineis a new method that allows you to change the default Game Object pipeline. You could use this to allow for more fine-grained conditional control over when to use Multi or Mobile (or another pipeline)PipelineManager.bootmethod is now passed the default pipeline and auto mobile setting from the Game Config.Multi Tint Pipeline
batchLinemethod in the Multi Pipeline will now check to see if the dxdy len is zero, and if so, it will abort drawing the line. This fixes issues on older Android devices, such as the Samsung Galaxy S6 or Kindle 7, where it would draw erroneous lines leading up to the top-left of the canvas under WebGL when rendering a stroked rounded rectangle. Fix strokeRoundedRect() draws wrong lines on mobile #5429 (thanks @fkoch-tgm @sreadixl)Multi.fragshader now uses ahighpprecision, ormediumpif the device doesn't support it (thanks @arbassic)WebGL.Utils.checkShaderMaxfunction will no longer use a massive if/else glsl shader check and will instead rely on the value given ingl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS).GenerateSrchas been removed as it's no longer required internally.batchSprite,batchTexture,batchTextureFrameandbatchFillRectwould all make heavy use of theTransformMatrix.getXRoundandgetYRoundmethods, which in turn calledgetXandgetYand applied optional rounding to them. This is all now handled by one single function (setQuad) with no branching, meaning rendering one single sprite has cut down 16 function calls and 48 getters to just 1 function.Lights Pipeline
outTintEffectattribute meaning the Light Pipeline will now correctly light both tinted and fill-tinted Game Objects. Fix [3.50] Tint Fill Not Working With Lights Pipeline #5452 (thanks @kainage)maxLightscopies of the Light shader on boot. Previously it would then pick which shader to use, based on the number of visible lights in the Scene. Now, the number of lights is passed to the shader and branches accordingly. This means rather than compiling n shaders on boot, it now only ever needs to create one.Light.fragshader now uses a newuLightCountuniform to know when to stop iterating through the max lights.LightPipeline.LIGHT_COUNTconstant has been removed as it's not used internally.LightPipelineprevious created a global level temporary vec2 for calculations. This is now part of the class as the newtempVec2property.Removed - Graphics Pipeline
The WebGL Graphics Pipeline has been removed. This pipeline wasn't used in v3.55, as all Graphics rendering is handled by the MultiTint pipeline, for better batching support. No Phaser Game Objects use the Graphics pipeline any longer, so to save space it has been removed and is no longer installed by the Pipeline Manager.
New Features - Matter Physics v0.19
We have updated the version of Matter Physics to the latest v0.19 release. This is a big jump and brings with it quite a few internal changes to Matter. The following are the differences we have identified in this release:
Body.setAngularVelocityandBody.setVelocityfunctions to be timestep independentBody.setSpeed,Body.setAngularSpeed,Body.getSpeed,Body.getVelocityandBody.getAngularVelocityupdateVelocityargument toBody.setPosition,Body.setAngle,Body.translateandBody.rotatecorrectionparameter fromEngine.updateas it is now built-inBody.setAngularVelocityandBody.setVelocityto be timestep independent60hzas a baselineBody.setSpeed,Body.setAngularSpeed,Body.getSpeed,Body.getVelocity,Body.getAngularVelocityupdateVelocityargument toBody.setPosition,Body.setAngle,Body.translate,Body.rotateBody.applyForceEngine.updateto be built-in toMatter.Bodybody.deltaTimepropertyspeedsetters toBody.setupdateVelocityargument toBody.setPosition,Body.setAngle,Body.translateandBody.rotatecollisionStartevent to trigger after resolving and after updating body velocitiesConstraint.pointAWorldandConstraint.pointBWorldBody.applyForcedocsNotes
When using a fixed timestep of 60hz (~16.666ms engine delta) results should look similar to before, as this was taken as the baseline.
If you're using a non-fixed timestep or one other than 60hz (~16.666ms) results should now become more similar to the 60hz baseline, therefore you may need to adjust e.g. body and constraint properties.
Since
Body.setAngularVelocityandBody.setVelocityare now timestep independent, you may need to adjust code you may have been using that factored in the timestep.For timestep independence, the
Matter.Bodyspeed and velocity getter and setter functions now relate to a fixed time unit rather than timestep, currently set as 1000/60 for easier backwards compatibility at the baseline 60hz.Note that
Body.applyForcenaturally still remains timestep dependent as before, see the updated Body.applyForce docs for details.While the properties
body.velocityandbody.speed(and angular versions) still exist they are not typically recommended for user code, in most cases you should switch to the newBody.getVelocityandBody.getSpeedfunctions as they are timestep independent.The following changes came from the v0.18 release, which are also part of v0.19:
Matter.Gridwith a faster and more efficient broadphase inMatter.Detector.Matter.SATrelated to collision reuse.Matter.Grid.MatterPhysics.collisionis a new reference to theCollisionmodule, which now handles all Matter collision events.MatterPhysics.gridhas been removed as this is now handled by theCollisionmodule.MatterPhysics.sathas been removed as this is now handled by theCollisionmodule.Matter.Body.previousPositionImpulseproperty has been removed as it's no longer used.Because of the changes above, the following new methods are available to any Phaser Matter Physics Game Object:
getVelocity- Returns the current linear velocity of the Body as a Vec2.getAngularVelocity- Returns the current rotation velocity of the Body.setAngularSpeed- Sets the current rotational speed of the body. Direction is maintained. Affects body angular velocity.getAngularSpeed- Returns the current rotational speed of the body. Equivalent to the magnitude of its angular velocity.New Features - New Tween Manager
TODO - TweenData to class
TODO - TweenData and Tween State methods
TODO - CONST removals
The Phaser 3.60 Tween system has been rewritten to help with performance, resolve some of its lingering issues and unifies the Tween events and callbacks.
The following are breaking changes:
chainmethod. This should give most developers the same level of sequencing they had using Timelines, without the timing issues.Tween.seekmethod used to take a value between 0 and 1, based on how far through the Tween you wished to seek. However, it did not work with infinitely looping or repeating Tweens and would crash the browser tab. The newseekmethod takes a value in milliseconds instead and works perfectly on infinite Tweens.duration,hold,repeatandrepeatDelay. These should be numbers only. You can, however, still provide a function fordelay, to keep it compatible with the StaggerBuilder.TweenManager#getAllTweensmethod has been renamed toTweenManager#getTweens. Functionally, it is the same.Tween.useFrameshas been removed and is no longer a valid Tween Config option. Tweens are now entirely millisecond based.TweenOnUpdateCallbacknow has the following parameters:tween,targets,key(the property being tweened),current(the current value of the property),previous(the previous value of the property) and finally any of the params that were passed in theonUpdateParamsarray when the Tween was created.TweenOnYoyoCallbacknow has the following parameters:tween,targets,key(the property being tweened),current(the current value of the property),previous(the previous value of the property) and finally any of the params that were passed in theonYoyoParamsarray when the Tween was created.TweenOnRepeatCallbacknow has the following parameters:tween,targets,key(the property being tweened),current(the current value of the property),previous(the previous value of the property) and finally any of the params that were passed in theonRepeatParamsarray when the Tween was created.Tween.stophas had theresetToparameter removed from it. Callingstopon a Tween will now prepare the tween for immediate destruction. If you only wish to pause the tween, seeTween.pauseinstead.persistsboolean flag when creating it, or toggle theTween.persistproperty before playback. This will force the Tween to not be destroyed by the Tween Manager, allowing you to replay it at any later point. The trade-off is that you are now entirely responsible for destroying the Tween when you are finished with it, in order to free-up resources.onActiveScope,onCompleteScope,onLoopScope,onPauseScope,onRepeatScope,onResumeScope,onStartScope,onStopScope,onUpdateScopeandonYoyoScope. You should set thecallbackScopeproperty instead, which will globally set the scope for all callbacks. You can also set theTween.callbackScopeproperty.The following are to do with the new Chained Tweens feature:
TweenManager.chain- TODOTween.getChainedTweensis a new method that will return all of the tweens in a chained sequence, starting from the point of the Tween this is called on.TweenManager.getChainedTweens(tween)is a new method that will return all of the tweens in a chained sequence, starting from the given tween.You can now specify a target property as 'random' to have the Tween pick a random float between two given values, for example:
alpha: 'random(0.25, 0.75)'. If you wish to force it to select a random integer, use 'int' instead:x: 'int(300, 600)'.The following are further updates within the Tween system:
TweenManager.addandTweenManager.createcan now optionally take an array of Tween Configuration objects. Each Tween will be created, added to the Tween Manager and then returned in an array. You can still pass in a single config if you wish.Tween.pauseis a new method that allows you to pause a Tween. This will emit the PAUSE event and, if set, fire theonPausecallback.Tween.resumeis a new method that allows you to resume a paused Tween. This will emit the RESUME event and, if set, fire theonResumecallback.TweenOnPauseCallbackavailable when creating a Tween (via theonPauseproperty). This comes with associatedonPauseParamsandonPauseScopeproperties, too, like all other callbacks and can also be added via theTween.setCallbacksmethod. This callback is invoked if you pause the Tween.TweenOnResumeCallbackavailable when creating a Tween (via theonResumeproperty). This comes with associatedonResumeParamsandonResumeScopeproperties, too, like all other callbacks and can also be added via theTween.setCallbacksmethod. This callback is invoked if you resume a previously paused Tween.x: [ 100, 300, 200, 600 ]in which case the Tween will use interpolation to determine the value.interpolationproperty in the Tween config to set which interpolation method the Tween will use if an array of numeric values have been given as the tween value. Valid values includeslinear,bezierandcatmull(orcatmullrom), or you can provide your own function to use.scaleproperty in a Tween config and, if the target does not have ascaleproperty itself (i.e. a GameObject) then it will automatically apply the value to bothscaleXandscaleYtogether during the tween. This is a nice short-cut way to tween the scale of Game Objects by only specifying one property, instead of two.killTweensOf(targets)now supports deeply-nested arrays of items as thetargetparameter. Fix scene.tweens.killTweensOf(myArray, myObject) doesnt kill tweens on myArray objects #6016 (thanks @michalfialadev)killTweensOf(target)did not stop target tweens if called immediately after tween creation. Fix killTweensOf(target) does not stop target tweens, if called immediately after tween creation. #6173 (thanks @michalfialadev)Tween.setCallback()without specifying theparamsargument would cause an error invoking the callback params. This parameter is now fully optional. Fix Tween.setCallback bugs if optional argument (param) is not passed, also the function gets called 3 times instead of once #6047 (thanks @orcomarcio)Tween.playimmediately after creating a tween withpaused: truein the config wouldn't start playback. Fix Calling play() on fresh paused tween doesn't play it #6005 (thanks @MartinEyebab)timeScalevalue unless they were using frame-based timing instead of delta timing.Tween.seek,toPositionnow defaults to zero. Previously, you had to specify a value.TweenBuildernow uses the newGetInterpolationFunctionfunction internally.TweenBuilderhas been optimized to perform far less functions when creating the TweenData instances.interpolationhas been added to the Reserved Words list and Defaults list (it defaults tonull).persistshas been added to the Reserved Words list and Defaults list (it defaults tofalse).Tween.initTweenDatais a new method that handles the initialisation of all the Tween Data and Tween values. This replaces what took place in theinitandseekmethods previously. This is called automatically and should not usually be invoked directly.Tween.calcDurationmethod has been removed. This is now handled as part of theinitTweenDatacall.repeatandholdwould cause the Tween to include one final hold before marking itself as complete. It now completes as soon as the final repeat concludes, not after an addition hold.New Features - Dynamic Textures and Render Textures
A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of Game Objects directly to it.
You can take many complex objects and draw them to this one texture, which can then be used as the base texture for other Game Objects, such as Sprites. Should you then update this texture, all Game Objects using it will instantly be updated as well, reflecting the changes immediately.
It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads on each change.
Before Phaser 3.60 this was known as a Render Texture. Dynamic Textures have been optimized and also offer the following new features and updates. All of these are also available to the new Render Texture, via the
textureproperty:TextureManager.addDynamicTexture(key, width, height)is a new method that will create a Dynamic Texture and store it in the Texture Manager, available globally for use by any Game Object.Phaser.Textureclass, meaning you can use it for any texture based object and also call all of the native Texture methods, such as the ability to add frames to it, use it as the backing source for a sprite sheet or atlas, and more.DynamicTexture.isDrawingis a new boolean that allows you to tell if a batch draw has been started and is in process.DynamicTexture.isSpriteTextureis a new boolean that informs the texture if it is being used as a backing texture for Sprite Game Objects, or not. If it is (which is the default) then items drawn to the texture are automatically inversed. Doing this ensures that images drawn to the Render Texture are correctly inverted for rendering in WebGL. Not doing so can cause inverted frames. If you use this method, you must use it before drawing anything to the Render Texture. Fix WebGL: RenderTexture frames do not render correctly #6057 Spritsheet to texture is reversed #6017 (thanks @andymikulski @Grandnainconnu)DynamicTexture.setIsSpriteTextureis a new method that allows you to toggle theisSpriteTextureproperty in a chained manner.DynamicTexture.renderTargetis a new property that holds an instance of a RenderTarget under WebGL. This encompasses a framebuffer and backing texture, rather than having them split.DynamicTexture.stampis a new method that takes a given texture key and then stamps it at the x/y coordinates provided. You can also pass in a config object that gives a lot more control, such as alpha, tint, angle, scale and origin of the stamp. This is a much cleaner way of stamping a texture to the DynamicTexture without having to first turn it into a Game Object.DynamicTexture.repeatis a new method that will take a given texture and draw it to the Dynamic Texture as a fill-pattern. You can control the offset, width, height, alpha and tint of the draw (thanks xlapiz)batchGameObjectnow splits based on the renderer, allowing us to combine lots of the rendering code together, saving space.snapshotandsnapshotPixelmethods now use thesnapshotAreamethod to reduce code and filesize.snapshotPixelfunction, used by the Canvas and WebGL Renderers and the RenderTexture would mistakenly divide the alpha value. These values now return correctly (thanks @samme)DynamicTexture.batchTextureFramewill now skip thedrawImagecall in canvas if the frame width or height are zero. Fix iOS drawImage fails with IndexSizeError: The index is not in allowed range #5951 (thanks @Hoshinokoe)DynamicTexture.fillin CANVAS mode only would produce a nearly always black color due to float conversion (thanks @andymikulski)DynamicTexture.fillin CANVAS mode only, after using theerasemethod, wouldn't reset the global composite operation correctly, resulting in fills. Fix Canvas Mode: RenderTexture "fill" method does not set "globalCompositeOperation" #6124 (thanks @mateuszkmiecik)draw,drawFrameorbatchDrawFrameand specifying atintvalue would inverse the Red and Blue channels. These are now handled properly. Fix RenderTexture.draw with tint: red/blue values inverted #5509 (thanks @anthonygood)Due to the creation of the Dynamic Texture class, we have completely revamped the old Render Texture Game Object. This is now a combination of a Dynamic Texture and an Image Game Object, that uses the Dynamic Texture to display itself with.
In versions of Phaser before 3.60 a Render Texture was the only way you could create a texture like this, that had the ability to be drawn on. But in 3.60 we split the core functions out to the Dynamic Texture class as it made a lot more sense for them to reside in there. As a result, the Render Texture is now a light-weight shim that sits on-top of an Image Game Object and offers proxy methods to the features available from a Dynamic Texture.
Render Texture breaking changes:
Render Textures used to be able to take
keyandframearguments in their constructors, which would take the texture from the Texture Manager and use that instance, instead of creating a new one. Because Dynamic Textures are always stored in the Texture Manager from the beginning, there is no need to specify these arguments. You can just get it from the Texture Manager by using its key.The following
RenderTextureproperties have changed:rendereris now available viatexture.renderer.textureManagerhas been removed.globalTinthas been removed.globalAlphahas been removed.canvasis now available viatexture.canvas.contextis now available viatexture.context.dirtyis now available viatexture.dirty.camerais now available viatexture.camera.renderTargetis now available viatexture.renderTarget.originis now (0.5, 0.5) by default instead of (0, 0).The following
RenderTexturemethods have changed:drawGameObjecthas been removed, this is now handled by the batch methods.resizehas been renamed. UsesetSize(width, height)instead.setGlobalTinthas been removed as it's no longer used internally.setGlobalAlphahas been removed as it's no longer used internally.batchGameObjectWebGLhas been removed, now handled bybatchGameObject.batchGameObjectCanvashas been removed, now handled bybatchGameObject.When should you use a Render Texture vs. a Dynamic Texture?
You should use a Dynamic Texture if the texture is going to be used by multiple Game Objects, or you want to use it across multiple Scenes, because textures are globally stored.
You should use a Dynamic Texture if the texture isn't going to be displayed in-game, but is instead going to be used for something like a mask or shader.
You should use a Render Texture if you need to display the texture in-game on a single Game Object, as it provides the convenience of wrapping an Image and Dynamic Texture together for you.
Post Pipeline Updates
In order to add clarity in the codebase we have created a new
PostPipelineComponent and moved all of the relevant functions from thePipelinecomponent in to it. This leads to the following changes:PostPipelineis a new Game Object Component that is now inherited by all Game Objects that are capable of using it.PostPipelinecomponent now have a new property calledpostPipelineData. This object is used for storing Post Pipeline specific data in. Previously, both regular and post pipelines used the samepipelineDataobject, but this has now been split up for flexibility.Pipeline.resetPipelinemethod no longer has its firstresetPostPipelinesargument. It now has just one argumentresetDataso please be aware of this if you call this function anywhere in your code.PostPipeline.initPostPipelineis a new method that should be called by any Game Object that supports Post Pipelines.PostPipelineComponent exclusively:ContainerandLayer.Input System Updates
There are breaking changes from previous versions of Phaser.
InteractiveObject.alwaysEnabledproperty has been removed. It is no longer checked within theInputPluginand setting it will have no effect. This property has not worked correctly since version 3.52 when the new render list was implemented. Upon further investigation we decided to remove the property entirely, rather than shoe-horn it into the render list. If you need to create a non-rendering Interactive area, use the Zone Game Object instead.Bitmap Mask Updates
There are breaking changes from previous versions of Phaser.
x, y, texture, frameif no masked object is provided.this.add.bitmapMask()from within a Scene, for easier creation.renderer,maskTexture,mainTexture,dirty,mainFramebufferandmaskFramebuffer. The following methods have also been removed:createMaskandclearMask.WebGLRendererhas 2 new properties:maskSourceandmaskTarget. These are the new global mask framebuffers.WebGLRenderer.beginBitmapMaskis a new method that starts the process of using the mask target framebuffer for drawing. This is called by theBitmapMaskPipeline.WebGLRenderer.drawBitmapMaskis a new method that completes the process of rendering using the mask target framebuffer. This is called by theBitmapMaskPipeline.BitmapMaskPipelinenow hands over most control of the framebuffers to the WebGLRenderer.GameObjects.Components.Mask.createBitmapMaskmethod can now accept thex,y,textureandframeparameters new to the BitmapMask constructor.createBitmapMaskon a Shape Game Object would fail unless you passed the shape to the method. Now, it will correctly create a mask from the Shape without needing to pass it. FixcreateBitmapMask()is inconsistent when used on Shapes #5976 (thanks @samme)TimeStep Updates
fps: { limit: 30 }value in your game config. In this case, it will set an fps rate of 30. This forces Phaser to not run the game step more than 30 times per second (or whatever value you set) and works for both Request Animation Frame and SetTimeOut.TimeStep._limitRateis a new internal private property allowing the Timestep to keep track of fps-limited steps.TimeStep.hasFpsLimitis a new internal boolean so the Timestep knows if the step is fps rate limited, or not.TimeStep.stepmethod andTimeStep.setLimitFPSmethod. Which one is called depends on if you have fps limited your game, or not. This switch is made internally, automatically.TimeStep.smoothDeltais a new method that encapsulates the delta smoothing.TimeStep.updateFPSis a new method that calculates the moving frame rate average.TimeStep.wakewill now automatically reset the fps limits and internal update counters.TimeStep.destroywill now callRequestAnimationFrame.destroy, properly cleaning it down.RequestAnimationFrame.stepwill now no longer callrequestAnimationFrameifisRunninghas been set tofalse(via thestopmethod)TimeStepno longer calculates or passes theinterpolationvalue to Game.step as it was removed several versions ago, so is redundant.RequestAnimationFrame.tickproperty has been removed as it's no longer used internally.RequestAnimationFrame.lastTimeproperty has been removed as it's no longer used internally.RequestAnimationFrameclass no longer calculates the tick or lastTime values and doesn't callperformance.nowas these values were never used internally and were not used by the receiving callback either.RequestAnimationFrame.targetproperty has been renamed todelayto better describe what it does.deltaSmoothingMaxvalue set in the game config. This is now clamped correctly (thanks @vzhou842)New Features
staggeraxis-y + staggerindex-odd,staggeraxis-x + staggerindex-odd,staggeraxis-y + staggerindex-evenandstaggeraxis-x, staggerindex-even(thanks @rexrainbow)tileFilterOptionswhich is an object passed to theGetTilesWithinmethods used by the Sprite vs. Tilemap collision functions. These filters dramatically reduce the quantity of tiles being checked for collision, potentially saving thousands of redundant math comparisons from taking place.Graphics.strokeRoundedRectandfillRoundedRectmethods can now accept negative values for the corner radius settings, in which case a concave corner is drawn instead (thanks @rexrainbow)AnimationManager.getAnimsFromTextureis a new method that will return all global Animations, as stored in the Animation Manager, that have at least one frame using the given Texture. This will not include animations created directly on local Sprites.BitmapText.setLineSpacingis a new method that allows you to set the vertical spacing between lines in multi-line BitmapText Game Objects. It works in the same was as spacing for Text objects and the spacing value can be positive or negative. See alsoBitmapText.lineSpacingfor the property rather than the method.WebGLPipeline.vertexAvailableis a new method that returns the number of vertices that can be added to the current batch before it will trigger a flush.TilemapandTilemapLayerclasses have a new methodgetTileCorners. This method will return an array of Vector2s with each entry corresponding to the corners of the requested tile, in world space. This currently works for Orthographic and Hexagonal tilemaps.BaseSoundManager.getAllPlayingis a new method that will return all currently playing sounds in the Sound Manager.Animation.showBeforeDelayis a new optional boolean property you can set when creating, or playing an animation. If the animation has a delay before playback starts this controls if it should still set the first frame immediately, or after the delay has expired (the default).InputPlugin.resetPointersis a new method that will loop through all of the Input Manager Pointer instances and reset them all. This is useful if a 3rd party component, such as Vue, has stolen input from Phaser and you need to reset its input state again.Pointer.resetis a new method that will reset a Pointer instance back to its 'factory' settings.Group.createMultipleit will now skip the post-creations options if they are not set in the config object used, or a Game Object constructor. Previously, things like alpha, position, etc would be over-written by the defaults if they weren't given in the config, but now the method will check to see if they are set and only use them if they are. This is a breaking change, but makes it more efficient and flexible (thanks @samme)onStart, which is passed the parametersfromScene,toSceneanddurationallowing you to consolidate transition logic into a single callback, rather than split across the start and end events (thanks @rexrainbow)TextureManager.silentWarningsis a new boolean property that, when set, will prevent the Texture Manager from emiting any warnings or errors to the console in the case of missing texture keys or invalid texture access. The default is to display these warnings, this flag toggles that.TextureManager.parseFrameis a new method that will return a Texture Frame instance from the given argument, which can be a string, array, object or Texture instance.GameConfig.stableSortandDevice.features.stableSortis a new property that will control if the internal depth sorting routine uses our own StableSort function, or the built-in browserArray.sort. Only modern browsers have a stableArray.sortimplementation, which Phaser requires. Older ones need to use our function instead. Set to 0 to use the legacy version, 1 to use the ES2019 version or -1 to have Phaser try and detect which is best for the browser (thanks @JernejHabjan)Device.es2019is a new boolean that will do a basic browser type + version detection to see if it supports ES2019 features natively, such as stable array sorting.sourceparameter:addSpriteSheet,addAtlas,addAtlasJSONArray,addAtlasJSONHash,addAtlasXMLandaddAtlasUnity. This allows you to add sprite sheet or atlas data to existing textures, or textures that came from external sources, such as SVG files, canvas elements or Dynamic Textures.Game.pauseis a new method that will pause the entire game and all Phaser systems.Game.resumeis a new method that will resume the entire game and resume all of Phaser's systems.Game.isPausedis a new boolean that tracks if the Game loop is paused, or not (and can also be toggled directly)ScaleManager.getViewPortis a new method that will return a Rectangle geometry object that matches the visible area of the screen, or the given Camera instance (thanks @rexrainbow)GameObjects.Layer.addToDisplayListandremoveFromDisplayListare new methods that allows for you to now add a Layer as a child of another Layer. Fix Error adding Layer to Layer #5799 (thanks @samme)GameObjects.Video.loadURLhas a new optional 4th parametercrossOrigin. This allows you to specify a cross origin request type when loading the video cross-domain (thanks @rmartell)loader.imageLoadType: "HTMLImageElement"in your Game Configuration and the Phaser Loader will use an Image Tag to load all images, rather than XHR and a Blob object which is the default. This is a global setting, so all file types that use images, such as Atlas or Spritesheet, will be changed via this flag (thanks @hanzooo)Tileset.tileOffset(which is a Vector2). This property is set automatically when Tiled data is parsed and found to contain it. Fix Phaser 3.54 draw offset layer #5633 (thanks @moJiXiang @kainage)Tilemap.createFromObjectsmethod has been overhauled to support typed tiles from the Tiled Map Editor (https://doc.mapeditor.org/en/stable/manual/custom-properties/#typed-tiles). It will now also examine the Tileset to inherit properties based on the tile gid. It will also now attempt to use the same texture and frame as Tiled when creating the object (thanks @lackhand)TweenManager.resetis a new method that will take a tween, remove it from all internal arrays, then seek it back to its start and set it as being active.Videoconfig will now detect forx-m4vplayback support for video formats and store it in theVideo.m4vproperty. This is used automatically by theVideoFilefile loader. Fix Using M4V extension instead of mp4 breaks loading #5719 (thanks @patrickkeenan)KeyboardPlugin.removeKeymethod has a new optional parameterremoveCapture. This will remove any keyboard capture events for the given Key. Fix Removing aKeydoesn't remove capturing fromKeyboardPlugin#5693 (thanks @cyantree)KeyboardPlugin.removeAllKeysmethod has a new optional parameterremoveCapture. This will remove any keyboard capture events for all of the Keys owned by the plugin.WebGLShader.fragSrcis a new property that holds the source of the fragment shader.WebGLShader.vertSrcis a new property that holds the source of the vertex shader.WebGLShader#.createProgramis a new method that will destroy and then re-create the shader program based on the given (or stored) vertex and fragment shader source.WebGLShader.setBooleanis a new method that allows you to set a boolean uniform on a shader.WebGLPipeline.setBooleanis a new method that allows you to set a boolean uniform on a shader.Phaser.Scenes.Systems.getStatusis a new method that will return the current status of the Scene.Phaser.Scenes.ScenePlugin.getStatusis a new method that will return the current status of the given Scene.Math.LinearXYis a new function that will interpolate between 2 given Vector2s and return a new Vector2 as a result (thanks @GregDevProjects)Curves.Path.getCurveAtis a new method that will return the curve that forms the path at the given location (thanks @natureofcode)ShapeGame Object as a Geometry Mask. Fix [Feature request] Allow Shape game object to be a mask #5900 (thanks @rexrainbow)Mesh.setTintis a new method that will set the tint color across all vertices of a Mesh (thanks @rexrainbow)Mesh.tintis a new setter that will set the tint color across all vertices of a Mesh (thanks @rexrainbow)Mesh.clearTintis a new method that will clear the tint from all vertices of a Mesh (thanks @rexrainbow)Vector2.projectis a new method that will project the vector onto the given vector (thanks @samme)TilemapLayernow has theMaskcomponent - meaning you can apply a mask to tilemaps (thanks @samme)TilemapLayer.setTintis a new method that allows you to set the tint color of all tiles in the given area, optionally based on the filtering search options. This is a WebGL only feature.UtilityPipeline.blitFramehas a new optional boolean parameterflipYwhich, if set, will invert the source Render Target while drawing it to the destination Render Target.GameObjects.Polygon.setTois a new method that allows you to change the points being used to render a Polygon Shape Game Object. Fix The GO Polygon is missing a method for adding points #6151 (thanks @PhaserEditor2D)maxAliveParticlesis a new Particle Emitter config property that sets the maximum number of alive particles the emitter is allowed to update. When this limit is reached a particle will have to die before another can be spawned.Utils.Array.Flattenis a new function that will return a flattened version of an array, regardless of how deeply-nested it is.GameObjects.Text.appendTextis a new method that will append the given text, or array of text, to the end of the content already stored in the Text object.Textures.Events.ADD_KEYis a new event dispatched by the Texture Manager when a texture with the given key is added, allowing you to listen for the addition of a specific texture (thanks @samme)Textures.Events.REMOVE_KEYis a new event dispatched by the Texture Manager when a texture with the given key is removed, allowing you to listen for the removal of a specific texture (thanks @samme)Geom Updates
The following are API-breaking, in that a new optional parameter has been inserted prior to the output parameter. If you use any of the following functions, please update your code:
Geom.Intersects.GetLineToLinemethod has a new optional parameterisRay. Iftrueit will treat the first line parameter as a ray, if false, as a line segment (the default).Geom.Intersects.GetLineToPointsmethod has a new optional parameterisRay. Iftrueit will treat the line parameter as a ray, if false, as a line segment (the default).Geom.Intersects.GetLineToPolygonmethod has a new optional parameterisRay. Iftrueit will treat the line parameter as a ray, if false, as a line segment (the default).Geom.Intersects.GetRaysFromPointToPolygonuses the newisRayparameter to enable this function to work fully again.Loader Updates
MultiFile.pendingDestroyis a new method that is called by the Loader Plugin and manages preparing the file for deletion. It also emits theFILE_COMPLETEandFILE_KEY_COMPLETEevents, fixing a bug whereMultiFilerelated files, such as an Atlas JSON or a Bitmap Font File, wouldn't emit thefilecompleteevents for the parent file, only for the sub-files. This means you can now listen for the file completion event formultiatlasfiles, among others.MultiFile.destroyis a new method that clears down all external references of the file, helping free-up resources.File.addToCacheno longer callsFile.pendingDestroy, instead this is now handled by the Loader Plugin.FILE_PENDING_DESTROYwhich is used to ensure Files aren't flagged for destruction more than once.LoaderPlugin.localSchemesis a new array of scheme strings that the Loader considers as being local files. This is populated by the newPhaser.Core.Config#loaderLocalSchemegame / scene config property. It defaults to[ 'file://', 'capacitor://' ]but additional schemes can be defined or pushed onto this array. Based on Fix WebAudio for Crodova based apps #6010 (thanks @kglogocki)Updates
AnimationManagerandAnimationStateif you try to add an animation with a key that already exists. Fix createFromAseprite() consecutively #6434.Tilemap.addTilesetImagehas a new optional parametertileOffsetwhich, if given, controls the rendering offset of the tiles. This was always available on the Tileset itself, but not from this function (thanks @imothee)GameObject.getBoundsmethod will now return aGeom.Rectangleinstance, rather than a plain Object (thanks @samme)GetBounds.getCentermethod now has an optionalincludeParentargument, which allows you to get the value in world space.MatterTileBodyclass, which is created when you convert a Tilemap into a Matter Physics world, will now check to see if the Tile hasflipXorflipYset on it and rotate the body accordingly. Fix Parsing of Rotation/Flipping of Tiled map does not properly handle FlipY #5893 (thanks @Olliebrown @phaserhelp)BaseCamerahas had itsAlphacomponent replaced withAlphaSingle. Previously you had access to properties such asalphaTopLeftthat never worked, now it correctly has just a single alpha property (thanks @samme)Time.Clock.startTimeis a new property that stores the time the Clock (and therefore the Scene) was started. This can be useful for comparing against the current time to see how much real world time has elapsed (thanks @samme)ColorMatrix._matrixand_dataare now Float32Arrays.ColorMatrix.set,resetandgetDatamethods all now use the built-in Float32 Array operations, making them considerably faster.ColorMatrix.BLACK_WHITEis a new constant used by blackwhite operations.ColorMatrix.NEGATIVEis a new constant used by negative operations.ColorMatrix.DESATURATE_LUMINANCEis a new constant used by desaturation operations.ColorMatrix.SEPIAis a new constant used by sepia operations.ColorMatrix.LSDis a new constant used by LSD operations.ColorMatrix.BROWNis a new constant used by brown operations.ColorMatrix.VINTAGEis a new constant used by vintage pinhole operations.ColorMatrix.KODACHROMEis a new constant used by kodachrome operations.ColorMatrix.TECHNICOLORis a new constant used by technicolor operations.ColorMatrix.POLAROIDis a new constant used by polaroid operations.ColorMatrix.SHIFT_BGRis a new constant used by shift BGR operations.Texture.haswill now return a strict boolean, rather than an object that can be cooerced into a boolean (thanks @samme)CanvasTexture.drawmethod has a new optional parameterupdatewhich allows you to control if the internal ImageData is recalculated, or not (thanks @samme)CanvasTexture.drawFramemethod has a new optional parameterupdatewhich allows you to control if the internal ImageData is recalculated, or not (thanks @samme)CanvasTexture.clearmethod has a new optional parameterupdatewhich allows you to control if the internal ImageData is recalculated, or not (thanks @samme)Game.registry, which is aDataManagerinstance that can be used as a global store of game wide data will now use its own Event Emitter, instead of the Game's Event Emitter. This means it's perfectly safe for you to now use the Registry to emit and listen for your own custom events without conflicting with events the Phaser Game instance emits.GenerateVertsfunction has a new optional parameterflipUVwhich, if set, will flip the UV texture coordinates (thanks cedarcantab)GenerateVertsfunction no longer errors if the verts and uvs arrays are not the same size andcontainsZis true (thanks cedarcantab)Device.Browserchecks for Opera and Edge have been updated to use the more modern user agent strings those browsers now use. This breaks compatibility with really old versions of those browsers but fixes it for modern ones (which is more important) (thanks @ArtemSiz)
SceneManager.processQueuemethod will no longerreturnif a new Scene was added, after starting it. This allows any other queued operations to still be run in the same frame, rather than being delayed until the next game frame. Fix Unexpected behavior of queued scene operations #5359 (thanks @telinc1)Camera.scrollXandscrollYwill now only set theCamera.dirtyflag totrueif the new value given to them is different from their current value. This allows you to use this property in your own culling functions. Fix camera.dirty flag is always true inside Phaser.Tilemaps.TilemapLayer.cullCallback #6088 (thanks @Waclaw-I)Face.updateis a new method that updates each of the Face vertices. This is now called internally byFace.isInView.Vertex.resizeis a new method that will set the position and then translate the Vertex based on an identity matrix.Vertex.updatemethod now returnsthisto allow it to be chained.maxSpeedvalue in the Arcade Physics Group config (thanks @samme)useDampingboolean in the Arcade Physics Group config (thanks @samme)HexagonalTileToWorldYfunction as it cannot work without an X coordinate. UseHexagonalTileToWorldXYinstead.HexagonalWorldToTileYfunction as it cannot work without an X coordinate. UseHexagonalWorldToTileXYinstead.BaseSoundManager.getAllmethod used to require akeyparameter, to return Sounds matching the key. This is now optional and if not given, all Sound instances are returned.WebAudioSoundManagerwill now detect if the Audio Context enters a 'suspended' or 'interrupted' state as part of its update loop and if so it'll try to resume the context. This can happen if you change or disable the audio device, such as plugging in headphones with built-in audio drivers then disconnecting them, or swapping tabs on iOS. Fix Plug in your headphones, unplug them, and the audio stops #5353 (thanks @helloyoucan)CONTEXT_RESTOREDGame Event has been removed and the WebGL Renderer no longer listens for thecontextrestoredDOM event, or has acontextRestoredHandlermethod. This never actually worked properly, in any version of Phaser 3 - although the WebGLRenderer would be restored, none of the shaders, pipelines or textures were correctly re-created. If a context is now lost, Phaser will display an error in the console and all rendering will halt. It will no longer try to re-create the context, leading to masses of WebGL errors in the console. Instead, it will die gracefully and require a page reload.TextandTileSpriteGame Objects no longer listen for theCONTEXT_RESTOREDevent and have had theironContextRestoredmethods removed.Scenes.Systems.canInputis a new internal method that determines if a Scene can receive Input events, or not. This is now used by theInputPlugininstead of the previousisActivetest. This allows a Scene to emit and handle input events even when it is runninginitorpreload. Previously, it could only do this aftercreatehad finished running. Fix Interactive Object can not be clickable while preload progress complete #6123 (thanks @yaasinhamidi)BitmapTextGame Object has two new read-only propertiesdisplayWidthanddisplayHeight. This allows the BitmapText to correctly use theGetBoundscomponent.BitmapTextGame Object now has theGetBoundscomponent added to it, meaning you can now correctly get its dimensions as part of a Container. Fix getBounds() does not detect BitmapText size in Container #6237 (thanks @likwidgames)WebGLSnapshotwill now flip the pixels in the created Image element if the source was a framebuffer. This means grabbing a snapshot from a Dynamic or Render Texture will now correctly invert the pixels on the y axis for an Image. Grabbing from the game renderer will skip this.WebGLRenderer.snapshotFramebufferand by extension, the snapshot methods in Dynamic Textures and Render Textures, has been updated to ensure that the width and height never exceed the framebuffer dimensions, or it'll cause a runtime error. The methodsnapshotAreahas had this limitation removed as a result, allowing you to snapshot areas that are larger than the Canvas. Fix RenderTexture snapshotFramebuffer cannot exceed the size of the drawingBuffer #5707 (thanks @teng-z)Animation.stopis always called when a new animation is loaded, regardless if the animation was playing or not and thedelayCounteris reset to zero. This stops animations with delays preventing other animations from being started until the delay has expired. Fix [3.50] "delay" property in animation config results in uninterruptible/unstable animation #5680 (thanks @enderandpeter)ScaleManager.listenershas been renamed todomlistenersto avoid conflicting with the EventEmitter listeners object. Fix EventEmitter#listeners & ScaleManager#listeners #6260 (thanks @x-wk)Geom.Intersects.LineToLinewill no longer create an internalPointobject, as it's not required internally (thanks @Trissolo)tempZoneused byGridAlignhas now hadsetOrigin(0, 0)applied to it. This leads to more accurate / expected zone placement when aligning grid items.GetBitmapTextSizefunction now includes an extra property in the resultingBitmapTextCharacterobject calledidxwhich is the index of the character within the Bitmap Text, without factoring in any word wrapping (thanks @JaroVDH)Camera.isSceneCamerais a new boolean that controls if the Camera belongs to a Scene (the default), or a Texture. You can set this via theCamera.setScenemethod. Once set theCamera.updateSystemmethod is skipped, preventing the WebGL Renderer from setting a scissor every frame.Camera.preRenderwill now applyMath.floorinstead ofMath.roundto the values, keeping it consistent with the Renderer when following a sprite.roundPixelsit will now runMath.flooron the Matrix position, preventing you from noticing 'jitters' as much when Camera following sprites in heavily zoomed Camera systems.TransformMatrix.setQuadis a new method that will perform the 8 calculations required to create the vertice positions from the matrix and the given values. The result is stored in the newTransformMatrix.quadFloat32Array, which is also returned from this method.TransformMatrix.multiplynow directly updates the Float32Array, leading to 6 less getter invocations.CameraManager.getVisibleChildrenmethod now uses the native Array filter function, rather than a for loop. This should improve performance in some cases (thanks @JernejHabjan)SceneManager.systemSceneis a new property that is set during the game boot and is a system Scene reference that plugins and managers can use, that lives outside of the Scene list.TextureManager.getmethof can now accept aFrameinstance as its parameter, which will return the frames parent Texture.GameObject.setFramemethod can now accept aFrameinstance as its parameter, which will also automatically update the Texture the Game Object is using.Device.safariVersionis now set to the version of Safari running, previously it was always undefined.hitAreaparameter of theGameObjects.Zone.setDropZonemethod is now optional and if not given it will try to create a hit area based on the size of the Zone Game Object (thanks @rexrainbow)DOMElement.preUpdatemethod has been removed. If you overrode this method, please now seepreRenderinstead.DOMElement.preRenderis a new method that will check parent visibility and improve its behavior, responding to the parent even if the Scene is paused or the element is inactive. Dom Elements are also no longer added to the Scene Update List. Fix setVisible not working for DOM elements in a container #5816 (thanks @prakol16 @samme)Particle.firewill now throw an error if the particle has no texture frame. This prevents an uncaught error later when the particle fails to render. Fix Please add useful information when a particles emitter has an invalid/null frame #5838 (thanks @samme @monteiz)ParticleEmitterManager.setEmitterFrameswill now print out console warnings if an invalid texture frame is given, or if no texture frames were set. Fix Please add useful information when a particles emitter has an invalid/null frame #5838 (thanks @samme @monteiz)SceneManager.stopandsleepwill now ignore the call if the Scene has already been shut down, avoiding potential problems with duplicate event handles. Fix Shutdown shouldn't be repeated for stopped scenes #5826 (thanks @samme)TintandFlipcomponents from theCameraclass. Neither were ever used internally, or during rendering, so it was just confusing having them in the API.console.errorwill be printed if theFile,MultiFile,JSONFileorXMLFilefail to process or parse correctly, even if they manage to load. Fix Warn for file processing failures #5862 Warn when there is a multiFile load failure #5851 (thanks @samme @ubershmekel)ScriptFileLoader File Type has a new optional parameter:type. This is a string that controls the type attribute of the<script>tag that is generated by the Loader. By default it is 'script', but you can change it to 'module' or any other valid type.Scene.pausewill now check to see if the Scene is in either a RUNNING or CREATING state and throw a warning if not. You cannot pause non-running Scenes.Mesh.addVerticeswill now throw a console warning if invalid vertices data is given to the method (thanks @omniowl)Mesh.addVerticesFromObjwill now throw a console warning if invalid vertices data is given to the method (thanks @omniowl)TouchManager.onTouchOverandonTouchOuthave been removed, along with all of their related event calls as they're not used by any browser any more.TouchManager.isTopis a new property, copied from the MouseManager, that retains if the window the touch is interacting with is the top one, or not.InputManager.onTouchMovemethod will now check if the changed touch is over the canvas, or not, via the DOMelementFromPointfunction. This means if the touch leaves the canvas, it will now trigger theGAME_OUTandGAME_OVERevents, where-as before this would only happen for a Mouse. If the touch isn't over the canvas, no Pointer touch move happens, just like with the mouse. Fix Touch moving event still fires when moving outside of canvas at mobile device #5592 (thanks @rexrainbow)TileMap.createBlankDynamicLayerhas now been removed as it was deprecated in 3.50.TileMap.createDynamicLayerhas now been removed as it was deprecated in 3.50.TileMap.createStaticLayerhas now been removed as it was deprecated in 3.50.Animations.AnimationManager.createFromAsepritehas a new optional 3rd parametertarget. This allows you to create the animations directly on a Sprite, instead of in the global Animation Manager (thanks Telemako)Animations.AnimationState.createFromAsepriteis a new method that allows you to create animations from exported Aseprite data directly on a Sprite, rather than always in the global Animation Manager (thanks Telemako)pathpackage used by the TS Defs generator has been moved todevDependencies(thanks @antkhnvsk)GetValuefunction has a new optional parameteraltSourcewhich allows you to provide an alternative object to source the value from.Renderer.Snapshot.WebGLfunction has had its first parameter changed from anHTMLCanvasElementto aWebGLRenderingContext. This is now passed in from thesnapshotmethods inside the WebGL Renderer. The change was made to allow it to work with WebGL2 custom contexts (thanks @andymikulski)disableContextMenufunction, but instead now uses the MouseManager / TouchManager targets, which if not specified defaults to the game canvas. Fix # (thanks @lukashass)Key.resetmethod no longer resets theKey.enabledorKey.preventDefaultbooleans back totrueagain, but only resets the state of the Key. Fix key.enabled = false losing effect when changing window/tab #6098 (thanks @descodifica)gameObject.hitAreaDebug.strokeColorin real-time (thanks @spayton)LightGame Object now has theOriginandTransformcomponents, along with 4 new properties:width,height,displayWidthanddisplayHeight. This allows you to add a Light to a Container, or enable it for physics. Fix Possible Bug?? #6126 (thanks @jcoppage)TransformComponent has a new boolean read-only propertyhasTransformComponentwhich is set totrueby default.World.enableBodymethod will now only create and add aBodyto an object if it has the Transform component, tested by checking thehasTransformComponentproperty. Without the Transform component, creating a Body would error with NaN values, causing the rest of the bodies in the world to fail.ProcessQueue.isActiveis a new method that tests if the given object is in the active list, or not.ProcessQueue.isPendingis a new method that tests if the given object is in the pending insertion list, or not.ProcessQueue.isDestroyingis a new method that tests if the given object is pending destruction, or not.ProcessQueue.addwill no longer place the item into the pending list if it's already active or pending.ProcessQueue.removewill check if the item is in the pending list, and simply remove it, rather than destroying it.Container.addHandlerwill nowThis discussion was created from the release Phaser v3.60 Beta 23.
All reactions