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 Area2D to Coin

Rename Sprite2D to Sprite

Add a Collision2D Node as a child of Coin

Give it a Circle Shape

Fit the shape around the coin

COIN SCRIPT

Select the Coin (Area2D) and add a new script.

The script will already have the default _ready and _process functions:

Delete them:


SIGNALS

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 

To set this up:

make sure the Coin (Area2D) node is selected 

move to the Node window in the Editor.

Click on Signals

Select body_entered Signal

Click on CONNECT


Click on Connect again.

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.

Test the game

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

From the FileSystem

Test again and watch the Player grow for each coin they collect!