-
Notifications
You must be signed in to change notification settings - Fork 0
/
StaticBody2D2.gd
50 lines (35 loc) · 1.21 KB
/
StaticBody2D2.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
extends StaticBody2D
const stone_path = preload('res://Stone.tscn')
var left_stone_array = []
var right_stone_array = []
func _ready():
pass
func _process(delta):
if Input.is_action_just_pressed("Add_Left_Stone"):
drop_left()
if Input.is_action_just_pressed("Add_Right_Stone"):
drop_right()
if Input.is_action_just_pressed("Remove_Left_Stone"):
remove_left()
if Input.is_action_just_pressed("Remove_Right_Stone"):
remove_right()
func drop_left():
var stone_left = stone_path.instance()
get_parent().add_child(stone_left)
stone_left.position = $Left_Stone_Spawner.global_position
left_stone_array.append(stone_left)
func remove_left():
get_parent().remove_child(left_stone_array.back())
left_stone_array.remove(left_stone_array.size()-1)
#get_child(ston).remove_child()
func drop_right():
var stone_right = stone_path.instance()
get_parent().add_child(stone_right)
stone_right.position = $Right_Stone_Spawner.global_position
right_stone_array.append(stone_right)
func remove_right():
get_parent().remove_child(right_stone_array.back())
right_stone_array.remove(right_stone_array.size()-1)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass