OmnichordGodot/RhythmController.gd

19 lines
506 B
GDScript

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
self.connect("pressed", self.button_pressed)
func button_pressed():
# Play chord
RhythmPlayer.stream = RhythmAudio
RhythmPlayer.play()