Phaser v4.0.0 Beta 7
Major Changes
- Camera System Rewrite
The camera system rewrite changes the way camera matrices are calculated.
The Phaser 3 camera combined position, rotation, and zoom into Camera#matrix. Camera scroll was appended later.
The new camera system uses two matrices. Camera#matrix is now a combination of rotation, zoom, and scroll. A new Camera#matrixExternal property includes camera position. This allows us to cleanly divide the view from the position.
This change doesn't affect how you set camera properties to change the view. It mostly affects internal systems. However, if you use camera matrices directly, be aware that they have changed.
Camera#matrixnow includes scroll, and excludes position.Camera#matrixExternalis a new matrix, which includes the position.Camera#matrixCombinedis the multiplication ofmatrixandmatrixExternal. This is sometimes relevant.- The
GetCalcMatrix(src, camera, parentMatrix, ignoreCameraPosition)method now takesignoreCameraPosition, causing its return value to use the identity matrix instead of the camera's position. GetCalcMatrixResultsnow includes amatrixExternalproperty, and factors scroll into thecameraandcalcmatrices.- To get a copy of a matrix with scroll factor applied, use
TransformMatrix#copyWithScrollFactorFrom(matrix, scrollX, scrollY, scrollFactorX, scrollFactorY). This generally replaces cases where phrases such asspriteMatrix.e -= camera.scrollX * src.scrollFactorXwere used.
The new system fixes many issues with nested transforms, filters, and other uses of transforms.
Minor Additions
- Add documentation explaining how to modify a
SpriteGPULayerefficiently. - Add
SpriteGPULayer#insertMembersmethod. - Add
SpriteGPULayer#insertMembersDatamethod. - Add
SpriteGPULayer#getDataByteSizemethod. - Add non-looping animations to
SpriteGPULayer(set animation toloop: false) to support one-time particle effects and dynamic sources. - Add creation time to
SpriteGPULayermembers. - Add documentation for writing a
Extern#renderfunction. TilemapLayerandTilemapGPULayernow support a parent matrix during rendering.Shapenow setsfiltersFocusContext = trueby default, to prevent clipping stroke off at the edges.
Fixes and Tweaks
- Fix missing reference to Renderer events in
BatchHandler(thanks @mikuso) - Fix
SpriteGPULayersegment handling (segments changed from 32 to 24 to avoid problems with 32-bit number processing) - Allow negative acceleration in
SpriteGPULayermember animations using Gravity. - Rearrange
SpriteGPULayerdata encoding. - Fix
SpriteGPULayerfailing to generate frame animations from config objects. - Allow
TextureSource#setFlipYto affect all textures (except compressed textures, which have fixed orientation). WebGLProgramWrappernow correctly recognizes uniforms with a value ofundefinedand can recognize if they have not changed and do not need updates.- Set
roundPixelsgame option tofalseby default. It's very easy to get messy results with this option, but it remains available for use cases where it is necessary. - Throw an error if
DOMElementhas no container. - Fix
TileSpriteapplyingsmoothPixelArtgame option incorrectly.