SOLVED: Disable keyboard movement during events

Started by Slasher, Sat 13/10/2012 08:44:46

Previous topic - Next topic

Slasher

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
} 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
}
  
   // 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.





Khris

Add this to room 2's script:
Code: ags
void on_keypress(eKeyCode k) {
  if (object[3].Animating) ClaimEvent();
}

Slasher

Many thanks Khris

I had a feeling it may be something like that.

cheers

SMF spam blocked by CleanTalk