Fix an issue where sustain sprites were not killed when the song was reset.

This commit is contained in:
EliteMasterEric 2023-07-25 21:39:19 -04:00
parent 56f1b6896a
commit 6af5259a10
3 changed files with 50 additions and 0 deletions

View file

@ -639,6 +639,9 @@ class PlayState extends MusicBeatState
currentStage.resetStage(); currentStage.resetStage();
playerStrumline.clean();
opponentStrumline.clean();
// Delete all notes and reset the arrays. // Delete all notes and reset the arrays.
regenNoteData(); regenNoteData();

View file

@ -396,6 +396,38 @@ class Strumline extends FlxSpriteGroup
return heldKeys[dir]; return heldKeys[dir];
} }
/**
* Called when the song is reset.
* Removes any special animations and the like.
* Doesn't reset the notes from the chart, that's handled by the PlayState.
*/
public function clean():Void
{
for (note in notes.members)
{
if (note == null) continue;
killNote(note);
}
for (holdNote in holdNotes.members)
{
if (holdNote == null) continue;
holdNote.kill();
}
for (splash in noteSplashes)
{
if (splash == null) continue;
splash.kill();
}
for (cover in noteHoldCovers)
{
if (cover == null) continue;
cover.kill();
}
}
public function applyNoteData(data:Array<SongNoteData>):Void public function applyNoteData(data:Array<SongNoteData>):Void
{ {
this.notes.clear(); this.notes.clear();
@ -423,6 +455,7 @@ class Strumline extends FlxSpriteGroup
public function killNote(note:NoteSprite):Void public function killNote(note:NoteSprite):Void
{ {
if (note == null) return;
note.visible = false; note.visible = false;
notes.remove(note, false); notes.remove(note, false);
note.kill(); note.kill();

View file

@ -282,6 +282,20 @@ class SustainTrail extends FlxSprite
missedNote = false; missedNote = false;
} }
public override function revive():Void
{
super.revive();
strumTime = 0;
noteDirection = 0;
sustainLength = 0;
fullSustainLength = 0;
noteData = null;
hitNote = false;
missedNote = false;
}
override public function destroy():Void override public function destroy():Void
{ {
vertices = null; vertices = null;