Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author Miguel Panos
»  Title: Tarta
»  Description: It is a circle graph or pie chart that takes the data entered by user
»  More by Miguel Panos


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4839 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  AuthorDeft Creative Ltd
»  Link: Home Page
»  Description: Portfolio site for .DeftCreative Ltd. A UK based web design studio specialising in flash websites, games and interactive CDROMs. With an emphasis on making things different.


Random Links | Add your own Flash Related Links
Flash Tutorials 1484 Tutorials 7 New Tutorials Added!
What's New | Top100

» Making Automatic Training Screen Capture Easily
» Create Undersea Life Animation
» Making Deinterlace Video with a low bitrate Easily
» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Games

Categories Health for MX 2004
Author: CorkySurprise | Website: www.freewebs.com/corkyandtooky |

 
Page 1
1

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.”

1

» Level Basic

Added: : 2004-12-27
Rating: 2.90 Votes: 10
Hits: 204
» Author
Likes Flash when it works- Hates it when it doesn't
» Download
Download the files used in this tutorial.
Download (11 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments