-
Notifications
You must be signed in to change notification settings - Fork 1
/
LifesSet.gd
39 lines (32 loc) · 783 Bytes
/
LifesSet.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
extends Node2D
var index = 0
func _ready():
add_all()
func add_all():
index = 0
for b in get_children():
b.modulate = Color.white
b.self_modulate = Color.white
func add_one():
if (index - 1) >= 0:
var b = get_node("Sprite" + str(index))
b.modulate = Color.white
b.self_modulate = Color.white
index -= 1
func lost_life():
if (index + 1) <= get_child_count():
index += 1
var b = get_node("Sprite" + str(index))
b.modulate = Color("3effffff")
b.self_modulate = Color("000000")
if index >= get_child_count():
print("no_lifes!")
GameEvent.emit_signal("no_lifes")
# use for debug
#func _input(event):
# if event.is_action_pressed("fire"):
# lost_life()
# elif event.is_action_pressed("reload_gun"):
# add_one()
#
# print("index:", index)