25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_coins.gd 470 B

123456789101112131415161718192021
  1. extends Node
  2. export var coin_scene : PackedScene
  3. export var all_coins_picked_up_script : Resource
  4. var coins := -1
  5. func spawn():
  6. if coins < 0: # not spawned yet
  7. coins = 0
  8. for spawn in get_children():
  9. var coin = coin_scene.instance()
  10. coin.connect("picked_up", self, "on_coin_picked_up")
  11. coins += 1
  12. spawn.add_child(coin)
  13. func on_coin_picked_up():
  14. coins -= 1
  15. if coins == 0:
  16. EventDispatcher.emit_signal("trigger_script", all_coins_picked_up_script)