Implement note visuals update method.

This commit is contained in:
2026-02-04 00:03:12 +08:00
parent 6ac9be6c79
commit fa0c53ac3e
4 changed files with 35 additions and 5 deletions

View File

@@ -6,13 +6,36 @@ class_name HoldNote extends NoteVisual
var start_id: int
var end_id: int
var start_beat: float
var end_beat: float
func reset() -> void:
start_id = -1
end_id = -1
start_beat = -999.0
end_beat = -999.0
func in_use() -> bool:
return start_id >= 0 or end_id >= 0
func update(beat: float) -> void:
pass
var start_scroll: float
if start_beat:
start_scroll = _calculate_scroll(start_beat, beat)
else:
start_scroll = 999.0 # Decently up. (TODO Replace with offset_begin).
_set_start_scroll(start_scroll)
var end_scroll: float
if end_beat:
end_scroll = _calculate_scroll(end_beat, beat)
else:
end_scroll = -999.0 # Decently down. (TODO Replace with offset_end).
_set_end_scroll(end_scroll)
# ======== IMPLEMENTATION ======== #
func _set_start_scroll(scroll: float) -> void:
start.y = scroll
func _set_end_scroll(scroll: float) -> void:
end.y = scroll

View File

@@ -2,8 +2,10 @@
[ext_resource type="Script" uid="uid://cbsnb8bdby0d" path="res://rhythm_game/note/visual/hold/hold_note.gd" id="1_5cv34"]
[node name="HoldNote" type="Node2D" unique_id=320259211]
[node name="HoldNote" type="Node2D" unique_id=320259211 node_paths=PackedStringArray("start", "end")]
script = ExtResource("1_5cv34")
start = NodePath("NoteStart")
end = NodePath("NoteEnd")
metadata/_custom_type_script = "uid://cbsnb8bdby0d"
[node name="NoteStart" type="Node2D" parent="." unique_id=1911676927]

View File

@@ -20,3 +20,6 @@ func _notification(what: int) -> void:
_lane = get_parent() as Lane
NOTIFICATION_UNPARENTED:
_lane = null
static func _calculate_scroll(target_beat: float, current_beat: float) -> float:
return Settings.get_note_scroll_speed() * (current_beat - target_beat)

View File

@@ -1,14 +1,16 @@
class_name TapNote extends NoteVisual
var hit_beat: float = -999.0
var id: int = -1
#TODO: Add all the members needed so a note can be updated.
func reset() -> void:
id = -1
hit_beat = -999.0
position = Vector2(0, 9999.0)
func in_use() -> bool:
return id >= 0
func update(beat: float) -> void:
pass
position.y = _calculate_scroll(hit_beat, beat)