5. But what happens if the user has not clicked 10 times yet?
Let’s add the code for the “else” of the if statement. We want that until the user has not clicked the button 10 times, our variable “global times” increases according to the number of times and the label text reflects that increasing number. So, first of all, we have to make our GlobalTimes variable increase by one at every click. Go to Math and add the block for summing numbers. Then, click on Variables and drag the following block inside the first space:
set (select Global times) to
Then go to Math and add the “0” block to the second empty space. Change its value to 1. By adding these blocks, we have just made our variable global times increase by one at every click.
6. Finally we have to set the label text equal to the global times value. Click on Label and select:
set Label1.text to
Now go to Variables and select “get” and Global times.
7. The last thing to do is initialising Screen2. Click on Screen1 at the top and select Screen2. Now click on Screen2 in the left side bar and add the block: