4. Clone Actions
In this video, you will program the clones to perform differently from one another.
When you test your code, both clones do exactly the same thing. They stay in the same position, wait for 3 seconds, and disappear.
Many studio logos perform an effect or animation before they center on the screen.
Program the “Studio Name” clone to run different code using conditional statements.
Drag out an “if” block. Next, drag out an “equals” block, and place it in the “if” block. Place the “costume #” block in the first value box.
This block stores the number of the current costume. Type in the costume number of the clone you’re animating. This example animates the “Studio Name” costume, so “2” is entered into the “equals” block.
Next, animate a movement for your studio name.
You may have to “show” the sprite, and switch to the correct costume number, to do this. This example uses a “go to x y” block and a “glide” block to make the words fly in from the bottom, but you’ll create your own fun animation for your logo.
You can make your costume spin, zip around the screen, or fade in using an effect. Place the entire “if” block after the “when I start as a clone” block.
Test it out. Both clones appear, and the “studio name” clone glides in from the bottom. However, the text now stays visible an additional second after the background disappears. In this example, the bug comes from the “glide” block. When the code for the “Studio Name” clone runs, it moves to the bottom of the screen, glides 1 second, then waits 3 seconds. That takes 4 seconds to complete! The “opening screen” clone only waits 3 seconds before it hides. Rather than sequencing the different parallel code stacks to stop at the same time, send an interrupt to stop the code from running.
Interrupts stop the code and make sprites do something different. In this case, use the “broadcast” block to send an interrupt which will stop the studio animation and start the new project. Drag out a broadcast block and attach it to the bottom of the “when flag clicked” block stack. Create a new message and name it “Start Program,” because this block will both delete the clones and start any new projects.
Drag out a “when I receive” block, and change the dropdown to “start program.”
Move the “delete this clone” block to the “when I receive” block. Move the “wait” block to above the “broadcast” block. The “wait” block determines the length of time the studio logo runs before the broadcast block interrupts the animation and deletes the clones.
Click the flag to test. Both clones should disappear after 3 seconds have passed. If 3 seconds is too long or too short, tinker with the wait value. This example changes the value to 4.
Now that you have one conditional statement and a way to make the animation end after a certain period of time, it will be easier to add more animations to your studio logo. The next video will show you how!
Now, it’s your turn: Program the “Studio Name” clone to run different code using “costume #,” “equals,” and “if” blocks.
Add an animation to the “Studio Name” clone.
Make the Studio Logo animation end using “broadcast” and “when I receive.”