Game introductions often include a short animation, special effect, or other interesting featuresto get people excited about playing the game. In this add-on, you'll program a flickeringbackground to introduce your project.
To start, click on the scripts tab. You’re creating an introduction, so the transitionsprite should show when the project starts. Drag out a “when flag clicked” block fromthe events menu, and add a “show” block from the looks menu. Click the flag to test.
Great! The “transition” sprite shows. Next, create the flicker effect by switchingquickly between two costumes.
Drag out a “switch costume to” block. Select the costume name of the effect youwant to show. Drag out another “switch costume to” block, and select the second costumename. Click each of these blocks repeatedly to make the flickering effect.
Rather than repeatedly clicking between these blocks, you can program the computer to repeatthis code for you.
Select the control menu, and drag out a “repeat 10” block. Place the “switch costume”blocks inside it. If you run this code now, nothing happens. The computer runs the codeso fast, you can’t see the sprite change costumes. To fix this, add a “wait” blockafter each “switch costume” block. Click the flag to test. To speed up or slow downthe flickering effect, change the values in the “wait” blocks.
Next, make the flicker effect fade out. Drag out a “change effect by" block. To fadethe sprite, select “ghost” in the dropdown. Click the block to run it. The sprite becomesslightly more transparent. To keep fading the transition until the transition spritedisappears entirely, add a “repeat 10” block, then attach this code to your blockstack. Click the flag to try it. Cool, now the introduction fades into theproject! You can change the speed of the fade by tinkering with the values in the “repeat”and “change effect” blocks. If the sprite doesn’t completely fade out,add a “hide” block at the end of your block stack.
Next, program the rest of your code to start running after the effect fades out. For each“when flag clicked” block in your program, add a “wait” block with the amount oftime your introduction takes. Try different values in the “wait” block until yourstory starts at the right time.
In computer science, it often takes more than one try to find the right solution to a problem.
Keep coding, testing, and trying solutions until you find the one that works.
Now, it’s your turn: Start an effect to introduce your game with“when flag clicked” and “show” blocks. Create a flickering effect using “repeat”and “switch costume” blocks Make the flicker effect fade out using “repeat”and “change ghost effect” blocks. Start your story after the introduction byadding “wait” blocks after each “when flag clicked” block.
Choose an Add-On
Program an interesting introduction to your project.
Learn about vector graphics, and edit or draw your own costume.
Learn about bitmap graphics and draw your own pixel character.
Add video game sound effects or music to your project.