From de5cca1120d1d878bbbdc4cb348722ff7052815e Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 5 Oct 2024 13:32:58 -0400 Subject: [PATCH] Add some cutom logic to determine if this.active is needed. --- source/funkin/graphics/FunkinSprite.hx | 12 ++++++++++++ source/funkin/play/notes/StrumlineNote.hx | 12 +++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/source/funkin/graphics/FunkinSprite.hx b/source/funkin/graphics/FunkinSprite.hx index 521553527..922310309 100644 --- a/source/funkin/graphics/FunkinSprite.hx +++ b/source/funkin/graphics/FunkinSprite.hx @@ -238,6 +238,18 @@ class FunkinSprite extends FlxSprite return true; } + /** + * @param id The animation ID to check. + * @return Whether the animation is dynamic (has multiple frames). `false` for static, one-frame animations. + */ + public function isAnimationDynamic(id:String):Bool + { + if (this.animation == null) return false; + var animData = this.animation.getByName(id); + if (animData == null) return false; + return animData.numFrames > 1; + } + /** * Acts similarly to `makeGraphic`, but with improved memory usage, * at the expense of not being able to paint onto the resulting sprite. diff --git a/source/funkin/play/notes/StrumlineNote.hx b/source/funkin/play/notes/StrumlineNote.hx index f139d421f..fedd71ae8 100644 --- a/source/funkin/play/notes/StrumlineNote.hx +++ b/source/funkin/play/notes/StrumlineNote.hx @@ -24,6 +24,12 @@ class StrumlineNote extends FlxSprite return this.direction; } + /** + * Set this flag to `true` to disable performance optimizations that cause + * the Strumline note sprite to ignore `velocity` and `acceleration`. + */ + public var forceActive:Bool = false; + public function new(noteStyle:NoteStyle, isPlayer:Bool, direction:NoteDirection) { super(0, 0); @@ -103,19 +109,19 @@ class StrumlineNote extends FlxSprite public function playStatic():Void { - this.active = true; + this.active = (forceActive || isAnimationDynamic('static')); this.playAnimation('static', true); } public function playPress():Void { - this.active = true; + this.active = (forceActive || isAnimationDynamic('press')); this.playAnimation('press', true); } public function playConfirm():Void { - this.active = true; + this.active = (forceActive || isAnimationDynamic('confirm')); this.playAnimation('confirm', true); }