Counting Game 6: Add Touch Event

This is where things start to get interesting! We’re going to give instructions to the game to take action when a carrot is clicked or tapped.

To do this, go to the Event Sheet.

Click on ‘Add Event’ and click on the ‘Touch’ Icon:

Then select ‘On Tap Object’. This is saying to the system that when an object is clicked or tapped, we want it to take action.

We need to tell the system which object we want it to react to when clicked or tapped. Therefore select ‘Carrot’ from the panel.

Set the Action

We now need to tell the system what we want it to do after the carrot has been tapped or clicked. Select ‘Add action’ and choose the carrot object:

To see how it works, we’ll change the angle of the carrot when it is clicked. Therefore choose ‘Set angle’ from the options:

and set the angle to 25.

Now, when you preview the project and click on a carrot, the carrot you just clicked should rotate.

You will see that whichever carrot you click will change its angle. However, at the moment you can click on carrots in any order and the action will happen.

Because this is a counting game, we want the carrot action only to happen when the carrots are clicked in the correct sequence.

Therefore we want this to be more targeted, as we want the player to only be able to click the numbers in order.

Making Carrots Clickable Sequentially

The purpose of this game is to encourage children to practice counting from 1 – 10. We want them to click on the carrots sequentially and listen to the sound of the number they have just clicked.

At the moment, the game is taking action after any carrot is clicked. We want it to take action only when the next sequential carrot is clicked.

To do this we are going to add a ‘Global Variable’ to the game. A variable holds key information within the game and in this instance we are going to ask it to count as each carrot is clicked. We can therefore use this to tell the game to only take action when the correct carrot is clicked. For more information about Global Variables in Construct 3, see our glossary HERE.

Add a Global Variable

To add a global variable, right click on the page and select ‘Add global variable’

Call the variable g_count

Tip: While you can call the variable anything you like, I try to keep consistent and I name all global variables with a g_ to help me recognize what’s what in larger games.

We can now instruct the system to use the global variable g_count to check whether the carrot clicked is the next in the sequence.

Add a Second Condition

We are now going to add a second condition so that the action only happens when the correct carrot is clicked, not when any carrot is clicked. Therefore we need to add a second condition by right clicking in the ‘Touch’ condition and select ‘Add another condition’

We are going to compare the animation frame to the global variable g_count. Remember how the animation frames start at 0 and g_count starts at 0? If we add a condition now we will be telling the system to take an action ONLY when a carrot is clicked AND the animation frame is equal to g_count.

Therefore we do this by selecting Carrot and then comparing the frame.

We need to tell the system to compare the frame against g_count:

The last thing we need to do is to add 1 to g_count each time the correct carrot is clicked. 

Click on ‘Add action’ and select the System object and ‘Add to’:

Check that it is adding 1 to g_count.


This is telling the system that each time the correct carrot is clicked, 1 is added to g_count ensuring that actions are only taken when the next sequential carrot is clicked.

The finished event should look like this: