Skip navigation
Currently Being Moderated

Pausing/Resuming a game in AS3

Aug 30, 2012 2:42 PM

Tags: #flash #as3 #button #actionscript3

Hey everyone,

I'm currently working on making a game for Android and IOS, and I want to know the easiest code to pause all entities within the game except sound. When you click pause, I want it to bring up a pause screen, pausing the game and then displaying the pause screen that has Sound FX and Music options as well as a resume button.

 

When clicking the resume button, the pause screen goes away and the game is then resumed.

 

Can anyone help me out?!

 
Replies
  • Currently Being Moderated
    Aug 30, 2012 3:52 PM   in reply to CoreyGKing

    to pause

     

    Stage.frameRate = 0

     

     

    to resume

     

     

    Stage.frameRate = 14 // or the frame rate original

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 30, 2012 4:09 PM   in reply to CoreyGKing

    yourButton.addEventListener(MouseEvent.CLICK, pauseGame);

    function pauseGame(e:MouseEvent):void{

         Stage.frameRate = 0;

    }

     

    yourOtherButton.addEventListener(MouseEvent.CLICK, resumeGame);

    function resumeGame(e:MouseEvent):void{

         Stage.frameRate = 15;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 31, 2012 11:15 AM   in reply to CoreyGKing

    Sorry

     

     

    yourButton.addEventListener(MouseEvent.CLICK, pauseGame);

    function pauseGame(e:MouseEvent):void{

         stage.frameRate = 0;

    }

     

    yourOtherButton.addEventListener(MouseEvent.CLICK, resumeGame);

    function resumeGame(e:MouseEvent):void{

         stage.frameRate = 15;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 28, 2012 5:28 AM   in reply to CoreyGKing

    hi..can i know how you pause the game and and then displaying the pause screen that has Sound FX and Music options as well as a resume button?

     
    |
    Mark as:
  • kglad
    62,007 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 28, 2012 8:04 AM   in reply to vinnchow

    first display your pause screen and then assign the frameRate stage property.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 29, 2012 1:57 AM   in reply to kglad

    i success to do it.But now i got another problem. now i doing a game like the player need dodge the falling stone(i animate it in timeline) from sky...and when get hited, the health bar will decrease. However, when i duplicate the stone into 3 stones, when hit the player, player only will decrease health bar life with among one stone only. Can i know why this happening?why other 2stones not working??
    thanks a lot..

     
    |
    Mark as:
  • kglad
    62,007 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 29, 2012 7:17 AM   in reply to vinnchow

    start a new thread for new issues.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 13, 2013 3:33 AM   in reply to CoreyGKing

    I keep getting ths error, do i need to import particular classes?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points