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

switch.gd 387 B

1234567891011121314151617181920212223
  1. extends KinematicBody
  2. signal switch
  3. export var initial_state := false
  4. var activated := false
  5. func _ready():
  6. activated = initial_state
  7. update_view()
  8. emit_signal("switch", activated)
  9. func on_interact():
  10. activated = !activated
  11. update_view()
  12. emit_signal("switch", activated)
  13. func update_view():
  14. if activated:
  15. $AnimationPlayer.play("On")
  16. else:
  17. $AnimationPlayer.play("Off")