Game Development Reference
In-Depth Information
4. The next step is to atach a wait () secs block.
5.
Fill in a very short ime of 0.05 seconds. This might seem a litle useless, but it will
give the other scripts (speciically the cannonball script in this case) ime to respond
before the target disappears.
6.
The last step is to delete this clone .
Cannonball collisions
The targets disappear when hit by the cannonball, but the cannonball can go on through
muliple targets. This makes the game a bit too easy. It would be beter if the cannonball
is stopped by hiing a target as well. So a new cannonball has to be aimed and shot for
each target.
Making the cannonball disappear on contact with a target just requires a litle addiion to the
exising script. The cannonball is already reset to its original posiion when hiing the stage
edge. We can use this already exising script and also check for hiing a target.
1. Click on the cannonball sprite in the Sprites view to see its scriping panel.
2. Grab an () or () operator block.
3. Pull the touching <edge>? block from the script and place it in one of the () or ()
slots. It doesn't mater which one.
4. Also get a new touching ()? block. Place it in the other slot and have this condiion
checking for target . (Have you already properly named your target sprite?)
5. Place this enire condiional structure in the now vacant condiion slot in the
exising script.
The cannonball gets reset when it touches the edge or a target. It doesn't mater that the
target is a clone. It is sill called a "target".
 
Search WWH ::




Custom Search