Removed Player from the Main scene in favor of instantiatiating Player
during the start of a new game.
This commit is contained in:
parent
a20e496c2e
commit
a007b08b83
3 changed files with 9 additions and 10 deletions
11
main.gd
11
main.gd
|
|
@ -1,6 +1,8 @@
|
|||
extends Node2D
|
||||
|
||||
var enemy = preload("res://enemy.tscn")
|
||||
var player = preload("res://player.tscn")
|
||||
var instance = null
|
||||
var playing = false
|
||||
var enemy_count: int = 0
|
||||
|
||||
|
|
@ -14,8 +16,6 @@ func _ready():
|
|||
EventBus.enemy_died.connect(_on_enemy_died)
|
||||
|
||||
|
||||
# spawn_enemies()
|
||||
|
||||
func spawn_enemies():
|
||||
|
||||
for x in range(9):
|
||||
|
|
@ -41,7 +41,7 @@ func _on_player_died():
|
|||
# get_tree().call_group("enemies", "queue_free")
|
||||
EventBus.enemy_win.emit()
|
||||
# $Player.set_process(false)
|
||||
# $Player.monitoring = false
|
||||
instance.queue_free()
|
||||
game_over.show()
|
||||
await get_tree().create_timer(2).timeout
|
||||
game_over.hide()
|
||||
|
|
@ -50,8 +50,11 @@ func _on_player_died():
|
|||
|
||||
func new_game():
|
||||
get_tree().call_group("enemies", "queue_free")
|
||||
# get_node("player").start()
|
||||
Global.score = 0
|
||||
# EventBus.initialize_shieldbar.emit()
|
||||
instance = player.instantiate()
|
||||
add_child(instance)
|
||||
$Player.shader_active = false
|
||||
$Player.start()
|
||||
$CanvasLayer/UI.update_score(Global.score)
|
||||
spawn_enemies()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue