spawner.gd 534 B

12345678910111213141516171819202122232425
  1. extends Node
  2. var enemy = preload('res://Enemy.tscn')
  3. export var wave_num = 10
  4. func _ready():
  5. yield(get_tree().create_timer(1.0),"timeout")
  6. while true:
  7. for x in wave_num:
  8. var instance = enemy.instance()
  9. var rot = rand_range(-PI,PI)
  10. instance.global_position = Vector2(sin(rot), cos(rot)) * 640
  11. add_child(instance)
  12. yield(get_tree().create_timer(10.0),"timeout")
  13. var counter = 0
  14. var score = {}
  15. func death_count(id):
  16. if score.has(id):
  17. score[id] += 1
  18. else:
  19. score[id] = 1
  20. get_parent().kill_update(score[id],id)