Use Global Variable to Interact with Sprites

 

Programming result

When you rotate Halocode around the y-axis, the sun on stage will rotate as well.

Introduction to Halocode's Axes

The axes of Halocode are as follows:

1.png

 

Create a new variable

1. Click Variables category, and then click "Make a Variable". Name the variable "y".

2.gif

 

2. Add a Variables block set (y) to () and a Sensing block rotation angle around (). Choose "Y" axis.

3.gif

 

Add event and control

3. Add an Events block when button is pressed and a Control block forever.

4.gif

 

Add a sprite

4. Under "Sprites", click "+". Choose "Sun1".

5.gif

 

5. Delete default sprite "Panda".

6.gif

 

Program the sun

6. Add a Motion block turn ↷ () degrees and a Variables block y.

7.gif

 

7. Add an Events block when green flag clicked and a Control block forever.

8.gif

 

8. Rotate Halocode and see what happens.

Download code


Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.