Learn how to use Adobe Flash with all the free tutorials. Game Making, Animating, Cartoon Design, Web Design and much more...
How to make a health bar
Making a health bar with with flash 8 can be useful for many different types of flash games, and it doesn’t just have to be a health bar. It can be a petrol gauge in a racing flash game, a time left bar, a skill bar; pretty much anything that represents stats. Flash 8 works very well with numbers and stats, so it's good to learn as it is very commonly used when making flash games.
For this example, we’ll just use it as a health bar.
Begin by drawing out a rectangle on the stage, they’re you go, that’s it for the drawing part already. Select the whole rectangle, and in its property box at the bottom of the screen, you see W: meaning width, and H: meaning height, set the width to 120, and the height to 20. This is not necessary, but an average size health bar is around this in flash games.
Right click on the rectangle, go down to ‘convert to symbol’, and make it a ‘movie clip’. However, to the right, there is a registration grid, it is set to the middle by default, change it over to the left of the grid by clicking on the desired area on the grid, and then click OK.
Now right click on the rectangle movieclip, and select ‘actions’ from the menu, insert the following actionscript:
onClipEvent (enterFrame) {
this._xscale -= 1;
}
onClipEvent (enterFrame) {
if (this._xscale == 0) {
_root.gotoAndStop(2);
}
}
This code means that the xscale of the rectangle will go down by 1 every time flash 8 enters the frame.
If flash 8 enters the frame and the xscale is 0, flash will go to frame 2.
Right click on frame 1, and go down to ‘actions’, insert the following actionscript:
stop();
Now right click on frame 2, and select ‘insert keyframe’, this is the frame, where we will let the user know, that, they’re dead.
Delete the health bar from this frame, as there won’t be any by the time they reach frame 2 in the game, and insert the following text on the stage, ‘You died!!!’.
You could animate this text, add some graphics, or something like that.
And that's how you make a health bar using flash 8.
As I said, this learning how to use statistics and numbers using flash 8, is very useful for when it comes to making flash games.
Subscribe to:
Post Comments (Atom)
2 comments:
Your post was very helpful for a project I am doing in my Game Design class. Thank you for the useful information!
Post a Comment