An incrementer allows you to increase (or decrease) a number in your app.
This is done by getting the current value and changing it by the desired amount. One common place that you might want to do this is in a game. For example, at the beginning of the game we have a variable called score
and our initial score is 0
.
Every time that the users earns a point in the game you want to increase the score by one point. In Thunkable there are a number of different ways you can do this; with the set
block or with the change
block.
1. Set Value
The conventional way to do this is to set score = score + 1
. Put simply, we get the current value of score, add one on to it and update score to be the new value.
Once the score
variable has been updated we display the new value in Button1
2. Change Value
Since incrementing is such a common operation in app development, Thunkable has a dedicated to make this as easy as possible for you. Rather than using 4 blocks, as was the case in the example above, you can just use the following two blocks to increase (or decrease) a variable by any amount that you want.
Remix
To see these blocks and copy them into your own project take a look at the project page below:
https://x.thunkable.com/projectPage/5f7b1e9aa98c0a459bf55a61
Next Steps:
You can use an incrementer to create a progress bar