start_menu.gd 2.0 KB

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