|
-
This would go on the frame where the "main" game is. Just to clear a few things up..
There isn't a sort of built in pause function within flash.. if you want a pause button in a game, you have to factor in absolutely everything that's going to stop when you press it. The variable "gamePaused" is just a name, it won't do anything until you tell the rest of your movie to respond to it.
So if you have a shooting game for example:
You have a function called "enemies", this might spawn an enemy in a random location when called.
You may also have a function called "shoot", this could be called when the mouse button is pressed and would fire a bullet and start a gun sound for example.
Now to effectively pause this game, you would have to disable both of those functions while the var "gamePaused" is true.. Assuming you have a movieclip that covers the whole stage, the first frame would be blank and the second frame would say "Paused" and cover the screen. This movie clip should stop on the second frame when "gamePaused" is true.
So back to the functions; The simplest way would be to write a condition at the top of each function which would be tested before the rest of the code in the function is executed:
function enemy(){
if(!gamePaused){
//enemy code
}
}
function shoot(){
if(!gamePaused){
//shooting code
}
}
So when either function is called, flash checks that the game isn't paused before it executes any of the code. If gamePaused is false (game is not paused) - it will continue with the function as normal. If gamePaused is true (game is paused) - it does nothing.
This is very simple example but should help you understand how a pause button would work. In a large, complex game, it'd be a lot of work. It's best to code with it in mind from the very beginning as it 'd be near impossible to slap in a pause button once it was nearing completion.
Last edited by lightspeed10; 02-09-2010 at 07:36 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|