feat: instantiating dragons to ingame position
This commit is contained in:
parent
fc921cc900
commit
610d623653
8 changed files with 64 additions and 19 deletions
|
@ -2,13 +2,14 @@ extends Node
|
|||
|
||||
|
||||
@export var dragon_template: PackedScene
|
||||
@export var dragon_ingame: PackedScene
|
||||
@export var dragon_spots: Array[Node2D]
|
||||
|
||||
var _instantiator: DragonInstantiator
|
||||
|
||||
|
||||
func _ready():
|
||||
_instantiator = DragonInstantiator.new(dragon_template, dragon_spots, get_viewport(), get_window())
|
||||
_instantiator = DragonInstantiator.new(dragon_template, get_viewport(), get_window())
|
||||
|
||||
await get_tree().process_frame
|
||||
move_window_to_bottom_right()
|
||||
|
@ -28,11 +29,23 @@ func move_window_to_bottom_right():
|
|||
DisplayServer.window_set_position(new_position)
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
var dragon: Dragon = _instantiator.instantiate()
|
||||
dragon.place_back.connect(_dragon_place_back)
|
||||
add_child(dragon)
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_pressed() and event.is_action("ui_accept"):
|
||||
_instantiate_dragon_ingame(dragon_spots[0].position)
|
||||
|
||||
|
||||
func _instantiate_dragon_ingame(position: Vector2):
|
||||
var dragon: DragonEntity = dragon_ingame.instantiate()
|
||||
add_child(dragon)
|
||||
dragon.position = position
|
||||
dragon.on_pick.connect(_pick_dragon)
|
||||
|
||||
|
||||
func _pick_dragon(position: Vector2):
|
||||
print(position)
|
||||
var dragon: Dragon = _instantiator.instantiate(position)
|
||||
dragon.place_back.connect(_dragon_place_back)
|
||||
add_child(dragon)
|
||||
|
||||
|
||||
func _dragon_place_back(dragon: Dragon):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue