This add-on will walk you through programming
a balloon celebration when the space bar is clicked.
To start, add a new balloon sprite from the sprite library.
Next, program the balloon to float
from the bottom of the stage to the top.
Drag out a go to block from the motion menu
and set the Y value to a number that's close
to the bottom of the stage like -180.
Next, add a glide block to the go to block.
The Y value should be a number
close to the top of the stage like positive 180.
Test it out.
Great!
The balloon is a little large.
Use the set size to block to change
the size of the balloon when it appears on stage.
100% is the original size, so numbers smaller than this
like 70% will make all of the balloons
70% of the original balloon size.
Make sure to test your code often
to see if it's working the way you'd like it to.
Awesome!
It works!
Now, program multiple balloons
to appear when the space key is pressed.
Drag out a when space key pressed
block from the events menu.
Then add a create clone of myself block
from the control menu to the space key event.
Recall that an earlier screen cast,
clones are created for the models to come on stage.
For this example, you'll create clones or duplicates
to have multiple balloons appear.
To make the clone do something,
add a when I start as clone block from the control menu.
Press the space bar to test.
Great!
Now, to have multiple balloons appear,
add a forever loop around the create clone of myself block.
Press the space bar.
Whoa!
Add a wait block inside the forever loop
so the balloons don't come out all at once.
Tinker with this value.
This example uses 0.3.
Now the balloons are all going up in a straight line.
Fix this using a pick random block from the operator's menu.
Add the pick random block to the X value in the glide block.
Change the range to -240 and 240.
This is the width of the stage.
Great!
Now, the balloons go to random
directions and this looks more natural.
Now there's another problem.
All of the balloons are getting
stuck at the top of the stage.
This can potentially slow down and overwork your computer.
To fix this, use a delete this clone block.
This block, is a control block
and it's the only way to delete a clone with code.
Add a forever loop around the motion blocks for the balloon,
and add a delete this clone block
at the bottom of the forever loop.
Awesome.
To make the balloons appear to be different colors,
add a change color effect block
after the create clone of myself block.
Now, there's a balloon celebration with different colors.
Finally, add hide and show blocks
to hide the balloon sprite until the celebration starts.
Drag out a hide block from the looks menu
and place a when flag clicked block above it.
Then add a show block to the when I start as a clone
block stack to make the balloon clones appear.
Great!
Now it's your turn.
Add a new balloon sprite then code the sprite
to forever go from the bottom of the stage
to the top of the stage, using a forever loop
and go to, glide, set size, and delete this clone blocks.
Make sure to add a when I start as clone block,
then code the balloon celebration to start
when the space key is pressed,
adding a forever loop and a create clone of myself,
change color effect, and a wait block.
Tinker with the values and consider using
pick random blocks in other places.