Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
Social media sites have ways to "like" or "love" different things, whether it’s a
post, a picture, or a status.
On Google plus, there’s a "plus 1" button.
Whenever it’s clicked, it indicates that you liked something, that it made you laugh,
or that you appreciate it!
In this add-on, you will program a "plus 1" button on your profile page so that users
can express that they liked your page.
In the starter project, there is a "+1 my page" sprite at the bottom of the stage.
First, create a variable.
Click on the "+1" sprite then click on the data menu.
Click the "make a variable" button and name it something that makes sense for the sprite
This example names the variable "+1," which shows up on the top right corner of the stage.
Remember that a variable holds and stores a value.
For this add-on, the project will store how many people click the +1 button and like the
Move the +1 display box over to the "plus my page" sprite, and double click the display
box to make it appear larger on the stage, just like you did in the previous videos.
Next, code the +1 button to increase by one every time the sprite is clicked.
Drag out the "change +1 by 1" block into the scripts editor.
When you click on this block, the variable increases by one.
If you change the value in the block to a larger number, like 10, then every time you
click the block, the variable increases by 10.
This example uses 1 in the value.
Since the variable should increase when the sprite is clicked, add a "when this sprite
clicked" event from the events menu.
Test your code.
When the sprite is clicked, the page increases by 1.
Finally, program the +1 count to start at zero when the flag is clicked.
Click on the data menu, and drag out a "set +1 to zero" block into the scripts editor.
When you click this block, the variable count goes to zero.
To make this code run when the flag is clicked, add a "when flag clicked" block to the top
of the "set +1 to" block.
Test it out!
When the flag is clicked, the variable count resets to zero, then when you click on the
"+1 sprite," the count increases.
Now users can interact with your page and show that they liked it!
Now, it’s your turn: Create a +1 variable for the "+1 sprite."
Code the variable to change by a value when it’s clicked, and reset when the flag is
If you need help, ask a neighbor or put up your sticky note to get the attention of your
CS First Guru.