OmnichordGodot/scripts/RhythmController.gd

20 lines
523 B
GDScript3
Raw Normal View History

2024-06-26 23:09:42 -03:00
extends Node
# Add asset here
var RhythmPlayer: AudioStreamPlayer
var RhythmAudio: AudioStreamOggVorbis
# Called when the node enters the scene tree for the first time.
func _ready():
RhythmPlayer = get_node("/root/Control/RhythmPlayer")
var resource_string = "res://audio/rhythm/%s.ogg" % self.name
var resource = load(resource_string)
RhythmAudio = resource
2024-06-26 23:49:24 -03:00
self.pressed.connect(button_pressed)
2024-06-26 23:09:42 -03:00
func button_pressed():
# Play chord
RhythmPlayer.stream = RhythmAudio
2024-06-26 23:49:24 -03:00
RhythmAudio.loop = true
2024-06-26 23:09:42 -03:00
RhythmPlayer.play()