Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Sat 13/10/2012 08:44:46

Title: SOLVED: Disable keyboard movement during events
Post by: Slasher on Sat 13/10/2012 08:44:46
Came a cross a snag.

I have an animation event start after conditions are met. During these events the mouse is disabled (invisible).
Once the event is over the mouse is returned visible.

However, keyboard movement can still be made and I need to disable any attempt to move the player.

How can I stop keyboard movements of the player until after the events and the player can again move?

Would a way be to put a condition in global if a key is pressed ie arrow L R U D and if bool false?

Or is there a in Room script I can use;

Here is the start of events:

Code (AGS) Select
} else if (reels ==4 && loom==true && ohandle.Graphic==256)
{
   
  oloom.SetView(14);
  oloom.Animate(0, 2, eRepeat, eNoBlock);
  SetTimer(1, 100);
  cELF.LockView(10);
  cELF.Animate(0, 4, eRepeat, eNoBlock);
  mouse.Visible=false; // NO MOUSE WITH THIS EVENT. BACK ON AFTER EVENT WHICH IS ON TIMERS.
  usedloom=true;
  ohandle.Graphic=257;
  }
 


If you can assist I would be grateful.

------------------------------------------

EDIT: This seems to work:

Code (AGS) Select
}
 
   // STOP PLAYER MOVING IF LOOM ANIMATING
 
  if (keycode == eKeyLeftArrow && cELF.Room==2 && object[3].Animating)
   cELF.StopMoving();
 
  if (keycode == eKeyRightArrow && cELF.Room==2 && object[3].Animating)
   cELF.StopMoving();
   
    if (keycode == eKeyUpArrow && cELF.Room==2 && object[3].Animating)
   cELF.StopMoving();
 
  if (keycode == eKeyDownArrow && cELF.Room==2 && object[3].Animating)
   cELF.StopMoving();


Still open if there is another way.




Title: Re: SOLVED: Disable keyboard movement during events
Post by: Khris on Sat 13/10/2012 12:01:51
Add this to room 2's script:
Code (ags) Select
void on_keypress(eKeyCode k) {
  if (object[3].Animating) ClaimEvent();
}
Title: Re: SOLVED: Disable keyboard movement during events
Post by: Slasher on Sat 13/10/2012 12:38:02
Many thanks Khris

I had a feeling it may be something like that.

cheers