NoteGroup optimize (#881)

* NoteGroup optimize

* CoolUtil.bound faster
This commit is contained in:
HEIHUAa
2026-01-21 07:26:55 +07:00
committed by GitHub
parent 8fc1493759
commit 9d9640071c
2 changed files with 10 additions and 15 deletions
+1 -1
View File
@@ -311,7 +311,7 @@ class Note extends FlxSprite
}
public function updateSustainClip() if (wasGoodHit && !noSustainClip) {
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
var t = CoolUtil.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
var rect = clipRect == null ? FlxRect.get() : clipRect;
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t));
}
+9 -14
View File
@@ -53,14 +53,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
public override function update(elapsed:Float) {
i = length-1;
__loopSprite = null;
__time = __getSongPos();
__time = __getSongPos() + limit;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) {
continue;
}
if (__loopSprite.strumTime - __time > limit)
break;
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) continue;
if (__loopSprite.strumTime > __time) break;
__loopSprite.update(elapsed);
}
}
@@ -74,12 +71,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
i = length-1;
__loopSprite = null;
__time = __getSongPos();
__time = __getSongPos() + limit;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible)
continue;
if (__loopSprite.strumTime - __time > limit) break;
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) continue;
if (__loopSprite.strumTime > __time) break;
__loopSprite.draw();
}
__currentlyLooping = oldCur;
@@ -97,16 +93,15 @@ class NoteGroup extends FlxTypedGroup<Note> {
public override function forEach(noteFunc:Note->Void, recursive:Bool = false) {
i = length-1;
__loopSprite = null;
__time = __getSongPos();
__time = __getSongPos() + limit;
var oldCur = __currentlyLooping;
__currentlyLooping = true;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists)
continue;
if (__loopSprite.strumTime - __time > limit) break;
if (__loopSprite == null || !__loopSprite.exists) continue;
if (__loopSprite.strumTime > __time) break;
noteFunc(__loopSprite);
}
__currentlyLooping = oldCur;