Game Development Reference
In-Depth Information
With a script, we will step through the different costumes on each hit. This will make it
appear that the hit bar shrinks and eventually the enemy is killed. The following are the
steps to do it:
1. Go to the Scripts tab to start making use of the new costumes. We will
make changes to the clone script.
2. Drag the collision check condiion out of the script and put it aside for
later use.
3. Remove the forever loop from the script.
4. In its place, put a repeat unil … block.
5. Set the collision check inside this block.
6. Get a = operator block and place it in the condiion slot of the repeat
unil … block.
7. Place the costume# variable from the Looks category in one slot of
the equaion.
8. Type 10 in the other slot. This will cause the script to repeat unil the sprite
is showing costume number 10, the dead state we just drew.
9. The clone should only be destroyed after the repeat condiion is met.
So drag the delete this clone block out of the if statement and re-atach
it at the botom of the script.
10. Instead of immediately deleing itself, the clone should advance a costume
when hit by a cannonball. Place a next costume block inside the if statement
to achieve this.
11. To prevent the sprite from stepping through muliple costumes on a single
hit, make the loop to wait for 0.05 by using the wait ... secs block.
12. To prevent the sprite from immediately disappearing on receiving the last hit,
and thus not showing the dead costume, we place another wait 0.5 secs
block just before the delete command.
 
Search WWH ::




Custom Search