Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.18 / 5.00 3,534 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.80 / 5.00 4,200 ViewsHey guys my first topic post here.
I'm making a flash game at the moment and I was wondering how I could have a "pause" button in the game, so the enter frame functions of some mcs would be temporarily disabled. Any ideas on how I would do this?
At 10/15/12 03:10 PM, MoArman wrote: Hey guys my first topic post here.
I'm making a flash game at the moment and I was wondering how I could have a "pause" button in the game, so the enter frame functions of some mcs would be temporarily disabled. Any ideas on how I would do this?
General answer is to disable everything that is running that you don't want to run anymore. You are the only one who knows what's running and what you don't want to run when "pause" is triggered.
You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.
At 10/15/12 03:10 PM, MoArman wrote: Hey guys my first topic post here.
I'm making a flash game at the moment and I was wondering how I could have a "pause" button in the game, so the enter frame functions of some mcs would be temporarily disabled. Any ideas on how I would do this?
welcome :)
your post doesn't give very much information. The first thing i'm going to ask about is what language you're making your game in. AS2 or AS3?
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 10/15/12 03:10 PM, MoArman wrote: Hey guys my first topic post here.
I'm making a flash game at the moment and I was wondering how I could have a "pause" button in the game, so the enter frame functions of some mcs would be temporarily disabled. Any ideas on how I would do this?
Heya,
stage.addEventListener(Evenet.ENTER_FRAME, onFrame, false, 0, true);
when you want to pause-
stage.removeEventListener(onFrame);
unpause-
stage.addEventListener(Evenet.ENTER_FRAME, onFrame, false, 0, true);
:D
At 10/15/12 03:20 PM, CharlieSimpson wrote: stage.removeEventListener(onFrame);
That depends on a lot of variables.
1) That he's using AS3
2) That he's putting his entire game loop in one function
3) That he's not using some external stuff like TweenLite
4) That he doesn't have other enterFrame listeners elsewhere.
besides, there's a better way to pause with AS3, anyway.
Just set the framerate to 0.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 10/15/12 03:20 PM, CharlieSimpson wrote: stage.addEventListener(Evenet.ENTER_FRAME, onFrame, false, 0, true);
ieee! You shouldn't be using "stage.", anyway. That's like using "_root." everywhere in AS2.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 10/15/12 03:28 PM, egg82 wrote:At 10/15/12 03:20 PM, CharlieSimpson wrote: stage.removeEventListener(onFrame);That depends on a lot of variables.
1) That he's using AS3
2) That he's putting his entire game loop in one function
3) That he's not using some external stuff like TweenLite
4) That he doesn't have other enterFrame listeners elsewhere.
besides, there's a better way to pause with AS3, anyway.
Just set the framerate to 0.
hehe, zzzzzzzzz....... he asked a simple question I gave a simple answer I said "stage" because I dont know which variables/classes he's using and a universally known reference is "stage".... of course one can change the reference of the listnener. If anyones using more than one ENTER_FRAME event...they shouldn't, if anyone ever uses a tween....they shouldn't. The last one...setting your frame rate to zero will make everything not work, when you set your frame rate to 0 it actually sets it to like 0.001 or something which is not pausing a game as the game will still be running, just very slowly and if you leave for an extended period of time can cause problems.
:D
At 10/15/12 03:19 PM, egg82 wrote:
welcome :)
your post doesn't give very much information. The first thing i'm going to ask about is what language you're making your game in. AS2 or AS3?
I'm using AS2.
At 10/15/12 03:47 PM, MoArman wrote: I'm using AS2.
onEnterFrame = null;
You should really learn As3, so you can translate the advices and snippets you receive into your outdated language.
At 10/15/12 03:47 PM, CharlieSimpson wrote: hehe, zzzzzzzzz....... he asked a simple question I gave a simple answer I said "stage" because I dont know which variables/classes he's using and a universally known reference is "stage"....
you shouldn't ever have to use "stage." or "_root." - that's my point.
of course one can change the reference of the listnener. If anyones using more than one ENTER_FRAME event...they shouldn't,
I see a few reasons to use more than one ENTER_FRAME listener. It's not common to do so, but it has its uses nontheless.
if anyone ever uses a tween....they shouldn't.
Um... What?
The last one...setting your frame rate to zero will make everything not work, when you set your frame rate to 0 it actually sets it to like 0.001 or something which is not pausing a game as the game will still be running, just very slowly and if you leave for an extended period of time can cause problems.
may or may not happen, but that plus a big "unpause" button covering the screen is more universal than removing an event listener.
anyway, in order to truly put your game on pause you're going to have to add a boolean to your classes and check that boolean on every event fire.
Or remove the events and put them back in place. Your call, really.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 10/15/12 04:32 PM, egg82 wrote: you shouldn't ever have to use "stage." or "_root." - that's my point.
I suppose I shouldn't say "ever" (in the case of stage.frameRate and adding keyboard event listeners, etc) but you get what i'm saying.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
Accessing parents from children is a bad idea, this include nearly all references to stage or _root, as for a pause button, long story short, unless you have been putting all your code very neatly on the timeline or in classes then it's not going to be possible.