Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this add on, you'll code a sprite
to glide on stage using a broadcast block.
First, choose the object you want to use.
Click on the object sprite.
Click the costumes tab and choose a costume you want to use.
To start, program the object sprite to glide on the stage.
In this example, the sprite appears on the left side
of the stage and glides toward the android sprite.
Select the object sprite
and drag it to the left of the stage.
Then, click the motion menu and drag out a go to XY block.
This block sets the sprite's X and Y position,
making it appear at that spot when the block is run.
This should happen at the start of the program.
So click on the events menu and
add a when flag clicked event.
Next, drag the object sprite to where you want it to go.
Notice that the X and Y positions
of the object sprite changed.
The values in the glide block also updated
to the sprite's current position.
Drag out a glide block.
To test, click the go to XY block.
The object starts at the left side of the stage.
Then, click on the glide block.
The sprite glides to the next position.
Now, send a message to start the glide
action by broadcasting a message.
The broadcast block sends a message
and the when I receive block receives it.
Broadcast blocks allow you to make code run
whenever you like in your program.
In this example, the object will
glide when the android mentions it.
Select the android, go to the events menu,
and add a broadcast block above
the say block that mentions the object.
Click the drop-down menu and select new message.
Name the message something that
describes what the code will do.
This example uses object appears.
Next, click the object sprite.
From events, add a when I receive block
above the glide block.
Test this by clicking the flag.
When the broadcast block runs,
it tells the glide block to run.
Finally, if the object should hide
at the beginning of the program,
then show when the message is received.
From looks, drag a hide block under
the when flag clicked block.
Then, add a show block under the when I receive event.
Click the flag to test.
Now it's your turn.
Make the object glide on the stage
using the go to XY and glide blocks.
Make your code run using broadcast
and when I receive blocks.
Finally, make your object appear using show and hide blocks.