Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
Game introductions often include
a short animation, special effect,
or other interesting features to get people excited
about playing the game.
In this add-on, you'll program a flickering background
to introduce your project.
You're creating an introduction,
so the transition sprites should show
when the project starts.
Drag out a when flag clicked block from the 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 switching quickly between two costumes.
Drag out a switch costume to block.
Select the costume name of the effect you want to show.
Drag out another switch costume to block
and select the second costume name.
Click each of these blocks repeatedly
to make the flickering effect.
Rather than repeatedly clicking between these blocks,
you can program the computer to repeat this 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 code so fast,
you can't see the sprite change costumes.
To fix this, add a wait block
after each switch costume block.
To speed up or slow down the flickering effect,
change the values on the weight blocks.
Next, make the flicker effect fade out.
Drag out a change effect by block.
To fade the sprite, select ghost in the dropdown.
Click the block to run it.
The sprite becomes slightly more transparent.
To keep fading the transition
until the transition sprite disappears entirely,
add a repeat 10 block, then attach this code
to your block stack.
Click the flag to try it out.
Cool, now the introduction fades into the project.
You can change the speed of a fade
by tinkering with the values and 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 of time
your introduction takes.
Try different values in the wait block
until your story starts at the right time.
Now it's your turn.
Start an effect to introduce your game
with 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
by adding wait blocks after each when flag clicked block.