From e7634c90e793b37307fadd0d15d7942a3e833ea1 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 30 Mar 2025 23:37:38 -0400 Subject: [PATCH] Fix an animation issue with the cans in 2hot. --- assets | 2 +- .../graphics/adobeanimate/FlxAtlasSprite.hx | 22 ++++++++++++------- source/funkin/ui/freeplay/AlbumRoll.hx | 8 +++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/assets b/assets index c65726712..c44537738 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c657267128eb00a6d2704af847222c9e9ab0351d +Subproject commit c445377389954a65439abfa568549fce153888aa diff --git a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx index dec362378..d3eba3306 100644 --- a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx +++ b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx @@ -61,8 +61,6 @@ class FlxAtlasSprite extends FlxAnimate throw 'FlxAtlasSprite not initialized properly. Are you sure the path (${path}) exists?'; } - onAnimationComplete.add(cleanupAnimation); - // This defaults the sprite to play the first animation in the atlas, // then pauses it. This ensures symbols are intialized properly. this.anim.play(''); @@ -196,6 +194,8 @@ class FlxAtlasSprite extends FlxAnimate goToFrameLabel(id); fr = anim.getFrameLabel(id); anim.curFrame += startFrame; + // Resume animation if it's paused. + anim.resume(); } } @@ -206,13 +206,10 @@ class FlxAtlasSprite extends FlxAnimate /** * Returns true if the animation has finished playing. - * Never true if animation is configured to loop. * @return Whether the animation has finished playing. */ public function isAnimationFinished():Bool { - if (!looping) return false; - return isLoopComplete(); } @@ -226,7 +223,15 @@ class FlxAtlasSprite extends FlxAnimate if (this.anim == null) return false; if (!this.anim.isPlaying) return false; - if (fr != null) return (anim.reversed && anim.curFrame < fr.index || !anim.reversed && anim.curFrame >= (fr.index + fr.duration)); + if (fr != null) + { + var curFrame = anim.curFrame; + + var startFrame = fr.index; + var endFrame = (fr.index + fr.duration); + + return (anim.reversed) ? (curFrame < startFrame) : (curFrame >= endFrame); + } return (anim.reversed && anim.curFrame == 0 || !(anim.reversed) && (anim.curFrame) >= (anim.length - 1)); } @@ -297,17 +302,18 @@ class FlxAtlasSprite extends FlxAnimate if (isLoopComplete()) { anim.pause(); - _onAnimationComplete(); if (looping) { anim.curFrame = (fr != null) ? fr.index : 0; anim.resume(); + // _onAnimationComplete not called since this is a loop. } else if (fr != null && anim.curFrame != anim.length - 1) { anim.curFrame--; - cleanupAnimation(""); + cleanupAnimation(currentAnimation ?? ""); + _onAnimationComplete(); } } } diff --git a/source/funkin/ui/freeplay/AlbumRoll.hx b/source/funkin/ui/freeplay/AlbumRoll.hx index ed797e202..9559bbe23 100644 --- a/source/funkin/ui/freeplay/AlbumRoll.hx +++ b/source/funkin/ui/freeplay/AlbumRoll.hx @@ -75,7 +75,11 @@ class AlbumRoll extends FlxSpriteGroup // Play the idle animation for the current album. if (animName != "idle") { - newAlbumArt.playAnimation('idle', true); + newAlbumArt.playAnimation('idle', true, false, true); + } + else + { + newAlbumArt.cleanupAnimation('idle'); } } @@ -213,7 +217,7 @@ class AlbumRoll extends FlxSpriteGroup albumTitle.animation.addByPrefix('switch', 'switch0', 24, false); add(albumTitle); - albumTitle.animation.finishCallback = (function(name) { + albumTitle.animation.onFinish.add(function(name) { if (name == 'switch') albumTitle.animation.play('idle'); }); albumTitle.animation.play('idle');