Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this add-on, you will program stars to circle around a character's head when an object
falls on it.
To start, add a new sprite that will fall on the main character sprite's head.
This example uses the cheese puffs from the sprite library.
Next, broadcast a message to make this sprite fall.
Add a broadcast block, and name the message something like "fall."
Add “say” blocks in the character sprite to describe your ouch moment.
In this example, this message is broadcast after the character says, "I got you some
Hmm, where are they?"
Select the sprite that will fall.
Program it to hide and start at the top of the stage when the flag is clicked.
Add "when flag clicked" and "hide" blocks.
Drag the sprite to a starting spot on the stage, and add a "go to xy" block to the bottom
of the code stack.
Program the sprite to show and glide down when it receives the “fall” message.
Add a "when I receive" block and a "show" block.
Drag the sprite down to the character's head, and add a "glide" block.
Click the two block stacks to test.
The sprite starts off hidden, then when it receives the “fall” message, it shows
and falls down.
Program the sprite to wait a bit, then fall to the ground.
Add a "wait" block, and adjust the time.
This example uses 0.1 seconds.
Then, drag the sprite to where it will land, and add a "glide" block.
Click the two block stacks to test again.
To make the sprite fall faster, make the time in the “glide” blocks shorter.
Next, program the stars sprite to appear when the character is hit.
Add a "broadcast" block above the "wait” block, and select "new message" from the dropdown.
Name the message something like "stars."
Program the stars to circle around the character’s head when it receives that message.
Select the star sprite, and add a "when I receive" block.
Select the stars message.
The star sprite is currently hidden.
To make it show and circle the character's head, add a "show" block.
Click the block stack to show the sprite.
Program the sprite to start on one side of the character's head, then move to the other.
Drag the star sprite to one side, and add a "go to xy" block.
Drag the sprite to the other side, and add a "glide" block.
Finally, drag the sprite back to the original side, and add another “glide” block.
Click the block stack to test.
The star bounces back and forth.
In real cartoons, when a character gets hit on the head, they don't have just one star
above their head.
They have a bunch.
To make several stars go around the sprite’s head, add a "create clone" block under the
"when I receive" block.
To make several clones that start slightly after each other, add a repeat loop around
this and a "wait" block under the "create clone" block.
Add a "when I start as clone" block, and move the "show" and motion blocks to this event.
Click the "when I receive" blockstack to test.
The clones move back and forth around the character's head.
But, the original sprite does not move, which looks a little strange.
To fix this, hide the original sprite.
Add a "when flag clicked" event, and add a "hide" block.
Click both block stacks test again.
The original sprite is hidden, but the clones are still on the screen after they stop moving.
To get rid of them, add a "delete this clone" block to the bottom of the code stack.
Click the stop sign to delete the clones, then click the “when I receive” stack
to test again.
With a little persistence, you made this effect work just right.
Now, it's your turn.
Add a sprite that will fall on the character's head.
Broadcast a message to make this sprite fall.
Program the sprite to receive this message, then glide down to the floor.
Broadcast a message to start the stars effect.
Program the star to create clones that glide back and forth across the character's head.
Hide the star sprite when the flag is clicked, and delete the star clones when they finish