Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: omegamit6zeichen on Sun 06/07/2014 11:44:37

Title: [SOLVED] Process Key Events in Pause Game GUI
Post by: omegamit6zeichen on Sun 06/07/2014 11:44:37
Hi,
i am new to AGS (v.3.3) and for our game i'm currently trying to make a screen which appears when pressing esc, and disappears when pressing it again.
So far so good, i made a little gui, and a method for toggling the visibility
Code (ags) Select

function ToggleIngameGui()
{
   if(PauseGui.Visible == false)
    {
   
    PauseGui.SetSize(300, 1);
    PauseGui.LockView(3);
   
    PauseGui.Visible=true;
    PauseGui.Animate(0, 3, eRepeat, eNoBlock);
    PauseGui.TweenSize(1.0, 300, 400, eEaseInTween, eNoBlockTween);
    PauseGui.TweenTransparency(1.0, 0, eEaseInTween, eNoBlockTween);
    }
    else
    {
      PauseGui.StopAllTweens(eFinishTween);
     
      PauseGui.TweenSize(1.0, 300, 1, eEaseOutTween, eNoBlockTween);
      PauseGui.TweenTransparency(1.0, 100, eEaseInTween, eNoBlockTween);
      WaitSeconds(1.0);
      PauseGui.UnlockView(true);
      PauseGui.Visible=false;
    } 
}


but when the gui appears the game is stopped (visibility = Pause game when shown)

and now the on_key_press event in the global script will not be executed (which is on purpose i think).
Is there some way to catch the event for the gui itself? .. the only thing i have is a very ugly workaround in the repeatedly_execute function ...
Code (ags) Select

function repeatedly_execute()
{
  //ugly workaround
  if((IsGamePaused() == 1) && (PauseGui.Visible == true))
  if (IsKeyPressed(27) == 1)
  if(PauseGui.Height == 400)
  {
    ToggleIngameGui();
    Wait(100);
  }
 
}

Title: Re: Process Key Events in Pause Game GUI
Post by: Khris on Sun 06/07/2014 14:17:52
If you look at a Default game's on_key_press function, you'll find this:
Code (ags) Select
function on_key_press(eKeyCode keycode) {
  // The following is called before "if game is paused keycode=0", so
  // it'll happen even when the game is paused.

  ... // lots of code for keys that work when game is paused here 

  if (IsGamePaused() || (IsInterfaceEnabled() == 0))
  {
    // If the game is paused with a modal GUI on the
    // screen, or the player interface is disabled in
    // a cut scene, ignore any keypresses.
    return;
  }

  ... // keys that should not work while game is paused here
}
Title: Re: Process Key Events in Pause Game GUI
Post by: omegamit6zeichen on Sun 06/07/2014 16:49:49
i've never felt so stupid in my whole life... <.<
ty ....