gdquest-demos / godot-3-beginner-2d-platformer

Learn to create a 2d platform game with the Godot game engine. This is a beginner programming tutorial.
MIT License
364 stars 96 forks source link

Bug if back main menu and click button play #42

Open rifkytecoder opened 2 years ago

rifkytecoder commented 2 years ago

func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed("pause") and pause_title.text != DIED_MESSAGE: self.paused = not paused scene_tree.set_input_as_handled()

mavjs commented 2 years ago

Finished this tutorial a few days back, and ran into a similar issue. I noticed that someone commented on the YouTube video on how to fix it and it worked for me, so I'll reference it here as well, in case, someone comes here first to look for answers.

Commented by Краси Кирчев on YouTube

I had some issues with dying and the game being paused after that.

The dying sets self.paused = true. The retry button has code that turns pause off, but if you go to Main Menu, buttons aren't clickable. To fix this, you need to open the MainScreen.tscn (and the EndScreen.tscn) and make them process when paused just like we did for the UserInterface. Issue doesn't stop here - game is still paused, and if you click Play on the MainScreen, you start lvl1 but frozen mid-air. To fix this, you need to add "get_tree().paused = false" or similar to the Play button's on-pressed function, just like we did in the Reply button.