Create a new Scene and call it Coin
Add an Area2D node as the root node.
This is a node that can detect collisions when a collider like our Player node walks over it.
Add a Sprite2D node as a child of Area2D
Add the Coin.png file as the Sprite's texture.
Rename Sprite2D to Sprite
Add a Collision2D Node as a child of Coin
Fit the shape around the coin
Select the Coin (Area2D) and add a new script.
The script will already have the default _ready and _process functions:
Signals are events that are triggered when something happens in our game.
We will be using the body_entered signal for our script.
Signals detect when an object has collided with Area2D
make sure the Coin (Area2D) node is selected
move to the Node window in the Editor.
Select body_entered Signal
This will generate an _on_body_entered function in the script,
and automatically connect it to the Area2D signal.
Now we can customise the bahaviour of the function in our script.
Increase the scale of the body that has entered the area.
Destroy the coin so it can’t be picked up a second time.
Add some coins to the Player Scene.
Notice when the player grabs a coin the Player grows
And the coin is destroyed.
We can add more coins to the Player scene
Just by dragging and dropping the Coin Scene file
Test again and watch the Player grow for each coin they collect!