To died is a classic end for games. The character has a "health-level" and this level can go to zero after some "problems".
A good option is to have the possibility to:
At our sample, the bullet is a movie-clip created using "motion tween". We have a general flag: health.
The program glued to the bullet is (remember: up, down, right and left are the movie-clips of the character):
onClipEvent(enterFrame){
if(_root.health<10){
_root.nextFrame();
}
if(this.hittest(_root.up) ||
this.hittest(_root.down) ||
this.hittest(_root.right) ||
this.hittest(_root.left)){
_root.health =_root.health-20;
_root.healthqtd.text=_root.health;
}
}
We have another "shadow" under the medical help device.

The program glued to this shadow is:
onClipEvent(load){
this._visible=false;
used=0;
}
onClipEvent(enterFrame){
if (hitTest(_root.base._x, _root.base._y, true)
&& used == 0){
used=1;
_root.health = _root.health + 40;
_root.healthqtd.text = _root.health;
}
}
Play our sample. Click in the figure to activate.Use the arrow keys to walk. Try to use the medical device. To died is a good experience...
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE