Workshop
Answer the following questions to make sure you understood the content of this hour.
Quiz
What does the One Shot property of a Timer node do?
How can we prevent our pixel art from getting blurry?
What are the steps needed to spawn another scene into a scene by script?
What does queue_free do and when?
How does the “score” Label in the stage scene know when it needs to update its score?
Answers
It lets the Timer stop after a timeout. Without the property, the Timer would restart again.
We need to turn off the filter property in the import dock or use the 2D Pixel preset.
We need to preload the scene, instantiate it with instance, set its position, and then add it as a child to the parent scene using add_child.
The queue_free function deletes a node from memory and therefore removes it from the game. It does this after the node has finished all its processing, including all input and signals that need to be processed.
The “score” Label is updated by the stage script. The stage script connects to the score signal of an asteroid when it gets spawned into the game. As soon as the asteroid is destroyed, it emits its score signal, which causes the stage to increment its internal score variable and write it to the “score” Label.