[SOLVED] Process Key Events in Pause Game GUI

Started by omegamit6zeichen, Sun 06/07/2014 11:44:37

Previous topic - Next topic

omegamit6zeichen

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

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

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


Khris

If you look at a Default game's on_key_press function, you'll find this:
Code: ags
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
}

omegamit6zeichen

i've never felt so stupid in my whole life... <.<
ty ....

SMF spam blocked by CleanTalk