Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion source/funkin/graphics/FunkinSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ class FunkinSprite extends FlxAnimate
}

/**
* Gets the current animation ID.
* Returns the name of the animation that is currently playing.
* If no animation is playing (usually this means the sprite is BROKEN!),
* returns an empty string to prevent NPEs.
*/
public function getCurrentAnimation():String
{
Expand Down
6 changes: 3 additions & 3 deletions source/funkin/play/notes/Strumline.hx
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ class Strumline extends FlxSpriteGroup
else if (conductorInUse.songPosition > holdNote.strumTime && holdNote.hitNote)
{
// Hold note is currently being hit, clip it off.
holdConfirm(holdNote.noteDirection);
holdConfirm(holdNote.noteDirection, holdNote.fullSustainLength);
holdNote.visible = true;

holdNote.sustainLength = (holdNote.strumTime + holdNote.fullSustainLength) - conductorInUse.songPosition;
Expand Down Expand Up @@ -1049,9 +1049,9 @@ class Strumline extends FlxSpriteGroup
* Play a confirm animation for a hold note.
* @param direction The direction of the note to play the confirm animation for.
*/
public function holdConfirm(direction:NoteDirection):Void
public function holdConfirm(direction:NoteDirection, ?length:Float = 0):Void
{
getByDirection(direction).holdConfirm();
getByDirection(direction).holdConfirm(length / 1000);

if (isPlayer) noteVibrations.noteStatuses[direction] = NoteStatus.holdConfirm;
}
Expand Down
47 changes: 28 additions & 19 deletions source/funkin/play/notes/StrumlineNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class StrumlineNote extends FunkinSprite
*/
static final CONFIRM_HOLD_TIME:Float = 0.15;

static final DEFAULT_OFFSET:Int = 13;

/**
* How long the hold note animation has been playing after a note is pressed.
*/
Expand Down Expand Up @@ -73,9 +75,9 @@ class StrumlineNote extends FunkinSprite
{
// Run a timer before we stop playing the confirm animation.
// On player, this allows holding the confirm key to fall back to press.
if (isPlayer && name == 'confirm')
if (isPlayer && name == 'confirm' && !holding)
{
confirmHoldTimer = 0;
confirmHoldTimer = CONFIRM_HOLD_TIME;
}
}

Expand All @@ -85,15 +87,16 @@ class StrumlineNote extends FunkinSprite

centerOrigin();

if (confirmHoldTimer >= 0)
if (confirmHoldTimer > 0)
{
confirmHoldTimer += elapsed;
confirmHoldTimer -= elapsed;

// Ensure the opponent stops holding the key after a certain amount of time.
if (confirmHoldTimer >= CONFIRM_HOLD_TIME)
if (confirmHoldTimer <= 0)
{
confirmHoldTimer = -1;
playStatic();
holding = false;
}
}
}
Expand Down Expand Up @@ -145,37 +148,43 @@ class StrumlineNote extends FunkinSprite

// On opponent, run a timer to stop playing the confirm animation.
// On player, stop the timer to avoid stopping the confirm animation earlier.
confirmHoldTimer = isPlayer ? -1 : 0;
confirmHoldTimer = isPlayer ? -1 : CONFIRM_HOLD_TIME;
holding = false;
}

public function isConfirm():Bool
{
return getCurrentAnimation().startsWith('confirm');
}

public function holdConfirm():Void
public var holding:Bool = false;

public function holdConfirm(?length:Float = 0):Void
{
this.active = true;

if (getCurrentAnimation() == "confirm-hold")
{
return;
}
else if (getCurrentAnimation() == "confirm")
if (holding) return;

this.confirmHoldTimer = isPlayer ? -1 : Math.max(length, CONFIRM_HOLD_TIME);

if ((getCurrentAnimation() == 'confirm' && isAnimationFinished()) || !gotCorrectConfirmHoldAnimation()) holding = true;

if (holding)
{
if (isAnimationFinished())
if (gotCorrectConfirmHoldAnimation())
{
this.confirmHoldTimer = -1;
this.playAnimation('confirm-hold', false, false);
}
}
else
{
this.playAnimation('confirm', false, false);
else
{
// Commented out, since it will spam this trace in console on every hold note with default notestlyes lol.
// trace('[WARN] Incorrect data for `confirm-hold` animation!');
}
}
}

static final DEFAULT_OFFSET:Int = 13;
private inline function gotCorrectConfirmHoldAnimation():Bool
return animation?.getByName("confirm-hold")?.looped ?? false;

/**
* Adjusts the position of the sprite's graphic relative to the hitbox.
Expand Down