• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Game development: how to pause a game?

Community Beginner ,
Aug 18, 2012 Aug 18, 2012

Copy link to clipboard

Copied

How to pause a game in order to open my inventory panel? I always think of destroying all objects, removing from stage and instantiating and adding to stage all again. But I don't know if I am going to waste my time doing that the hard way. I would like to know a reliable manner and easy maintenance way to do this.

Thanks in advance.

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 18, 2012 Aug 18, 2012

Copy link to clipboard

Copied

You need to stop code that is continuously processing.  If you have a Timer running that controls activity, then you need to stop the Timer.  If you have an ENTER_FRAME event listener active, you need to deactivate it...  and so on with anything else that is running by itself.

Another option would be to build conditional code into the event handler functions that only allows the functions to process based on a boolean value... such as you create a boolean variable named "gamePaused" and then in your code where you need to have automatic activity occuring you use it as a precodnition...

    if(!gamePaused){   

         // process activity

    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2012 Aug 18, 2012

Copy link to clipboard

Copied

LATEST

actually, you can just toggle your frame rate to pause and unpause your game:

var frame_rate:int=stage.frameRate.

function pause_unpauseF():void{

if(stage.frameRate<1){

stage.frameRate=frame_rate;

} else{

stage.frameRate=0;

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines