Hardware Reference
In-Depth Information
Adding a Script to Switch the Stage
So far, you have created a portal sprite that broadcasts a message when touched by the
Adventurer sprite, but that does not solve the problem of switching the backgrounds
of the stage. You need to add a script to the stage so that it responds to the message
that was broadcast when the portal sprite was touched.
1. Click the Stage icon in the Sprites palette. Add the control block when
clicked, followed by a switch to background _ looks block, and select
Outside from the drop-down menu. Make sure that you have labelled your
stage backgrounds as Inside and Outside to correspond with your location
designs.
2. Next add another control block, but this time use when I receive and select the
broadcast message Level from the drop-down menu. Add the switch to back-
ground _ looks block and this time choose Inside from the drop-down menu.
Figure 3-19 shows this script. Save your work so far and test to see if it works.
FIGURE 3-19 Using broadcast on the stage to switch between backgrounds
3. Whenever you are creating more complicated scripts for multiple sprites and on
the stage, it is a good idea to test that they work. Click the green flag and use the
arrow keys on your keyboard to navigate the Adventurer sprite to the portal and
see what happens.
4. You may ind that your Adventurer sprite is not positioned at the entrance of
your Inside cave background. Simply drag the Adventurer sprite to where you
would like it to start from on this stage background, make a note of the x and y
Search WWH ::




Custom Search