-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstruction.gd
56 lines (40 loc) · 1.09 KB
/
Instruction.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
50
51
52
53
54
55
extends Node2D
onready var Explosion_Fail = preload("res://Explosion_Fail.tscn")
export(float) var MX_BPM
var tween_duration
var movement_target
var letter
var detector
const TYPES = ["A", "S", "D", "F", "H", "J", "K", "L"]
const SPRITES_PATH = "res://Sprites/tile%s.png"
# Called when the node is added to the scene for the first time.
func _ready():
tween_duration = (60*12)/MX_BPM
self.visible = true
# Called after the Node is instantiated by Level/Spawner
func initialize(init_data):
self.visible = false
movement_target = init_data.target
letter = init_data.letter
# Assign the proper texture based on the assigned letter
$Sprite.texture = load(SPRITES_PATH % letter)
func appear():
$Tween.interpolate_property(
self,
"position",
self.position,
movement_target.position,
tween_duration,
Tween.TRANS_LINEAR,
Tween.EASE_IN
)
$Tween.start()
func fail():
var ExpPart = Explosion_Fail.instance()
add_child(ExpPart)
ExpPart.emitting = true
hide_particle()
func hide_particle():
$Particles2D.visible = false
func _on_Tween_tween_completed(object, key):
self.queue_free()