Clicking to spawn things
This commit is contained in:
parent
0f5640d789
commit
0716fd62e8
2 changed files with 15 additions and 0 deletions
8
entities/TestDrone.tscn
Normal file
8
entities/TestDrone.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_scene format=3 uid="uid://53jwsbj0hghr"]
|
||||||
|
|
||||||
|
[node name="TestDrone" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Polygon2D" type="Polygon2D" parent="."]
|
||||||
|
position = Vector2(1, -1)
|
||||||
|
color = Color(1, 0.266667, 1, 1)
|
||||||
|
polygon = PackedVector2Array(-28, -25, 25, -28, 26, 33, -32, 19)
|
||||||
|
|
@ -4,7 +4,9 @@ var spawning_drone : bool = false
|
||||||
var spawning_type : String = ""
|
var spawning_type : String = ""
|
||||||
|
|
||||||
@onready var drone_controls = %DroneControls
|
@onready var drone_controls = %DroneControls
|
||||||
|
@onready var spawned_drones_container = get_node("SpawnedDrones")
|
||||||
@onready var cursor = preload("res://resources/cursors/launch_drone.png")
|
@onready var cursor = preload("res://resources/cursors/launch_drone.png")
|
||||||
|
@onready var test_drone = preload("res://entities/TestDrone.tscn")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Log.pr("Drone Manager Ready...")
|
Log.pr("Drone Manager Ready...")
|
||||||
|
|
@ -21,6 +23,9 @@ func _input(event) -> void:
|
||||||
|
|
||||||
func spawn_drone(drone_type : String) -> void:
|
func spawn_drone(drone_type : String) -> void:
|
||||||
Log.pr("This function will put a " + drone_type + " drone in the world")
|
Log.pr("This function will put a " + drone_type + " drone in the world")
|
||||||
|
var new_drone = test_drone.instantiate()
|
||||||
|
spawned_drones_container.add_child(new_drone)
|
||||||
|
new_drone.position = get_viewport().get_mouse_position()
|
||||||
|
|
||||||
func place_drone(drone_type : String) -> void:
|
func place_drone(drone_type : String) -> void:
|
||||||
if !spawning_drone:
|
if !spawning_drone:
|
||||||
|
|
@ -30,6 +35,8 @@ func place_drone(drone_type : String) -> void:
|
||||||
spawning_drone = true
|
spawning_drone = true
|
||||||
spawning_type = drone_type
|
spawning_type = drone_type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func cancel_spawning() -> void:
|
func cancel_spawning() -> void:
|
||||||
Input.set_custom_mouse_cursor(null)
|
Input.set_custom_mouse_cursor(null)
|
||||||
drone_controls.reset_button_focus()
|
drone_controls.reset_button_focus()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue