Fix hold notes not always having a cover

This commit is contained in:
VirtuGuy
2026-05-19 17:45:24 -06:00
committed by Hundrec
parent 28cbf3767a
commit f0a5188cb1
+8 -20
View File
@@ -229,7 +229,7 @@ class Strumline extends FlxSpriteGroup
this.notesVwoosh.zIndex = 31;
this.add(this.notesVwoosh);
this.noteHoldCovers = new FlxTypedSpriteGroup<NoteHoldCover>(0, 0, 4);
this.noteHoldCovers = new FlxTypedSpriteGroup<NoteHoldCover>();
this.noteHoldCovers.zIndex = 40;
this.add(this.noteHoldCovers);
@@ -1261,30 +1261,18 @@ class Strumline extends FlxSpriteGroup
*/
function constructNoteHoldCover():NoteHoldCover
{
var result:NoteHoldCover = null;
var result:NoteHoldCover = this.noteHoldCovers.getFirstAvailable();
// If we haven't filled the pool yet...
if (noteHoldCovers.length < noteHoldCovers.maxSize)
if (result != null)
{
// Create a new note hold cover.
result = new NoteHoldCover(noteStyle);
this.noteHoldCovers.add(result);
result.revive();
}
else
{
// Else, find a note splash which is inactive so we can revive it.
result = this.noteHoldCovers.getFirstAvailable();
if (result != null)
{
result.revive();
}
else
{
// The note hold cover pool is full and all note hold covers are active,
// so we just pick one at random to destroy and restart.
result = FlxG.random.getObject(this.noteHoldCovers.members);
}
// The note hold cover pool is full and all note hold covers are active,
// We have to create a new note hold cover.
result = new NoteHoldCover(noteStyle);
this.noteHoldCovers.add(result);
}
return result;