fixed looping bugs!!

This commit is contained in:
Yoshman29
2022-11-06 13:52:40 +01:00
parent 576590a0c9
commit fb35dbf7c0
3 changed files with 36 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
1190
1194
+35
View File
@@ -8,6 +8,7 @@ import flixel.group.FlxGroup.FlxTypedGroup;
class NoteGroup extends FlxTypedGroup<Note> {
var __loopSprite:Note;
var i:Int = 0;
var __currentlyLooping:Bool = false;
public function addNotes(notes:Array<Note>) {
for(e in notes) add(e);
@@ -39,6 +40,8 @@ class NoteGroup extends FlxTypedGroup<Note> {
i = 0;
__loopSprite = null;
var oldCur = __currentlyLooping;
__currentlyLooping = true;
while(i < length) {
__loopSprite = members[i];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) continue;
@@ -46,6 +49,7 @@ class NoteGroup extends FlxTypedGroup<Note> {
__loopSprite.draw();
i++;
}
__currentlyLooping = oldCur;
@:privateAccess FlxCamera._defaultCameras = oldDefaultCameras;
}
@@ -53,6 +57,9 @@ class NoteGroup extends FlxTypedGroup<Note> {
public override function forEach(noteFunc:Note->Void, recursive:Bool = false) {
i = 0;
__loopSprite = null;
var oldCur = __currentlyLooping;
__currentlyLooping = true;
while(i < length) {
__loopSprite = members[i];
@@ -61,6 +68,7 @@ class NoteGroup extends FlxTypedGroup<Note> {
noteFunc(__loopSprite);
i++;
}
__currentlyLooping = oldCur;
}
public override function forEachAlive(noteFunc:Note->Void, recursive:Bool = false) {
forEach(function(note) {
@@ -68,4 +76,31 @@ class NoteGroup extends FlxTypedGroup<Note> {
}, recursive);
}
public override function remove(Object:Note, Splice:Bool = false):Note
{
if (members == null)
return null;
var index:Int = members.indexOf(Object);
if (index < 0)
return null;
// doesnt prevent looping from breaking
if (Splice && __currentlyLooping && i >= index)
i--;
if (Splice)
{
members.splice(index, 1);
length--;
}
else
members[index] = null;
if (_memberRemoved != null)
_memberRemoved.dispatch(Object);
return Object;
}
}
-1
View File
@@ -952,7 +952,6 @@ class PlayState extends MusicBeatState
if (generatedMusic)
{
var toDelete:Array<Note> = [];
notes.forEachAlive(function(daNote:Note)
{
var strum:Strum = null;