From 9ac03cd565254538e4eaea91c8e55ab0f33e23e4 Mon Sep 17 00:00:00 2001 From: Oliver Kisielius Date: Wed, 13 Dec 2023 15:06:21 -0500 Subject: [PATCH 1/7] Check for undefined to avoid a crash in the examples at phaser3-custom-build. --- src/scene/SceneManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 42a9b24de..43dbaf2de 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -577,7 +577,7 @@ var SceneManager = new Class({ sys.step(time, delta); } - if (sys.scenePlugin._target) + if (sys.scenePlugin && sys.scenePlugin._target) { sys.scenePlugin.step(time, delta); } From 835d77cb8584d08f94c794e9dcdc5b4edcaaaa2f Mon Sep 17 00:00:00 2001 From: Dhashvir Lalla Date: Mon, 15 Jan 2024 05:16:56 +1100 Subject: [PATCH 2/7] fix nineslice hit areas --- src/gameobjects/nineslice/NineSlice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gameobjects/nineslice/NineSlice.js b/src/gameobjects/nineslice/NineSlice.js index 9bf69a1d6..628ff2d6f 100644 --- a/src/gameobjects/nineslice/NineSlice.js +++ b/src/gameobjects/nineslice/NineSlice.js @@ -839,7 +839,7 @@ var NineSlice = new Class({ { this.width = width; this.height = height; - + this.updateDisplayOrigin(); var input = this.input; if (input && !input.customHitArea) From 6ea40f8b3213c49baed80aabee6da37ba30a6d52 Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Wed, 24 Jan 2024 17:25:42 -0500 Subject: [PATCH 3/7] Text textures are now stored in the TextureManager --- changelog/3.80/CHANGELOG-v3.80.md | 1 + src/gameobjects/text/Text.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/changelog/3.80/CHANGELOG-v3.80.md b/changelog/3.80/CHANGELOG-v3.80.md index baeeebd23..06799a08a 100644 --- a/changelog/3.80/CHANGELOG-v3.80.md +++ b/changelog/3.80/CHANGELOG-v3.80.md @@ -9,6 +9,7 @@ * The `TweenChainBuilder` was incorrectly setting the `persist` flag on the Chain to `true`, which goes against what the documentation says. It now correctly sets it to `false`. This means if you previously had a Tween Chain that was persisting, it will no longer do so, so add the property to regain the feature. * The `dropped` argument has now been adeded to the documentation for the `DRAG_END` and `GAMEOBJECT_DRAG_END` events (thanks @samme) * `Container.onChildDestroyed` is a new internal method used to destroy Container children. Previously, if you destroyed a Game Object in an exclusive Container, the game object would (momentarily) move onto the Scene display list and emit an ADDED_TO_SCENE event. Also, if you added a Sprite to a non-exclusive Container and stopped the Scene, you would get a TypeError (evaluating 'this.anims.destroy'). This happened because the fromChild argument in the DESTROY event was misinterpreted as destroyChild in the Container's remove(), and the Container was calling the Sprite's destroy() again. (thanks @samme) +* The `Text` Game Object now places its texture into the global `TextureManager` and a `_textureKey` private string property has been added to reference that texture. # Bug Fixes diff --git a/src/gameobjects/text/Text.js b/src/gameobjects/text/Text.js index 7fde6f821..69525cb4b 100644 --- a/src/gameobjects/text/Text.js +++ b/src/gameobjects/text/Text.js @@ -14,6 +14,7 @@ var GetValue = require('../../utils/object/GetValue'); var RemoveFromDOM = require('../../dom/RemoveFromDOM'); var TextRender = require('./TextRender'); var TextStyle = require('./TextStyle'); +var UUID = require('../../utils/string/UUID'); /** * @classdesc @@ -261,8 +262,18 @@ var Text = new Class({ */ this._crop = this.resetCropObject(); + /** + * The internal unique key to refer to the texture in the TextureManager. + * + * @name Phaser.GameObjects.Text#_textureKey + * @type {string} + * @private + * @since 3.80.0 + */ + this._textureKey = UUID(); + // Create a Texture for this Text object - this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + this.texture = scene.sys.textures.addCanvas(this._textureKey, this.canvas); // Set the context to be the CanvasTexture context this.context = this.texture.context; @@ -1520,7 +1531,12 @@ var Text = new Class({ CanvasPool.remove(this.canvas); - this.texture.destroy(); + var texture = this.texture; + + if (texture) + { + texture.destroy(); + } } /** From 1bfdcfe92228afc8b531537a726b8623cf707066 Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Wed, 24 Jan 2024 19:54:46 -0500 Subject: [PATCH 4/7] TileSprite textures are now stored in the TextureManager --- changelog/3.80/CHANGELOG-v3.80.md | 2 +- src/gameobjects/tilesprite/TileSprite.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/changelog/3.80/CHANGELOG-v3.80.md b/changelog/3.80/CHANGELOG-v3.80.md index 06799a08a..0aa698056 100644 --- a/changelog/3.80/CHANGELOG-v3.80.md +++ b/changelog/3.80/CHANGELOG-v3.80.md @@ -9,7 +9,7 @@ * The `TweenChainBuilder` was incorrectly setting the `persist` flag on the Chain to `true`, which goes against what the documentation says. It now correctly sets it to `false`. This means if you previously had a Tween Chain that was persisting, it will no longer do so, so add the property to regain the feature. * The `dropped` argument has now been adeded to the documentation for the `DRAG_END` and `GAMEOBJECT_DRAG_END` events (thanks @samme) * `Container.onChildDestroyed` is a new internal method used to destroy Container children. Previously, if you destroyed a Game Object in an exclusive Container, the game object would (momentarily) move onto the Scene display list and emit an ADDED_TO_SCENE event. Also, if you added a Sprite to a non-exclusive Container and stopped the Scene, you would get a TypeError (evaluating 'this.anims.destroy'). This happened because the fromChild argument in the DESTROY event was misinterpreted as destroyChild in the Container's remove(), and the Container was calling the Sprite's destroy() again. (thanks @samme) -* The `Text` Game Object now places its texture into the global `TextureManager` and a `_textureKey` private string property has been added to reference that texture. +* The `Text` and `TileSprite` Game Objects now place their textures into the global `TextureManager` and a `_textureKey` private string property has been added which contains a UUID to reference that texture. # Bug Fixes diff --git a/src/gameobjects/tilesprite/TileSprite.js b/src/gameobjects/tilesprite/TileSprite.js index 4e32ae45e..faaae6f62 100644 --- a/src/gameobjects/tilesprite/TileSprite.js +++ b/src/gameobjects/tilesprite/TileSprite.js @@ -11,6 +11,7 @@ var GameObject = require('../GameObject'); var GetPowerOfTwo = require('../../math/pow2/GetPowerOfTwo'); var Smoothing = require('../../display/canvas/Smoothing'); var TileSpriteRender = require('./TileSpriteRender'); +var UUID = require('../../utils/string/UUID'); var Vector2 = require('../../math/Vector2'); // bitmask flag for GameObject.renderMask @@ -219,6 +220,16 @@ var TileSprite = new Class({ */ this._crop = this.resetCropObject(); + /** + * The internal unique key to refer to the texture in the TextureManager. + * + * @name Phaser.GameObjects.TileSprite#_textureKey + * @type {string} + * @private + * @since 3.80.0 + */ + this._textureKey = UUID(); + /** * The Texture this Game Object is using to render with. * @@ -226,7 +237,7 @@ var TileSprite = new Class({ * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} * @since 3.0.0 */ - this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + this.texture = scene.sys.textures.addCanvas(this._textureKey, this.canvas); /** * The Texture Frame this Game Object is using to render with. @@ -556,7 +567,12 @@ var TileSprite = new Class({ this.displayTexture = null; this.displayFrame = null; - this.texture.destroy(); + var texture = this.texture; + + if (texture) + { + texture.destroy(); + } this.renderer = null; }, From 2e4b43be4e908dbe8f0d17f4d33eda5d09add884 Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Fri, 26 Jan 2024 13:19:54 -0500 Subject: [PATCH 5/7] AnimationFrame duration is the duration of the frame if set, msPerFrame is not added --- changelog/3.80/CHANGELOG-v3.80.md | 1 + src/animations/Animation.js | 4 ++-- src/animations/AnimationFrame.js | 3 +-- src/animations/AnimationManager.js | 8 -------- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/changelog/3.80/CHANGELOG-v3.80.md b/changelog/3.80/CHANGELOG-v3.80.md index 0aa698056..18f0493f5 100644 --- a/changelog/3.80/CHANGELOG-v3.80.md +++ b/changelog/3.80/CHANGELOG-v3.80.md @@ -16,6 +16,7 @@ * The `InputManager.onTouchMove` function has been fixed so it now correctly handles touch events on pages that have scrolled horizontally or vertically and shifted the viewport. Fix #6489 (thanks @somechris @hyewonjo) * `Factory.staticBody` had the wrong return type in the docs/TS defs. Fix #6693 (thanks @ddhaiby) * The `Time.Timeline` class didn't show as extending the Event Emitter, or have `config` as an optional argument in the docs / TS defs. Fix #6673 (thanks @ghclark2) +* `Animations.AnimationFrame#duration` is now the complete duration of the frame. Before this included `Animations.AnimationState#msPerFrame` with the value of `Animations.AnimationFrame#duration`. The fix to remove `Animations.AnimationState#msPerFrame` from `Animations.AnimationFrame#duration` has been removed from `Animations.AnimationManager#createFromAseprite` because of this clarification. Fix #6712 (thanks @Nerodon @TomMalitz) ## Examples, Documentation, Beta Testing and TypeScript diff --git a/src/animations/Animation.js b/src/animations/Animation.js index c14815c4e..a4a9da202 100644 --- a/src/animations/Animation.js +++ b/src/animations/Animation.js @@ -362,7 +362,7 @@ var Animation = new Class({ // When is the first update due? state.accumulator = 0; - state.nextTick = state.msPerFrame + state.currentFrame.duration; + state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame; }, /** @@ -515,7 +515,7 @@ var Animation = new Class({ { state.accumulator -= state.nextTick; - state.nextTick = state.msPerFrame + state.currentFrame.duration; + state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame; }, /** diff --git a/src/animations/AnimationFrame.js b/src/animations/AnimationFrame.js index 93f9788c6..0269ebc4f 100644 --- a/src/animations/AnimationFrame.js +++ b/src/animations/AnimationFrame.js @@ -115,8 +115,7 @@ var AnimationFrame = new Class({ this.nextFrame = null; /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. + * The duration, in ms, of this frame of the animation. * * @name Phaser.Animations.AnimationFrame#duration * @type {number} diff --git a/src/animations/AnimationManager.js b/src/animations/AnimationManager.js index e6392582a..fa50b1a81 100644 --- a/src/animations/AnimationManager.js +++ b/src/animations/AnimationManager.js @@ -451,14 +451,6 @@ var AnimationManager = new Class({ } } - // Fix duration to play nice with how the next tick is calculated. - var msPerFrame = totalDuration / animFrames.length; - - animFrames.forEach(function (entry) - { - entry.duration -= msPerFrame; - }); - if (direction === 'reverse') { animFrames = animFrames.reverse(); From 002fa6300ad732e75c12ce8ae2962d4dced3044a Mon Sep 17 00:00:00 2001 From: samme Date: Mon, 29 Jan 2024 09:17:41 -0800 Subject: [PATCH 6/7] Improve the warnings in addTilesetImage() --- src/tilemaps/Tilemap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index 1b796e5b0..b70944716 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -400,7 +400,7 @@ var Tilemap = new Class({ if (!this.scene.sys.textures.exists(key)) { - console.warn('Invalid Tileset Image: ' + key); + console.warn('Texture key "%s" not found', key); return null; } @@ -410,7 +410,7 @@ var Tilemap = new Class({ if (index === null && this.format === Formats.TILED_JSON) { - console.warn('No data found for Tileset: ' + tilesetName); + console.warn('Tilemap has no tileset "%s". Its tilesets are %o', tilesetName, this.tilesets); return null; } From be5223936a70897a5cb80af01f7f117557f79096 Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Mon, 29 Jan 2024 23:33:19 -0500 Subject: [PATCH 7/7] Update CHANGELOG-v3.80.md --- changelog/3.80/CHANGELOG-v3.80.md | 3 ++- src/gameobjects/nineslice/NineSlice.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog/3.80/CHANGELOG-v3.80.md b/changelog/3.80/CHANGELOG-v3.80.md index 18f0493f5..b9207e673 100644 --- a/changelog/3.80/CHANGELOG-v3.80.md +++ b/changelog/3.80/CHANGELOG-v3.80.md @@ -17,6 +17,7 @@ * `Factory.staticBody` had the wrong return type in the docs/TS defs. Fix #6693 (thanks @ddhaiby) * The `Time.Timeline` class didn't show as extending the Event Emitter, or have `config` as an optional argument in the docs / TS defs. Fix #6673 (thanks @ghclark2) * `Animations.AnimationFrame#duration` is now the complete duration of the frame. Before this included `Animations.AnimationState#msPerFrame` with the value of `Animations.AnimationFrame#duration`. The fix to remove `Animations.AnimationState#msPerFrame` from `Animations.AnimationFrame#duration` has been removed from `Animations.AnimationManager#createFromAseprite` because of this clarification. Fix #6712 (thanks @Nerodon @TomMalitz) +* The `NineSlice` Game Object method `setSize` now recalculates its origin by calling the `updateDisplayOrigin` method. (thanks @dhashvir) ## Examples, Documentation, Beta Testing and TypeScript @@ -25,4 +26,4 @@ My thanks to the following for helping with the Phaser 3 Examples, Beta Testing, @AlvaroEstradaDev @stevenwithaph @paxperscientiam - +@samme diff --git a/src/gameobjects/nineslice/NineSlice.js b/src/gameobjects/nineslice/NineSlice.js index 628ff2d6f..b33469c93 100644 --- a/src/gameobjects/nineslice/NineSlice.js +++ b/src/gameobjects/nineslice/NineSlice.js @@ -839,7 +839,9 @@ var NineSlice = new Class({ { this.width = width; this.height = height; + this.updateDisplayOrigin(); + var input = this.input; if (input && !input.customHitArea)