@@ -73,9 +73,9 @@ class StrumlineNote extends FunkinSprite
7373 {
7474 // Run a timer before we stop playing the confirm animation.
7575 // On player, this allows holding the confirm key to fall back to press.
76- if (isPlayer && name == ' confirm' )
76+ if (isPlayer && name == ' confirm' && ! holding )
7777 {
78- confirmHoldTimer = 0 ;
78+ confirmHoldTimer = CONFIRM_HOLD_TIME ;
7979 }
8080 }
8181
@@ -85,15 +85,16 @@ class StrumlineNote extends FunkinSprite
8585
8686 centerOrigin ();
8787
88- if (confirmHoldTimer >= 0 )
88+ if (confirmHoldTimer > 0 )
8989 {
90- confirmHoldTimer + = elapsed ;
90+ confirmHoldTimer - = elapsed ;
9191
9292 // Ensure the opponent stops holding the key after a certain amount of time.
93- if (confirmHoldTimer >= CONFIRM_HOLD_TIME )
93+ if (confirmHoldTimer <= 0 )
9494 {
9595 confirmHoldTimer = - 1 ;
9696 playStatic ();
97+ holding = false ;
9798 }
9899 }
99100 }
@@ -145,36 +146,43 @@ class StrumlineNote extends FunkinSprite
145146
146147 // On opponent, run a timer to stop playing the confirm animation.
147148 // On player, stop the timer to avoid stopping the confirm animation earlier.
148- confirmHoldTimer = isPlayer ? - 1 : 0 ;
149+ confirmHoldTimer = isPlayer ? - 1 : CONFIRM_HOLD_TIME ;
150+ holding = false ;
149151 }
150152
151153 public function isConfirm (): Bool
152154 {
153155 return getCurrentAnimation ().startsWith (' confirm' );
154156 }
155157
156- public function holdConfirm (): Void
158+ public var holding : Bool = false ;
159+
160+ public function holdConfirm (? length : Float = 0 ): Void
157161 {
158162 this .active = true ;
159163
160- if (getCurrentAnimation () == " confirm-hold" )
161- {
162- return ;
163- }
164- else if (getCurrentAnimation () == " confirm" )
164+ if (holding ) return ;
165+
166+ this .confirmHoldTimer = isPlayer ? - 1 : Math .max (length , CONFIRM_HOLD_TIME );
167+
168+ if ((getCurrentAnimation () == ' confirm' && isAnimationFinished ()) || ! gotCorrectConfirmHoldAnimation ()) holding = true ;
169+
170+ if (holding )
165171 {
166- if (isAnimationFinished ())
172+ if (gotCorrectConfirmHoldAnimation ())
167173 {
168- this .confirmHoldTimer = - 1 ;
169174 this .playAnimation (' confirm-hold' , false , false );
170175 }
171- }
172- else
173- {
174- this .playAnimation (' confirm' , false , false );
176+ else
177+ {
178+ // Commented out, since it will spam this trace in console on every hold note with default notestlyes lol.
179+ // trace('[WARN] Incorrect data for `confirm-hold` animation!');
180+ }
175181 }
176182 }
177183
184+ private inline function gotCorrectConfirmHoldAnimation (): Bool
185+ return animation ?. getByName (" confirm-hold" )?. looped ?? false ;
178186 /**
179187 * Returns the name of the animation that is currently playing.
180188 * If no animation is playing (usually this means the sprite is BROKEN!),
@@ -188,7 +196,7 @@ class StrumlineNote extends FunkinSprite
188196
189197 public function isAnimationFinished (): Bool
190198 {
191- return this .animation .finished ;
199+ return this .animation ? .finished ?? true ;
192200 }
193201
194202 static final DEFAULT_OFFSET : Int = 13 ;
0 commit comments