A crosshair cursor would be ideal for a shooter/hunter game. And this one procedure can be used to make a standard cursor also.
In this tutorial the crosshair will be used as the cursor also, as it is being made for a shooting game. Using the oval tool draw out a circle on the stage, make sure it has no fill. This cirle only needs be small, with a width and height of about 35. Inside this circle using the line tool, you will need to draw a cross, the middle of the lines that form the cross should intersect directly in the middle of the circle.
Select the crosshair you have just drawn, right click on it and convert it in to a movieclip. In it properties panel, give it an instance name of crosshair_mc. (make sure you do not include the full stop 'mc').
Insert another layer and rename it actions. Right click on the first frame and select actions. Put in the following actionscript:
Mouse.hide();
crosshair_mc.onMouseMove = function() {this._x=_xmouse, this._y=_ymouse;}
This tells flash to hide the mouse cursor, and make the crosshair movieclip's x and y co-ordinates the same as the mouse'.
Learn how to use Adobe Flash with all the free tutorials. Game Making, Animating, Cartoon Design, Web Design and much more...
Showing posts with label Game Making. Show all posts
Showing posts with label Game Making. Show all posts
Checkbox in flash
Adobe Flash has an inbuilt function that allows you to insert a checkbox in flash easily and quickly.
From the main menu options select window>components. A window will appear with a few different catergories to choose from, you will need the user interface catergory, from the user interface catergories double click on checkbox. This will insert an instance of a checkbox on the stage.
Select the checkbox and open up it's properties panel, there are three tabs, properties, filters and parameters, select the parameters tab. A table will now appear in the parameters panel, locate label, in empty box next to label, insert the text yes, also check that the text on the table that reads selected, is set to false. There should now be a checkbox on the stage with the word yes on the right hand side of it. Select the yes checkbox, just above the properties tab, there is an actions tab, click it and insert the following actionscript:
onClipEvent (enterFrame) {
if (this.selected) {
_root.gotoAndStop(2);
}
}
This tells flash that when it enters the frame, it needs to wait until the checkbox is selected, before going to frame 2.
Checkboxes are really useful for things like collecting date and reviews, quizes, serveys, web forms etc.
From the main menu options select window>components. A window will appear with a few different catergories to choose from, you will need the user interface catergory, from the user interface catergories double click on checkbox. This will insert an instance of a checkbox on the stage.
Select the checkbox and open up it's properties panel, there are three tabs, properties, filters and parameters, select the parameters tab. A table will now appear in the parameters panel, locate label, in empty box next to label, insert the text yes, also check that the text on the table that reads selected, is set to false. There should now be a checkbox on the stage with the word yes on the right hand side of it. Select the yes checkbox, just above the properties tab, there is an actions tab, click it and insert the following actionscript:
onClipEvent (enterFrame) {
if (this.selected) {
_root.gotoAndStop(2);
}
}
This tells flash that when it enters the frame, it needs to wait until the checkbox is selected, before going to frame 2.
Checkboxes are really useful for things like collecting date and reviews, quizes, serveys, web forms etc.
Creating a game menu
Although this menu is designed for a shooting game, using the skills that you learn from this tutorial will help you when creating and making any menu for any flash game or flash movie.
Double click on layer 1, and rename it actions.
Insert another 4 layers, renaming them: ‘title’, ‘purchases’, ‘player name’ and ‘start button’.
More layers will need to be inserted shortly, for the shooting menu’s animation, which will be your creation (see animation tutorials if unsure). If this is the first menu you have ever made, perhaps try adding some animation once your comfortable with the concept of creating a menu. so far you should have the following layers
-Actions (For all the actions)
-Title (Contains the title of the game)
-Purchases (A layer which controls the purchasing funtions)
-Player name (Allows the player to enter their name)
-Start button (Allows the player to begin the game)
In this shooting game menu, the player will be required to enter their name, purchase bullets, and press the start button to begin.
You will need to think of a title for the game, which will be ‘Shoot to Kill’ for this tutorial. Using the text tool, insert a textbox somewhere on the stage, making sure it is on the title layer, and insert the title of the game in the textbox. Being a main heading the text should be made visible with colour, and made a moderate size. For this tutorial the headings original position is off the stage, and once the game has started it slides in from the side of the stage to the middle of the stage.
Let's make your title do this also. On frame 1 of the title layer move the text off the left hand side of stage, making sure none of the text is visible on the stage. Right click on frame 15 on the title layer and insert a keyframe. On frame 15 move the title text to where you want it to slide to. Once this is done, right click anywhere between the 1st and 15th frame and create motion tween. Test the movie to see the result.
Now that there is an animation at the start of the game, you don't want to
see all the other menu options until this animation is over.
So you will need to insert a keyframe on frame 15 of all the other layers, as this is where the animation ends.
Before going any further define the variables of the game. On the 15th frame of the actions layer, insert the following actionscript:
stop();
var ammo = 0;
var money = 100;
This tells Adobe Flash to set the players money to 100, and the players ammo to 0. Obviously the player will require some money to purchase ammo. But only a little bit, as this is only the beginning of the game.
Now for the player name layer:
Using the text tool, insert a textbox somewhere on the stage on the 15th frame. In the textbox properties, set it to input text, this allows the player to enter text in to the textbox. Select the textbox, and give it a var of ‘playerName’ without the quotation marks. Also, next to ‘Var:’ on the left side, there are three buttons, the one closest to ‘Var:’ puts a border around the text box, click on it, and make sure that there is a border around the text box. (If this isn' done, the user won’t be able to see where to enter their name).
Now next to this playerName input textbox, on the left hand side, insert a static textbox. In the textbox write ‘enter name:’
The shooting menu now has a place for the user to enter their name!
For the purchase layer:
You will now need to provide the player with some stats showing them how much ammo they have purchased.
Using the text tool insert a static textbox on the stage, and write in the textbox, ‘ammo:’ Now next to this, on the right hand side of this textbox, insert a dynamic textbox, give it a var of ammo. The shooting menu now has somewhere to display how much ammo the player has purchased.
Now you will need to design a button that allows the user to purchase the bullets.
Using the text tool, draw out a static textbox, and type in ‘Purchase Bullets’. You could also draw a little bullet to put next to the text just to make it more creative and interesting. Select the purchase bullets text, right click on it, and convert it in to a button.
Right click on the purchase bullets button, and give it the following actions:
on (release) {
if (_root.money>24) {
_root.ammo += 5;
_root.money -= 25;
} else {
_root.ammo += 0;
}
}
This tells Adobe Flash that when the button is released, if the money is larger than 24, the users ammo will go up by 5, however, if it’s below 24, the ammo won’t go up at all.
Meaning the cost of 5 bullets is, 25.
The user can now insert their name, and purchase bullets for the game menu.
You will also need to insert some money functions on this layer:
Using the text tool, insert some static text somewhere on the stage, and make the text '$', on the right hand side of this, insert a dynamic text box, with the var of money. And that's it for that!
Last but not least, the start button:
Simply draw the graphic that you want to be you start button, right click on it, and convert it in to a button.
Now give the start button the following actions by right clicking on it and selecting actions:
on (release) {
gotoAndStop("Scene 2", 1);
}
This tells flash that when the button is released, go to scene 2.
Scene 2, is where the start of the main game begins. To insert ‘Scene 2’, click on ‘insert’, from the top menu, and select scene.
On scene 2, insert three dynamic textboxes, and three static text boxes.
Give these var names to the dynamic text boxes:
One textbox needs to have a ‘var’ of: ammo
Another needs a var of: playerName
And the last needs a var of: money.
Now obviously for the static text boxes, they describe what the dynamic text boxes are for. So next to the ammo text box on the left hand side, insert the text ‘ammo’.
For the money text box, it needs a money symbol next to it ‘$’.
Being a shooting game, you may want to make a crosshair cursor. Take this tutorial to see how to make a crosshair cursor.
To go back to scene 1, click on ‘view’, from the top menu, hover the mouse over ‘go to’, and select scene 1.
This is a basic way of creating a menu, but it is fully funtional, and the skills learnt from this tutorial, can definately be used for other tasks. NOT JUST FOR A SHOOTING GAME!
Double click on layer 1, and rename it actions.
Insert another 4 layers, renaming them: ‘title’, ‘purchases’, ‘player name’ and ‘start button’.
More layers will need to be inserted shortly, for the shooting menu’s animation, which will be your creation (see animation tutorials if unsure). If this is the first menu you have ever made, perhaps try adding some animation once your comfortable with the concept of creating a menu. so far you should have the following layers
-Actions (For all the actions)
-Title (Contains the title of the game)
-Purchases (A layer which controls the purchasing funtions)
-Player name (Allows the player to enter their name)
-Start button (Allows the player to begin the game)
In this shooting game menu, the player will be required to enter their name, purchase bullets, and press the start button to begin.
You will need to think of a title for the game, which will be ‘Shoot to Kill’ for this tutorial. Using the text tool, insert a textbox somewhere on the stage, making sure it is on the title layer, and insert the title of the game in the textbox. Being a main heading the text should be made visible with colour, and made a moderate size. For this tutorial the headings original position is off the stage, and once the game has started it slides in from the side of the stage to the middle of the stage.
Let's make your title do this also. On frame 1 of the title layer move the text off the left hand side of stage, making sure none of the text is visible on the stage. Right click on frame 15 on the title layer and insert a keyframe. On frame 15 move the title text to where you want it to slide to. Once this is done, right click anywhere between the 1st and 15th frame and create motion tween. Test the movie to see the result.
Now that there is an animation at the start of the game, you don't want to
see all the other menu options until this animation is over.
So you will need to insert a keyframe on frame 15 of all the other layers, as this is where the animation ends.
Before going any further define the variables of the game. On the 15th frame of the actions layer, insert the following actionscript:
stop();
var ammo = 0;
var money = 100;
This tells Adobe Flash to set the players money to 100, and the players ammo to 0. Obviously the player will require some money to purchase ammo. But only a little bit, as this is only the beginning of the game.
Now for the player name layer:
Using the text tool, insert a textbox somewhere on the stage on the 15th frame. In the textbox properties, set it to input text, this allows the player to enter text in to the textbox. Select the textbox, and give it a var of ‘playerName’ without the quotation marks. Also, next to ‘Var:’ on the left side, there are three buttons, the one closest to ‘Var:’ puts a border around the text box, click on it, and make sure that there is a border around the text box. (If this isn' done, the user won’t be able to see where to enter their name).
Now next to this playerName input textbox, on the left hand side, insert a static textbox. In the textbox write ‘enter name:’
The shooting menu now has a place for the user to enter their name!
For the purchase layer:
You will now need to provide the player with some stats showing them how much ammo they have purchased.
Using the text tool insert a static textbox on the stage, and write in the textbox, ‘ammo:’ Now next to this, on the right hand side of this textbox, insert a dynamic textbox, give it a var of ammo. The shooting menu now has somewhere to display how much ammo the player has purchased.
Now you will need to design a button that allows the user to purchase the bullets.
Using the text tool, draw out a static textbox, and type in ‘Purchase Bullets’. You could also draw a little bullet to put next to the text just to make it more creative and interesting. Select the purchase bullets text, right click on it, and convert it in to a button.
Right click on the purchase bullets button, and give it the following actions:
on (release) {
if (_root.money>24) {
_root.ammo += 5;
_root.money -= 25;
} else {
_root.ammo += 0;
}
}
This tells Adobe Flash that when the button is released, if the money is larger than 24, the users ammo will go up by 5, however, if it’s below 24, the ammo won’t go up at all.
Meaning the cost of 5 bullets is, 25.
The user can now insert their name, and purchase bullets for the game menu.
You will also need to insert some money functions on this layer:
Using the text tool, insert some static text somewhere on the stage, and make the text '$', on the right hand side of this, insert a dynamic text box, with the var of money. And that's it for that!
Last but not least, the start button:
Simply draw the graphic that you want to be you start button, right click on it, and convert it in to a button.
Now give the start button the following actions by right clicking on it and selecting actions:
on (release) {
gotoAndStop("Scene 2", 1);
}
This tells flash that when the button is released, go to scene 2.
Scene 2, is where the start of the main game begins. To insert ‘Scene 2’, click on ‘insert’, from the top menu, and select scene.
On scene 2, insert three dynamic textboxes, and three static text boxes.
Give these var names to the dynamic text boxes:
One textbox needs to have a ‘var’ of: ammo
Another needs a var of: playerName
And the last needs a var of: money.
Now obviously for the static text boxes, they describe what the dynamic text boxes are for. So next to the ammo text box on the left hand side, insert the text ‘ammo’.
For the money text box, it needs a money symbol next to it ‘$’.
Being a shooting game, you may want to make a crosshair cursor. Take this tutorial to see how to make a crosshair cursor.
To go back to scene 1, click on ‘view’, from the top menu, hover the mouse over ‘go to’, and select scene 1.
This is a basic way of creating a menu, but it is fully funtional, and the skills learnt from this tutorial, can definately be used for other tasks. NOT JUST FOR A SHOOTING GAME!
Learning actionscript
Learning actionscript can be really difficult, it's just like learning another languange, a languange that allows you to communicate with Adobe Flash and tell it what to do, when to do it and how to do it. This is one of the most important skills to learn for anyone wanting to develop their skills in game making, website design and interactive pages.
Actionscript is extremely precise, 100% to be exact, so you will need to become really familar with the languange, and this is obviously achieved through constant use of actionscript, trying different things, solving code errors. Learning to solve code errors is definately a really effective way of developing your skills. It doesn't matter in the slightest if you have to Google the solution, your job is to remember the mistake, and REMEMBER THE SOLUTION!
Get to know the basics, before progressing to more advanced actionscript you should at least know some of the most basic lines of actionscript. For example, a very common line that you will use very regularly:
'gotoAndPlay(2)' - This tells Adobe Flash that you want it to go to the
second keyframe on the timeline, and play. Timeline control is definately something you need to understand, and luckily, it is really easy to pick up. This line of code doesn't really achieve much though. To make this more detailed, you could make it,
'on (release) {gotoAndPlay(2)}' - This actionscript would work perfect
with a play button.
That may only be one line of actionscript,and a very simple line, but it's a start. And in no time you should be able to memorise that and use it regularly without even thinking about it. Of course you will eventually need to use much more sophisticated actionscript, but once you have mastered the basics, this won't seem so daunting. And these tutorials will ease you in to the process.
Summary: Begin to learn actionscript and remember it, you should never copy and past, the idea is learn to write your own code, the more you type in the actionscript, the quicker and easier you will learn to write your own code!
Quote: 'When you come across a problem, find the solution, and remember the solution!'
Actionscript is extremely precise, 100% to be exact, so you will need to become really familar with the languange, and this is obviously achieved through constant use of actionscript, trying different things, solving code errors. Learning to solve code errors is definately a really effective way of developing your skills. It doesn't matter in the slightest if you have to Google the solution, your job is to remember the mistake, and REMEMBER THE SOLUTION!
Get to know the basics, before progressing to more advanced actionscript you should at least know some of the most basic lines of actionscript. For example, a very common line that you will use very regularly:
'gotoAndPlay(2)' - This tells Adobe Flash that you want it to go to the
second keyframe on the timeline, and play. Timeline control is definately something you need to understand, and luckily, it is really easy to pick up. This line of code doesn't really achieve much though. To make this more detailed, you could make it,
'on (release) {gotoAndPlay(2)}' - This actionscript would work perfect
with a play button.
That may only be one line of actionscript,and a very simple line, but it's a start. And in no time you should be able to memorise that and use it regularly without even thinking about it. Of course you will eventually need to use much more sophisticated actionscript, but once you have mastered the basics, this won't seem so daunting. And these tutorials will ease you in to the process.
Summary: Begin to learn actionscript and remember it, you should never copy and past, the idea is learn to write your own code, the more you type in the actionscript, the quicker and easier you will learn to write your own code!
Quote: 'When you come across a problem, find the solution, and remember the solution!'
Designing and creating an RPG game
RPG/Role Playing games are among the most popular games. As and RPG game puts the user in control of the game more than most other games types. Allowing the user to make choices, take certain paths and hope it’s the right one and so on.
Before you start designing your game, it is really important that you do a plan first.
Grab a scrap of paper and start jotting down the ‘Game Plan.’
This can include, the list of characters that will appear in your game, including there role in the game, and even a biography of the character, including there personality, are they bad or good, what do they do in the RPG game.
Now try develop a bit of a story line, how will the game begin, what type of problems will arise, what will fix the problems?
Deciding how the user will interact with the game, for example:
Will the user be required to walk through the game and face the challenges, or will they only need the mouse to decide the characters fate, both would be better.
Write it out like a book, you do not need to include all the details, just enough for you to understand what’s going on. Once you’ve mapped out the plan, have a pretty accurate idea of what events will happen in the game, solution, character etc, have a little think about some additional features that you could add to your game.
Such as:
Inventory - to hold all the items the player can collect
Health bar – so the player can die
Timer or time limit – make the game more difficult with a time limit
Score – things the player can collect through out the game to earn points.
Once you have this all written down, know what you want to happen in the game, have the events plotted out, you can start creating your game, and you’ll be shocked about how much easier it is to set your game out, and get it going.
Start by designing your characters, design a menu, and so on.
The information you need, can be found on this website.
Resources:
How to make an inventory
How to make a score
Timer/time limit
Health bar
Before you start designing your game, it is really important that you do a plan first.
Grab a scrap of paper and start jotting down the ‘Game Plan.’
This can include, the list of characters that will appear in your game, including there role in the game, and even a biography of the character, including there personality, are they bad or good, what do they do in the RPG game.
Now try develop a bit of a story line, how will the game begin, what type of problems will arise, what will fix the problems?
Deciding how the user will interact with the game, for example:
Will the user be required to walk through the game and face the challenges, or will they only need the mouse to decide the characters fate, both would be better.
Write it out like a book, you do not need to include all the details, just enough for you to understand what’s going on. Once you’ve mapped out the plan, have a pretty accurate idea of what events will happen in the game, solution, character etc, have a little think about some additional features that you could add to your game.
Such as:
Inventory - to hold all the items the player can collect
Health bar – so the player can die
Timer or time limit – make the game more difficult with a time limit
Score – things the player can collect through out the game to earn points.
Once you have this all written down, know what you want to happen in the game, have the events plotted out, you can start creating your game, and you’ll be shocked about how much easier it is to set your game out, and get it going.
Start by designing your characters, design a menu, and so on.
The information you need, can be found on this website.
Resources:
How to make an inventory
How to make a score
Timer/time limit
Health bar
How to make a password
In this tutorial we are going to make an input text field where the user needs to enter a password in order to play the flash file.
This is really easy to do.
Begin by selecting the ‘text tool’, and in the property box at the bottom, make sure it is set to ‘dynamic text’, and the text alignment is set to ‘Align Center’.
Now at the top of the stage, draw out a large text field that will fit the text, ‘invalid password’ in it. In the property’s box of this text field, underneath where it says, dynamic text, there will be an empty box, in this box, insert the following, ‘wrongPassword’. Without the quotes!!!
This text box will be used to let the user know if they have entered an invalid password.
Using the ‘text tool’ again, set it to ‘input text’, in the property’s box, and insert a text field on the stage. (This is where the user will enter a password). In the property box, underneath where it says, ‘input text’, write ‘my_passWord’, without the quotes!!!
And next to where it says Var: write, ‘passWord’, without the quotes.
Now we will need to insert a button, for the user to click after they have entered a password. Somewhere on the stage, using the ‘oval tool’, draw out an oval, where you want the submit button to be.
Now select the whole oval, right click on it, and then go down to ‘convert to symbol’, and make it a button.
Now right click on the button, and select ‘actions’, insert the following code:
on (release) {
if (_root.passWord == "cjay" == true) {
gotoAndStop(2);
} else {
_root.wrongPassword.text = "Invalid Passord";
gotoAndStop(1);
}
}
In the first line of code:
‘(_root.passWord == “cjay” == true) {
Change ‘cjay’ to whatever you want the password to be.
When the button is released, it checks to make sure that the password entered is cjay, and if it is it will go to the next frame.
Else
The text box we made before called wrongPassword, will display, the text ‘Invalid Password’ and it will stay at frame 1.
Now right click on frame 1 in layer 1, select ‘action’, and insert the following code:
stop();
my_passWord.password = true;
This code tells flash that to stop on this frame, and that the text entered is to be displayed with asterisks, as this hides the password.
Now right click on frame 2 of layer 1, select ‘insert keyframe’, and delete everything off this keyframe.
On this new keyframe, using the ‘text tool’ set it to ‘static text’, enter some text like, ‘the password you entered was accepted’.
And that’s it for this tutorial.
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.
How to make a movie clip drag able
Add the following code to a movie clip to make it drag able:
onClipEvent (mouseDown) {
startDrag(this);
}
onClipEvent (mouseUp) {
stopDrag();
}
How to make your character walk with the arrow keys
Insert an additional layer so that you will now have two layers; name the top layer actions, and the bottom layer character.
On the first frame of the character layer, draw out your character facing to the left of the stage. Convert it into a movie clip and name it stand still. Right click on stand still in the library and select duplicate, name the duplicate walk left. Double click on the walk left symbol in the library and animate him walking right. IMPORTANT NOTE: Don’t actually make him move to the right; just animate the legs as if he was walking right.
When you have done that, click back to the main timeline.
Now right click on the walk left movie clip in the library and name the duplicate walk right.
Double click on the walk right movie clip to enter it timeline and then select modify from the top menu options, transform and flip horizontal. Now click back to the main timeline.
On the first frame of the character drag an instance of the stand still move clip to the centre of the stage, give it an instance name of standStill. Double click on this move clip and insert a blank keyframe at frame 2. Then drag an instance of the walk left move clip to the centre of the stage making sure it is in the same position as the stand still move clip was. Insert another blank keyframe where, then drag an instance of the walk right movie clip from the library and position in the centre of the stage, as before make sure this is in the same position the walk left was, only is will be facing the opposite direction.
Insert a new layer, and name it actions, right click on the first frame and select actions, add the following code:
Stop();
Now click back to the main timeline.
Right click on the first frame of the actions layer, and select actions, add the following code:
//if the left arrow key is down, go to frame to of this movie clip and also move left.
standStill.onEnterFrame = function() {
if(Key.isDown(Key.LEFT)) {
this._x+=4;
this.gotoAndStop(2);
}
else if(Key.isDown(Key.RIGHT)) {
this._x-=4;
this.gotoAndStop(3);
}
//if none of the above is happening, stop on frame 1
else this.gotoAndStop(1);
}
Well done, that is all you need to do.
As I always say: any questions Email me at: learn_flash_pro_makeitsimple_now@hotmail.com
On the first frame of the character layer, draw out your character facing to the left of the stage. Convert it into a movie clip and name it stand still. Right click on stand still in the library and select duplicate, name the duplicate walk left. Double click on the walk left symbol in the library and animate him walking right. IMPORTANT NOTE: Don’t actually make him move to the right; just animate the legs as if he was walking right.
When you have done that, click back to the main timeline.
Now right click on the walk left movie clip in the library and name the duplicate walk right.
Double click on the walk right movie clip to enter it timeline and then select modify from the top menu options, transform and flip horizontal. Now click back to the main timeline.
On the first frame of the character drag an instance of the stand still move clip to the centre of the stage, give it an instance name of standStill. Double click on this move clip and insert a blank keyframe at frame 2. Then drag an instance of the walk left move clip to the centre of the stage making sure it is in the same position as the stand still move clip was. Insert another blank keyframe where, then drag an instance of the walk right movie clip from the library and position in the centre of the stage, as before make sure this is in the same position the walk left was, only is will be facing the opposite direction.
Insert a new layer, and name it actions, right click on the first frame and select actions, add the following code:
Stop();
Now click back to the main timeline.
Right click on the first frame of the actions layer, and select actions, add the following code:
//if the left arrow key is down, go to frame to of this movie clip and also move left.
standStill.onEnterFrame = function() {
if(Key.isDown(Key.LEFT)) {
this._x+=4;
this.gotoAndStop(2);
}
else if(Key.isDown(Key.RIGHT)) {
this._x-=4;
this.gotoAndStop(3);
}
//if none of the above is happening, stop on frame 1
else this.gotoAndStop(1);
}
Well done, that is all you need to do.
As I always say: any questions Email me at: learn_flash_pro_makeitsimple_now@hotmail.com
How to make a maze game
Making a maze game
Insert two additional layers, so you are left with 3 layers. Name layer 1 maze, layer 2 cursor and layer 3 actions.
Right click on the first frame in the actions layer and select actions, add the following actions:
stop();
Mouse.hide();
cursor.onMouseMove = function() {
this._x=_xmouse, this._y=_ymouse;
};
These actions have been explained in previous tutorials.
In the first frame of the cursor layer, using the oval tool, draw out a small circle on the stage. Now convert the circle into a movie clip, call it cursor. Also give it an instance name of cursor.
Now on the first frame of the maze layer, select line tool and set the stroke height to 10.75 or higher. Now draw out your maze(this is what the cursor will have to be guided through so make sure the cursor is smaller enough to fit in your maze).
Convert the maze you just made into a button. Now right click on the maze, select actions, and add these actions to it:
on (rollOver) {
gotoAndStop(2);
}
This means that if the cursor rolls over the maze it will move on the 2nd frame.
Now at the end of the maze where you want the finish to be draw our something that represents the end of the maze. Eg. You may want to put a trophy or a gold medal or something like that.
Convert it into a button and add the following actions to it:
on (rollOver) {
gotoAndStop(3);
}
These actions are the same as before only with a different frame number to go to.
Now insert a new keyframe at frame 2(this is the frame that the game will go to if the cursor rolls over the maze). Now delete everything on the stage, and using the brush tool, write something like YOU LOSE. Now insert another keyframe at frame 3 in the maze layer. Delete the YOU LOSE text and replace it with something like GREAT WORK.
That’s it, you just made a maze game, you may want to insert keyframe at frames 2 and 3 of the cursor layer so the cursor is still active.
Now that you know how to create a maze game, add more levels, with the knowledge you have learnt throughout these tutorials you will be able to add button to restart and buttons to go to the next level etc.
How to make a quiz game
Making a Quiz Game
Start by inserting an additional 2 layers, so you will be left with 3 layers.
Name the bottom layer title, the middle Q’s and A’s and the top layer Actions.
Select modify from the menu option located at the top of the screen, then select document and change the colour to black(I am using black for this example, you use what ever you want).
Insert a keyframe at frame 2 on every layer.
Right click on the first frame of the action layer and select actions, now on the first line type in:
stop();
score = 0;
Now right click on the second frame of the action layer and select actions, on the first line type in:
percent = score/1*100+%;
(IMPORTANT NOTE: THERE MUST BE QUOTATION MARKS AROUND THE PERCENT SYMBOL.
The only reason I have not added the quotation marks is because this is a html document, and if I place the quotation marks around the % you will only see “”.
This is telling flash that the percent = whatever the score is(for this example I only have 1 question, so the score will be 1) divided by 100.(which is 100%). The +% means to add a % symbol at the end of the result.
On the first frame of the title layer, draw out a text box(static text) and type in the name of the quiz. For this example I will be using learnflash8pro.blogspot.com.
Now on the second frame of the title layer, draw out another text box(static text) and type in You Scored.
On the first frame of the Q’s and A’s layer, write out the question and the answers.
My question was Is learnflash8pro.blogspot.com the best site ever?
My answers were Yes and No.
I recommend that you place each of these underneath each other.
Eg. Is learnflash8pro.blogspot.com the best site ever?
Yes
No
Convert the answers in to 2 separate buttons. Right click on the correct answer and select action(of course the correct answer for me would be yes).
Add these actions to the correct answers:
on (release){
gotoAndStop(2);
score+=1;
}
This means that when the mouse is released the score will go up by one and go to the next frame.
Add these actions to the incorrect answer:
on (release){
gotoAndStop(2);
}
This means that when the mouse is released go to frame two. As this is the wrong answer we don’t want the score to go up.
Now on the 2nd keyframe of the Q’s and A’s layer, using the text tool(static text) draw out 3 text boxes, each underneath each other.
In the top text box type in: # of Questions:1
In the middle text box type in: # of Correct Questions:
Now in the bottom text box type in: Percentage:
Now using the text tool again, this time dynamic text, draw out a text box next to the # of Correct Questions text box, give it a var name of score.
Now using the text tool(still dynamic text) draw out a text box next to Percentage, and give this text box a var name of percent.
Congratulations, you have made your first quiz.
Now that you have the idea, create a quiz with a few questions, and obviously you will have to make minor changes to the Actionscript.
Start by inserting an additional 2 layers, so you will be left with 3 layers.
Name the bottom layer title, the middle Q’s and A’s and the top layer Actions.
Select modify from the menu option located at the top of the screen, then select document and change the colour to black(I am using black for this example, you use what ever you want).
Insert a keyframe at frame 2 on every layer.
Right click on the first frame of the action layer and select actions, now on the first line type in:
stop();
score = 0;
Now right click on the second frame of the action layer and select actions, on the first line type in:
percent = score/1*100+%;
(IMPORTANT NOTE: THERE MUST BE QUOTATION MARKS AROUND THE PERCENT SYMBOL.
The only reason I have not added the quotation marks is because this is a html document, and if I place the quotation marks around the % you will only see “”.
This is telling flash that the percent = whatever the score is(for this example I only have 1 question, so the score will be 1) divided by 100.(which is 100%). The +% means to add a % symbol at the end of the result.
On the first frame of the title layer, draw out a text box(static text) and type in the name of the quiz. For this example I will be using learnflash8pro.blogspot.com.
Now on the second frame of the title layer, draw out another text box(static text) and type in You Scored.
On the first frame of the Q’s and A’s layer, write out the question and the answers.
My question was Is learnflash8pro.blogspot.com the best site ever?
My answers were Yes and No.
I recommend that you place each of these underneath each other.
Eg. Is learnflash8pro.blogspot.com the best site ever?
Yes
No
Convert the answers in to 2 separate buttons. Right click on the correct answer and select action(of course the correct answer for me would be yes).
Add these actions to the correct answers:
on (release){
gotoAndStop(2);
score+=1;
}
This means that when the mouse is released the score will go up by one and go to the next frame.
Add these actions to the incorrect answer:
on (release){
gotoAndStop(2);
}
This means that when the mouse is released go to frame two. As this is the wrong answer we don’t want the score to go up.
Now on the 2nd keyframe of the Q’s and A’s layer, using the text tool(static text) draw out 3 text boxes, each underneath each other.
In the top text box type in: # of Questions:1
In the middle text box type in: # of Correct Questions:
Now in the bottom text box type in: Percentage:
Now using the text tool again, this time dynamic text, draw out a text box next to the # of Correct Questions text box, give it a var name of score.
Now using the text tool(still dynamic text) draw out a text box next to Percentage, and give this text box a var name of percent.
Congratulations, you have made your first quiz.
Now that you have the idea, create a quiz with a few questions, and obviously you will have to make minor changes to the Actionscript.
How make an object move using arrow keys
Making Object Move Using Arrows
Start by naming layer 1 circle, this is the only layer that is required for this tutorial.
Using the Oval tool draw out a circle on the stage, convert it to a movie clip.
Now right click on the circle, and select actions.
Now on the first line type in:
onClipEvent (enterFrame) {
//if the left arrow is pressed, the circle will move to the left,
//the number determines how fast it will move.
if (Key.isDown(Key.LEFT)) {
this._x = _x-7;
} else if (Key.isDown(Key.RIGHT)) {
this._x = _x+7;
}
//the circle will move up
if (Key.isDown(Key.UP)) {
this._y = _y-7;
//the circle will move down
} else if (Key.isDown(Key.DOWN)) {
this._y = _y+7;
}
}
NOTE: you can quite easily copy paste these action, where I have explained what the actions will do won’t interfere as I have placed two forward slashes before them, this is so flash doesn’t pay any attention to them.
Well, how easy was that?
Start by naming layer 1 circle, this is the only layer that is required for this tutorial.
Using the Oval tool draw out a circle on the stage, convert it to a movie clip.
Now right click on the circle, and select actions.
Now on the first line type in:
onClipEvent (enterFrame) {
//if the left arrow is pressed, the circle will move to the left,
//the number determines how fast it will move.
if (Key.isDown(Key.LEFT)) {
this._x = _x-7;
} else if (Key.isDown(Key.RIGHT)) {
this._x = _x+7;
}
//the circle will move up
if (Key.isDown(Key.UP)) {
this._y = _y-7;
//the circle will move down
} else if (Key.isDown(Key.DOWN)) {
this._y = _y+7;
}
}
NOTE: you can quite easily copy paste these action, where I have explained what the actions will do won’t interfere as I have placed two forward slashes before them, this is so flash doesn’t pay any attention to them.
Well, how easy was that?
How to make your character talk when clicked
Make your character talk when he/she/it gets clicked
For this example we will also only be using layer 1. Using the oval tool draw out a circle of any colour and convert it to a movie clip. NOTE: I am only using a circle as an example, this would be your character. Now double click on your character. Start by right clicking on frame 1, and selecting actions. On the first line type in: stop();
Now insert a keyframe at frame 2. On frame 2 we need to put in the words that we want our character to say. Using the text tool (static text), insert a text box just above his head, for this example I want him to say: learningflashpro.blogspot.com.
I want the player to have enough time to read this, so I inserted a keyframe at frame 40. (this may be different for you, if you only have a short sentence like mine, use about 40 frame, otherwise just muck around with it until it is right).
On the last keyframe, in my case this would be frame 40, right click and select actions, now on the first line type in:
gotoAndStop(1);
This is so when this frame is reached it will go back to frame 1 where there is no text.
Back in the main timeline, make a cursor(do this by following the steps in tut.16).
Now we need to add some action to the character, right click on your character and select actions, on the first line type in:
onClipEvent(mouseDown) {
if(this.hitTest(_root.cursor)) {
this.gotoAndPlay(2);
}
}
This means that when the mouse has been pressed down the character movie clip will play.
That is it, pretty easy wasn’t it?
NOTE: to advance on this tutorial try instead of just using text, change it to audio.
Remember that you will need to insert a new layer to do this.
By now you should have the knowledge to do this, if not, I recommend that you go over some of the previous tutorials.
For further reference: the ads on this site contain great things about flash, consider trying them out.
For this example we will also only be using layer 1. Using the oval tool draw out a circle of any colour and convert it to a movie clip. NOTE: I am only using a circle as an example, this would be your character. Now double click on your character. Start by right clicking on frame 1, and selecting actions. On the first line type in: stop();
Now insert a keyframe at frame 2. On frame 2 we need to put in the words that we want our character to say. Using the text tool (static text), insert a text box just above his head, for this example I want him to say: learningflashpro.blogspot.com.
I want the player to have enough time to read this, so I inserted a keyframe at frame 40. (this may be different for you, if you only have a short sentence like mine, use about 40 frame, otherwise just muck around with it until it is right).
On the last keyframe, in my case this would be frame 40, right click and select actions, now on the first line type in:
gotoAndStop(1);
This is so when this frame is reached it will go back to frame 1 where there is no text.
Back in the main timeline, make a cursor(do this by following the steps in tut.16).
Now we need to add some action to the character, right click on your character and select actions, on the first line type in:
onClipEvent(mouseDown) {
if(this.hitTest(_root.cursor)) {
this.gotoAndPlay(2);
}
}
This means that when the mouse has been pressed down the character movie clip will play.
That is it, pretty easy wasn’t it?
NOTE: to advance on this tutorial try instead of just using text, change it to audio.
Remember that you will need to insert a new layer to do this.
By now you should have the knowledge to do this, if not, I recommend that you go over some of the previous tutorials.
For further reference: the ads on this site contain great things about flash, consider trying them out.
How to add an inventory to your game
Making an Inventory
This is rather easy to achieve, and a lot of Role Playing Games(rpg) games have inventories. Here is how you make one.
We will only be using layer 1 for this tutorial.
We will start by making our custom cursor.
Draw out a small circle on the stage(any colour), convert it to a movie clip and name it cursor.
Now give the cursor an instance name of cursor. Now right click on the first frame of layer 1 and select actions, now on the first line type in the following:
Mouse.hide();
cursor.onMouseMove = function() {
this._x=_xmouse, this._y=_ymouse;
};
As we know this makes the mouse hidden and allows you to move the cursor whenever you move the mouse.
Now draw out a box using the rectangle tool, make the stroke colour black, and no fill. Using the text tool, (static text) draw out a text box underneath or above that box and type in Inventory.
This is obviously so the player knows what this box is.
Now draw a small black square using the rectangle tool and convert it to a movie clip, name it item. Right click on the black box and select copy, now paste that copy, and move it inside the box. Resize it if needed so that it fits in the box. Now give it an instance name of invitem. Change the alpha of this item to 0, this was explained in a previous tutorial.
The item in the inventory box should now be invisible. If so move on to the next step.
Right click on the visible box and select actions, now on the first line type in the following:
onClipEvent(enterFrame) {
if(this.hitTest(_root.cursor)) {
this._alpha=0;
_root.invitem._alpha=100;
}
}
Now what this means is if the box that is visible represented by “this” collides with the cursor. The visible box’s alpha will go to zero “this._alpha=0;” and the other box’s alpha will go to 100 “_root.invitem._alpha=100;”.
Test the movie, now when you are move the mouse over the visible box it will become invisible and the other one will appear.
FAQ’s ABOUT THIS TUTORIAL:
Q. Why have you used the code “this” and not the name of the box?
A. As I am applying the actions to the movie clip itself, I only need to put this, as I am talking about this item that I am applying the actions to.
Q. Why do you need to put onClipEvent (enterFrame)?
A. I need to put onClipEvent as I am applying these action to a movie clip. I have put enterFrame as I want this to happen when the frame is entered. I could have changed this mouseDown which would mean when the mouse is down.
This is rather easy to achieve, and a lot of Role Playing Games(rpg) games have inventories. Here is how you make one.
We will only be using layer 1 for this tutorial.
We will start by making our custom cursor.
Draw out a small circle on the stage(any colour), convert it to a movie clip and name it cursor.
Now give the cursor an instance name of cursor. Now right click on the first frame of layer 1 and select actions, now on the first line type in the following:
Mouse.hide();
cursor.onMouseMove = function() {
this._x=_xmouse, this._y=_ymouse;
};
As we know this makes the mouse hidden and allows you to move the cursor whenever you move the mouse.
Now draw out a box using the rectangle tool, make the stroke colour black, and no fill. Using the text tool, (static text) draw out a text box underneath or above that box and type in Inventory.
This is obviously so the player knows what this box is.
Now draw a small black square using the rectangle tool and convert it to a movie clip, name it item. Right click on the black box and select copy, now paste that copy, and move it inside the box. Resize it if needed so that it fits in the box. Now give it an instance name of invitem. Change the alpha of this item to 0, this was explained in a previous tutorial.
The item in the inventory box should now be invisible. If so move on to the next step.
Right click on the visible box and select actions, now on the first line type in the following:
onClipEvent(enterFrame) {
if(this.hitTest(_root.cursor)) {
this._alpha=0;
_root.invitem._alpha=100;
}
}
Now what this means is if the box that is visible represented by “this” collides with the cursor. The visible box’s alpha will go to zero “this._alpha=0;” and the other box’s alpha will go to 100 “_root.invitem._alpha=100;”.
Test the movie, now when you are move the mouse over the visible box it will become invisible and the other one will appear.
FAQ’s ABOUT THIS TUTORIAL:
Q. Why have you used the code “this” and not the name of the box?
A. As I am applying the actions to the movie clip itself, I only need to put this, as I am talking about this item that I am applying the actions to.
Q. Why do you need to put onClipEvent (enterFrame)?
A. I need to put onClipEvent as I am applying these action to a movie clip. I have put enterFrame as I want this to happen when the frame is entered. I could have changed this mouseDown which would mean when the mouse is down.
How to make a shooting game
Making a Shooting Game(tut.15)
I would certainly suggest to those of you who would like to make games using flash to take this tutorial. It only a simple tutorial, but it will help those people beginning in this field of flash, and give them a better understanding.
Let’s start by inserting the following layers:
Actions- adds interaction to the game
Crosshair- so the player knows where they are shooting
Score- this is so the player can see how well they are doing
Enemy- this is what the player is to shoot, each time they hit it, the score goes up by 1.
Restart- this is so the player can play the game again if they want to
We are going to start by making the crosshair, this is very easy. Select the stroke color and set it to red, and set the fill color to no fill.
Making sure you have the oval tool selected, in the properties inspector, change the stroke height to about 2.75.
Now draw out a circle on the stage, (remember that this will be the custom cursor, so don’t make it too big).
Now select the line tool and draw a cross in it, hence the name crosshair.
Now select the whole crosshair and convert it to a movie clip naming it crosshair, also give it an instance name of crosshair in the properties inspector.
Now on the first frame of the actions layer, right click and select actions. On the first line type in:
Mouse.hide();
crosshair.onMouseMove = function() {
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent;
};
This was discussed in a previous tutorial.
Now for the enemy, for this example let’s just use a black circle to practice with.
Ensure that the enemy layer is below the crosshair layer otherwise the crosshair will appear behind the enemy.
Using the oval tool draw out a black circle on the stage, convert this in to a movie clip and name it enemy.
Now right click on the enemy and select actions, on the first line type in:
onClipEvent(mouseDown) {
if(this.hitTest(_root.crosshair)) {
_root.score+=1;
}
}
This means that if the crosshair is over the enemy and the mouse is clicked the score will go up by one. This was explained in more detail in a previous tutorial.
Now for the score. Select the text tool, in the properties inspector set it to dynamic text. Now draw out a text box in the top centre of the stage, now give it a var of score. It would also be a good idea to set the text so that it is aligned in the centre of the text box. Do this by selecting the option in properties inspector align centre.
In the first frame of the actions layer type this underneath the code that is already there:
var score = 0;
As we know this sets the score to zero.
Now in the following layer insert a keyframe at frame 206.
Actions
Score
Crosshair
Restart
At frame 205 of the enemy layer insert a keyframe
Here is where we want the final score to be displayed. Start by moving the score on frame 206 to the centre and enlarging the text size, only on the last keyframe(206). Make sure the score has not changed in the other keyframes.
Now above the score in frame 206 on the score layer, insert a static text box above it that says: Your Score:
This is so the player knows that the number on the screen is what they scored.
On the last key frame of the actions layer, right click and select actions, on the first line type in:
Stop();
This is so the game stops here for the player to read their score.
Last but no least we want to add a restart button to restart the game.
On the last keyframe of the of the restart layer, using the oval tool draw out a circle and write restart inside of it using either the brush tool or the text tool.
Convert this to a button naming it restart.
Right click on the button and select actions, now on the first line type in:
on (release) {
gotoAndPlay(1);
}
This means that when this button is clicked on the, flash will go back to frame 1 and play from there again.
There you go, your very first game, as simple as it is, you have to start somewhere.
NOTE: MAKE SURE THE ENEMY IS NOT DISPLAYED ON THE LAST KEYFRAME, OTHERWISE THE PLAYER CAN CONTINUE TO CLICK ON THE ENEMY AND THEIR SCORE WILL KEEP GOING UP.
I would certainly suggest to those of you who would like to make games using flash to take this tutorial. It only a simple tutorial, but it will help those people beginning in this field of flash, and give them a better understanding.
Let’s start by inserting the following layers:
Actions- adds interaction to the game
Crosshair- so the player knows where they are shooting
Score- this is so the player can see how well they are doing
Enemy- this is what the player is to shoot, each time they hit it, the score goes up by 1.
Restart- this is so the player can play the game again if they want to
We are going to start by making the crosshair, this is very easy. Select the stroke color and set it to red, and set the fill color to no fill.
Making sure you have the oval tool selected, in the properties inspector, change the stroke height to about 2.75.
Now draw out a circle on the stage, (remember that this will be the custom cursor, so don’t make it too big).
Now select the line tool and draw a cross in it, hence the name crosshair.
Now select the whole crosshair and convert it to a movie clip naming it crosshair, also give it an instance name of crosshair in the properties inspector.
Now on the first frame of the actions layer, right click and select actions. On the first line type in:
Mouse.hide();
crosshair.onMouseMove = function() {
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent;
};
This was discussed in a previous tutorial.
Now for the enemy, for this example let’s just use a black circle to practice with.
Ensure that the enemy layer is below the crosshair layer otherwise the crosshair will appear behind the enemy.
Using the oval tool draw out a black circle on the stage, convert this in to a movie clip and name it enemy.
Now right click on the enemy and select actions, on the first line type in:
onClipEvent(mouseDown) {
if(this.hitTest(_root.crosshair)) {
_root.score+=1;
}
}
This means that if the crosshair is over the enemy and the mouse is clicked the score will go up by one. This was explained in more detail in a previous tutorial.
Now for the score. Select the text tool, in the properties inspector set it to dynamic text. Now draw out a text box in the top centre of the stage, now give it a var of score. It would also be a good idea to set the text so that it is aligned in the centre of the text box. Do this by selecting the option in properties inspector align centre.
In the first frame of the actions layer type this underneath the code that is already there:
var score = 0;
As we know this sets the score to zero.
Now in the following layer insert a keyframe at frame 206.
Actions
Score
Crosshair
Restart
At frame 205 of the enemy layer insert a keyframe
Here is where we want the final score to be displayed. Start by moving the score on frame 206 to the centre and enlarging the text size, only on the last keyframe(206). Make sure the score has not changed in the other keyframes.
Now above the score in frame 206 on the score layer, insert a static text box above it that says: Your Score:
This is so the player knows that the number on the screen is what they scored.
On the last key frame of the actions layer, right click and select actions, on the first line type in:
Stop();
This is so the game stops here for the player to read their score.
Last but no least we want to add a restart button to restart the game.
On the last keyframe of the of the restart layer, using the oval tool draw out a circle and write restart inside of it using either the brush tool or the text tool.
Convert this to a button naming it restart.
Right click on the button and select actions, now on the first line type in:
on (release) {
gotoAndPlay(1);
}
This means that when this button is clicked on the, flash will go back to frame 1 and play from there again.
There you go, your very first game, as simple as it is, you have to start somewhere.
NOTE: MAKE SURE THE ENEMY IS NOT DISPLAYED ON THE LAST KEYFRAME, OTHERWISE THE PLAYER CAN CONTINUE TO CLICK ON THE ENEMY AND THEIR SCORE WILL KEEP GOING UP.
How to make a time limit
Making a Countdown Timer
This tutorial is only a short and simple one.
Start by naming layer 1 counter, insert another layer and name it actions. Right click on frame 1 and select actions. On the first line type in:
Stop();
We need to do this as we will have 2 frame and we want it to stop on frame 1 as this is where a countdown will be.
On the first frame of the counter layer draw out a basic shape with a fill colour (recommended). This is going to hold the countdown time. Select the whole shape you just made and convert it to a Movie Clip, name it time control. The reason we will be naming it time control is we are going to use this to control the countdown.
Select the text tool and same as before make sure it is set to dynamic text, now change the font colour to a different colour to what the time control is, otherwise you won’t be able to see the countdown.
Now draw out the text box on top of the time control movie clip.
Give the countdown a var of countdown, var was discussed in a previous tutorial.
Now double click on the time control movie clip to enter its timeline.
Here is where we will set the speed of the countdown. First of all, check to see what your fps is set to, it is set to 12 by default, so I will use twelve. The fps was discussed in a previous tutorial. Now I want my countdown to go down a number every second, so I am going to insert a keyframe at frame 13. I realize I said 13 and not twelve. Why I did this: If you look at the bar underneath the timeline where it displays how many seconds into the timeline you are, you’ll see that at the 12th frame it is .9 sec, and at the 13th frame it is exactly 1 second.
Now right click on the 13th frame which is the last keyframe, and select actions.
Now on the first line type:
_root.counter -= 1;
This simply means that every time this frame is played the countdown will go down by one. The reason we have put _root because we are referring to the timeline.
Note: Before the = sign there is a minus “-“ you cannot see it very well.
Now click on scene 1 to enter the main timeline.
Right click on the first frame in the action layer, and select action, underneath stop(); type in:
var counter = 10;
This sets the counter to start at ten.
Now right click on the time control and select actions, on the first line type in:
onClipEvent (enterFrame) {
if (_root.counter == 0) {
_root.gotoAndStop(2);
}
}
The reason we have put clip event is because we have applied these actions to a movie clip.
enterFrame means when the frame is entered, so you won’t have to press any buttons, it will just happens when the countdown reaches zero.
if (_root.counter == 0) {
_root.gotoAndStop(2);
}
}
This simply means when the counter reaches zero, it is to go to frame 2 and stop at frame 2.
Now close the actions menu. Insert a keyframe at the second keyframe of the counter layer, on the second keyframe, delete everything.
Now using the brush tool or the text tool write something like time up.
Now test the movie, the countdown will start running from 10 down to 0, when it reaches zero it will say time up.
Don’t worry is this tutorial was a little confusing, it will all come with time until you understand what all this AS2 means. We will be working with it a fair bit in later tutorials.
Before moving on to the next tutorial, have a play around in flash, creating some flash animations, testing out the simple AS2 we have recently learnt, think of this as revision, but have fun with this.
Tip 8. Have fun when using flash.
Why this helps: It is obvious, if you are creating things in flash that you find boring you lose interest, so if you are working on something in flash that is getting boring, try think of something you could add to this to make it fun.
Tip 9. Muck around in flash often exploring new things.
Why this helps: This is how we find out new things, improve our flash projects, get better at using flash.
Alright, let’s start our next tutorial.
How to make a 'scared ya' maze game
This video includes a section showing you how to add a 'scared ya' part, simply ignore this part if you want it just to be a normal game.
Making your first game
We will be making our first game in this tutorial. Even if you have no interest in making games with flash, I recommend that you take this tutorial as it will expand on your knowledge and skills in flash, this will help with your creativity just as much as making a mini movie.
Okay let’s start. This is going to be a very simple game as this is our very first tutorial on game making, but this will be good for your skills in using flash.
Rename layer 1 to score. This will be our score layer, every game needs a score.
Now insert another layer and name it actions. Insert one more layer and name it enemy. Ok, that is all the layers we will need for our first game. Let’s start with our score layer. Start by selecting the text tool, in the properties inspector, change the box that says static text to dynamic text, now draw out a text box that would hold about three digits. Make the text size about 70 to 80. Move the text box the top of the stage and position it in the centre. Now back in the properties inspector of the text box you will see a little box that says var, if you do not see this box, click on the little down arrow in the lower right and corner of the properties inspector. Now in the box where it says var, type in “score”, without the quotations.
This is so that we can communicate with this text box through AS2.
On the first and only frame of the actions layer right click and select actions.
Now on the first line type in:
var score = 0;
what this does it sets the score to zero, as we gave the text box a variable of score, flash knows that we want this to be set to zero, var is short for variable.
Now on the enemy layer draw out a circle or any simple shape, and convert it to a button, and name it enemy.
Now right click on the button and select actions, on the first line type in:
on (release) {
score += 1;
}
We already know what the on (release) means as it was discussed in a previous tutorial. score+=1; simple means when the button is clicked on the score is to go up by one. If we were to change the 1 to a 6 it would go up by 6. {} these simply define that these are the action to do when the button has been clicked on.
Now test the move, click on the button, each time you click on the button the score will go up by 1. Great work, you have made a 5 star game, should sell for millions. This is a very basic tutorial on game making, but further on, I will make more advanced tutorials for those of you who would be interested.
Now, although this tutorial was not important to all of you, it is still good to take it anyway, as I said, it introduces you to the different areas of flash, understanding this will help you greatly.
Next we will be making a timer that counts down form 10 to 0, when the timer reaches 0 it will go to the next frame and stop. This tutorial is not really important, but I would recommend taking it anyway, just to understand it a bit more. I want to introduce you to some very back AS2.
Subscribe to:
Posts (Atom)