-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarget_script.gd
More file actions
67 lines (43 loc) · 1.33 KB
/
target_script.gd
File metadata and controls
67 lines (43 loc) · 1.33 KB
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
extends Node2D
onready var crossair = get_node("Sprite")
onready var pos_arrow_top = get_parent().get_node("Positions/Node/Position2D3")
onready var arrow = preload("res://players/archer/Arrow.tscn")
var click = false
var touch_pos
func _input(event):
if event is InputEventScreenTouch:
touch_pos = get_canvas_transform().affine_inverse().xform(event.position)
if event is InputEventScreenDrag:
touch_pos = get_canvas_transform().affine_inverse().xform(event.position)
func _physics_process(delta):
if Nav.pressed:
click = true
crossair.visible
if Project.shoot == true:
var new_instance = arrow.instance()
self.add_child(new_instance)
new_instance.position = pos_arrow_top.position
Project.shoot = false
if click == true:
crossair.global_position = touch_pos
crossair.visible = true
func _on_Top_button_pressed():
click = true
func _on_Top_button_released():
click = false
crossair.visible = false
if touch_pos.x < 0:
print("further than the gate")
Project.aiming_pos_1 = Vector2(80, 3)
else:
Project.aiming_pos_1 = touch_pos
func move_units_down():
crossair.global_position == touch_pos
click = true
crossair.visible = true
func move_units_up():
click = false
crossair.visible = false
if touch_pos.x < 0 and WorldPOS.gate == true:
touch_pos = Vector2(20, 3)
Nav.move_to(touch_pos)