All objects in a game that the player is able to collect are called collectables. In our game, we will add collectable coins scattered in the level's pieces for the player to collect. Before we start working on it, we need to plan what we are going to do, so this is our simple plan:
- Our collectables–let's call them coins from now on–will be collected on contact with the player game object
- We will write the Collectable class to manage coin behavior
- For every coin collected, we will count and increment the number of collected coins on the UI
- The count of total collected coins will restart with a new game