Browse Source

[2D Game Tutorial] Fixing the last codeblock to run on 4.0

The last code which would make the tutorial incompatible for 4.0 was this. I ran it locally on my 2D project to ensure it works.
Basically to replace the yield one-shot timer, I used this https://docs.godotengine.org/en/latest/classes/class_scenetreetimer.html

Fixes https://github.com/godotengine/godot-docs/issues/6234

@Calinou Related to this: If I do an upgrade/polish of the 2D tutorial [like I did with 3.0](https://github.com/godotengine/godot-docs/pull/6243) where I upload more **.webp** images and clarify and ref hyperlink here and there, would it be accepted soon, or delayed until after .webp support? Asking because it will take a day or two (I already have the images which is the hard part), and if that upgrade is merged in 4+ months, I would rather schedule my priorities in another way
TheYellowArchitect 2 years ago
parent
commit
be79373bfd
1 changed files with 2 additions and 2 deletions
  1. 2 2
      getting_started/first_2d_game/06.heads_up_display.rst

+ 2 - 2
getting_started/first_2d_game/06.heads_up_display.rst

@@ -211,12 +211,12 @@ We also need to process what happens when the player loses. The code below will
     func show_game_over():
     func show_game_over():
         show_message("Game Over")
         show_message("Game Over")
         # Wait until the MessageTimer has counted down.
         # Wait until the MessageTimer has counted down.
-        await($MessageTimer, "timeout")
+        await $MessageTimer.timeout
 
 
         $Message.text = "Dodge the\nCreeps!"
         $Message.text = "Dodge the\nCreeps!"
         $Message.show()
         $Message.show()
         # Make a one-shot timer and wait for it to finish.
         # Make a one-shot timer and wait for it to finish.
-        yield(get_tree().create_timer(1), "timeout")
+        await get_tree().create_timer(1.0).timeout
         $StartButton.show()
         $StartButton.show()
 
 
  .. code-tab:: csharp
  .. code-tab:: csharp