eKey question

Started by geork, Thu 28/05/2009 14:26:00

Previous topic - Next topic

geork

 Hey all
   I am trying to make something happen when the user presses a key, and only for that room. I got the code and the claim event, but apparentely I need to include a function or something (the index wasn't clear): on_key_press. how do I create a code that only works for that room? I tried:
Code: ags
 if(keycode == eKeyRightArrow){
    cEgo.Walk(cEgo.x - 40, cEgo, eBlock, eWalkableAreas);
    ClaimEvent();
  }
 
, but it didn't recognize 'keycode'
        thanks

Matti

#1
Try:

Code: ags

if (IsKeyPressed(377) == 1){
  cEgo.Walk(cEgo.x - 40, cEgo, eBlock, eWalkableAreas);
  ClaimEvent();
}


377 is the ASCII-code for the right arrow. The Code table can be found in the manual.

But is the player supposed to go to the left when the player uses the right arrow key?

geork


Trent R

Code: ags
function on_key_press(eKeyCode keycode) {
  if(keycode == eKeyRightArrow){
    cEgo.Walk(cEgo.x - 40, cEgo, eBlock, eWalkableAreas);
    ClaimEvent();
  }
}


Should work just fine... And IsKeyPressed AKAIK is basically used for rep_exec events.


~Trent


To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk