There are MANY possibilities for powerups. To demonstrate we will add a collectible which applies a short time bonus.
It appears occasionally for a short time and then disappears.
The powerup is SO similar in structure to the Coin Scene that we will reuse it.
Cick the Scene menu and choose Save Scene As
Change the name of the root node to Powerup
Detach the script from the root
Add a new group called powerups
Change the Idle Animation of the AnimatedSprite2D node
To the one found in Assets/pow folder
Add a new script to the Powerup node
Copy the pickup function from the coin script
This is how long a powerup is on screen
Connect the timout signal
(Either in code or via Inspector)
So that the timeout can be removed
Rename it to PowerupTimer
Add another AudioStreamPlayer
Rename it to PowerupSound
Add the Powerup.wav to the Stream
Connect the timeout signal of the PowerupTimer
Either in code or via Inspector
Add a variable to store the powerup scene
Ensure you load the Powerup Scene
Complete the powerup timeout function
After a random amount of time
Update the new game function
Update the game over function
Update the on area entered function
To distinguish between two different pickups
To do different things for