Tracking down the spawning of extra enemies; removed extraneous enemy
counting and queue_free of enemies.
This commit is contained in:
parent
be3919acd7
commit
25a4897697
4 changed files with 15 additions and 12 deletions
13
main.gd
13
main.gd
|
|
@ -17,7 +17,6 @@ func _ready():
|
|||
|
||||
|
||||
func spawn_enemies():
|
||||
get_tree().call_group("enemies", "queue_free")
|
||||
for x in range(9):
|
||||
for y in range(3):
|
||||
var e = enemy.instantiate()
|
||||
|
|
@ -39,7 +38,7 @@ func _on_enemy_died(value: int):
|
|||
|
||||
func _on_player_died():
|
||||
# get_tree().call_group("enemies", "queue_free")
|
||||
EventBus.enemy_win.emit()
|
||||
enemy_win()
|
||||
# $Player.set_process(false)
|
||||
# get_tree().call_group("enemies", "set_process", false)
|
||||
instance.queue_free()
|
||||
|
|
@ -51,16 +50,18 @@ func _on_player_died():
|
|||
|
||||
func new_game():
|
||||
# Ensure enemies are cleared.
|
||||
enemy_count = 0
|
||||
get_tree().call_group("enemies", "queue_free")
|
||||
get_tree().call_group("enemy_bullets", "queue_free")
|
||||
print("Number of enemies at new_game: ",enemy_count)
|
||||
# print("Number of enemies at new_game: ",enemy_count)
|
||||
await get_tree().process_frame
|
||||
|
||||
# Reset score.
|
||||
Global.score = 0
|
||||
$CanvasLayer/UI.update_score(Global.score)
|
||||
|
||||
|
||||
# instantiate the Player
|
||||
# await get_tree().create_timer(1).timeout
|
||||
instance = player.instantiate()
|
||||
add_child(instance)
|
||||
$Player.start()
|
||||
|
|
@ -69,6 +70,7 @@ func new_game():
|
|||
EventBus.initialize_shieldbar.emit()
|
||||
|
||||
# Tell the enemies to spawn!
|
||||
#await get_tree().create_timer(.5).timeout
|
||||
spawn_enemies()
|
||||
|
||||
# Tell the game we're playing.
|
||||
|
|
@ -93,3 +95,6 @@ func win_game():
|
|||
await get_tree().create_timer(2).timeout
|
||||
game_over.hide()
|
||||
start_button.show()
|
||||
|
||||
func enemy_win() -> void:
|
||||
print("Enemy win!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue