From dbf6a710a3dc91a91cb7be0a18fc8b0b4c260f7d Mon Sep 17 00:00:00 2001 From: Turtike Date: Wed, 4 Feb 2026 00:05:33 +0800 Subject: [PATCH] Fix note pool. --- rhythm_game/note/visual/note_pool.gd | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rhythm_game/note/visual/note_pool.gd b/rhythm_game/note/visual/note_pool.gd index 4c56410..3df3c52 100644 --- a/rhythm_game/note/visual/note_pool.gd +++ b/rhythm_game/note/visual/note_pool.gd @@ -37,6 +37,7 @@ func get_tap() -> TapNote: if tap == null: tap = _instantiate_tap() _used_taps[tap] = true + tap.reset() return tap ## Return a tap note. @@ -50,6 +51,7 @@ func return_tap(tap: TapNote) -> void: "Returning tap note ", tap, " that was not spawned by pool ", self, "." ) + tap.reset() _free_taps.append(tap) ## Get a hold note. Instantiates one if no free nodes are available. @@ -58,6 +60,7 @@ func get_hold() -> HoldNote: if hold == null: hold = _instantiate_hold() _used_holds[hold] = true + hold.reset() return hold ## Return a hold note. @@ -71,6 +74,7 @@ func return_hold(hold: HoldNote) -> void: "Returning hold note ", hold, " that was not spawned by pool ", self, "." ) + hold.reset() _free_holds.append(hold) ## Spawn the given number of notes. @@ -89,8 +93,11 @@ var _used_taps: Dictionary[TapNote, bool] var _free_holds: Array[HoldNote] var _used_holds: Dictionary[HoldNote, bool] +func _ready() -> void: + reserve(tap_size, hold_size) + func _instantiate_tap() -> TapNote: return NoteScenes.get_tap(tap_skin).instantiate() as TapNote func _instantiate_hold() -> HoldNote: - return NoteScenes.get_tap(tap_skin).instantiate() as HoldNote + return NoteScenes.get_hold(tap_skin).instantiate() as HoldNote