-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.gd
49 lines (30 loc) · 1.05 KB
/
example.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# To run this example:
#
# Create a new scene with a Node named Example at its root.
# Add a Music AudioStreamPlayer child named Music.
# Set its Stream property to an MP3 you have handy.
# Add a RhythmNotifier child.
# Set its Audio Stream Player property to $Music.
# Set its BPM property to the beats per minute of your MP3 (take a guess).
# Attach this script to $Example.
# Run the scene and watch the Output window.
extends Node
func _ready():
# Print every 4 beats
$RhythmNotifier.beats(4).connect(func(count):
print("TAMBOURINE NOISE NUMBER %d !" % count)
)
# On beat 12.25, seek to beat 2
$RhythmNotifier.beats(12.25, false).connect(func(_count):
$Music.seek($RhythmNotifier.beat_length * 2.0)
)
$Music.play()
func __ready():
DebugConsole.add_command_setvar("testbool", set_bool, self, DebugCommand.ParameterType.Bool,
"should work with on/off as well as true/false", get_bool)
pass # Replace with function body.
func set_bool(val: bool):
_bool_value = val
func get_bool():
return _bool_value
var _bool_value: bool