start_menu.gd 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. extends Control
  2. var nodes
  3. # Called when the node enters the scene tree for the first time.
  4. func _ready() -> void:
  5. nodes = [
  6. self.get_node("Easy"),
  7. self.get_node("Normal"),
  8. self.get_node("Hard"),
  9. self.get_node("Lunatic")
  10. ]
  11. (self.get_node("AnimationPlayer") as AnimationPlayer).play("new_animation")
  12. # Called every frame. 'delta' is the elapsed time since the previous frame.
  13. func _process(delta: float) -> void:
  14. if(Input.is_action_just_pressed("ui_accept")):
  15. MusicController.playSE(MusicController.SEs.ok)
  16. if(Input.is_action_just_pressed("ui_cancel")):
  17. get_tree().current_scene.get_node("TitleMenuGroup").get_node("Menu").get_node("Start").submenuopened = false
  18. MusicController.playSE(MusicController.SEs.cancel)
  19. (self.get_node("AnimationPlayer") as AnimationPlayer).play_backwards("new_animation")
  20. await get_tree().create_timer(0.25).timeout
  21. self.queue_free()
  22. (get_tree().get_root().get_node("Mainmenu").get_node("TitleMenuGroup").get_node("AnimationPlayer") as AnimationPlayer).play_backwards("new_animation_2")
  23. if(Input.is_action_just_pressed("ui_up")):
  24. MusicController.playSE(MusicController.SEs.select)
  25. for i in range(0, nodes.size()) :
  26. if((nodes[i] as Sprite2D).get_meta("selected") == true):
  27. (nodes[i] as Sprite2D).set_meta("selected", false)
  28. (nodes[i-1] as Sprite2D).set_meta("selected", true)
  29. break
  30. if(Input.is_action_just_pressed("ui_down")):
  31. MusicController.playSE(MusicController.SEs.select)
  32. for i in nodes.size():
  33. if((nodes[i] as Sprite2D).get_meta("selected") == true):
  34. (nodes[i] as Sprite2D).set_meta("selected", false)
  35. if(i+1 >= nodes.size()):
  36. (nodes[0] as Sprite2D).set_meta("selected", true)
  37. break
  38. else:
  39. (nodes[i+1] as Sprite2D).set_meta("selected", true)
  40. break