First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: CorkySurprise | Website: http://www.freewebs.com/corkyandtooky
Ok I'll try to make this as simple as possible; Open up Flash and open up a new file (It should work on any version of flash really, although I only tested MX & MX 2004) Create a new layer and call it Controls. Now, create a dynamic text box. If you know how to make dynamic text boxes skip this part ---------------------------------------------------------------------- How to make Dynamic Text Boxes: Create a standard text box (Control & T). Now, select the Box which says Static Text, and scroll down to Dynamic Text. Done; wasn't that easy? ---------------------------------------------------------------------- Now, give it the variable name of health. On the first frame of Controls put this script in: health = 100; This tells the dynamic text box called health to have a value of 100. If in your game you want 35 health, change it to health = 35; Now, create a new layer called Character. This will be the man you’re controlling. Draw a small dot, or whatever you want to move about. Select it, Convert to Symbol (F8) and call it Character. Also give it an instance name of character (don't change this one yet) Next step is to make a new layer called Enemy. Draw the "Bad Guy" or whatever you want your character to run into. Convert him into a symbol and give him an instance name of Red. (Red because in the .zip file I called it red) Next step, On the Controls layer create a new frame and give it the frame label Gameover. Then, give it some frame script saying: Stop(); Now for some script, give this code to the character: onClipEvent (enterFrame) { if (this.hitTest(_root.Red)) { _root.health -= 1; if (_root.health == 0) { _root.gotoAndStop("Gameover"); } } } What does this mean in English? It means: When the movie clip called Character Comes into contact with another Movie Clip called Red it will look for a dynamic text box called health and take away 1 from it. If the dynamic text box called health = 100 it will goto and stop on the frame called "Gameover" But, the character can't move; what use is that? Give this script to the character: onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { _x = _x-10; } if (Key.isDown(Key.UP)) { _y = _y-10; } if (Key.isDown(Key.RIGHT)) { _x = _x+10; } if (Key.isDown(Key.DOWN)) { _y = _y+10; } } So now it looks like: onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { _x = _x-10; } if (Key.isDown(Key.UP)) { _y = _y-10; } if (Key.isDown(Key.RIGHT)) { _x = _x+10; } if (Key.isDown(Key.DOWN)) { _y = _y+10; } } onClipEvent (enterFrame) { if (this.hitTest(_root.Red)) { _root.health -= 1; if (_root.health == 0) { _root.gotoAndStop("Gameover"); } } } And there you go, Health system done. If you want to make it more complex you can start by fixing a glitch I’ve found. If you made it so the enemy did 3 damage the health doesn’t go onto zero, it goes onto 1, then -2. The script only goes to Gameover if it equals 0. To fix this, you need to add something which makes the script say “if health = 0 or under.”
» Level Basic

Added: 2004-12-27
Rating: 3 Votes: 10
(10 being the highest)
» Author
Likes Flash when it works- Hates it when it doesn't
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.