-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hand.gd
74 lines (57 loc) · 1.7 KB
/
Hand.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
extends AnimatedSprite
#Base Impact pos: -56 -39
#Catch Impact pos: -76 -30
#Base Woosh pos: -44 -100
#Catch Woosh pos: -59 -99
var thrown = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func catchCoin():
animation = "startCatch"
yield(get_tree().create_timer(0.1), "timeout")
animation = "catch"
func _on_Game_catch(success):
if success:
thrown = false
animation = "startCatch"
drawTrail()
yield(get_tree().create_timer(0.1), "timeout")
if not thrown:
animation = "catch"
else:
animation = "failCatch"
$Animations.playback_speed = 16
$Animations.play("Fail")
func drawTrail():
$Woosh.position = Vector2(-59,-99)
$Woosh.visible = true
$Impact.position = Vector2(-76,-30)
$Impact.visible = true
yield(get_tree().create_timer(0.05), "timeout")
$Impact.visible = false
$Woosh.visible = false
func _on_Game_throw(_step):
thrown = true
$Woosh.position = Vector2(-44,-100)
$Woosh.visible = true
$Impact.position = Vector2(-56,-39)
$Impact.visible = true
yield(get_tree().create_timer(0.05), "timeout")
$Impact.visible = false
$Woosh.visible = false
func _on_Game_catch_fail():
drawTrail()
yield(get_tree().create_timer(1), "timeout")
animation = "search"
$Animations.playback_speed = 1
$Animations.play("Search")
yield(get_tree().create_timer(0.5), "timeout")
get_node("../Coin").stream = load("res://resources/sounds/grab.wav")
get_node("../Coin").play()
animation = "idle"
yield(get_tree().create_timer(0.5), "timeout")
get_node("../Coin").stream = load("res://resources/sounds/flick.tres")