From 2e4b43be4e908dbe8f0d17f4d33eda5d09add884 Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Fri, 26 Jan 2024 13:19:54 -0500 Subject: [PATCH] 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();