How do I prevent button presses from repeating? [SOLVED]

Started by Melissa, Mon 01/04/2013 19:18:52

Previous topic - Next topic

Melissa

I know that someone has already posted this question:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=32121.msg414514

But I couldn't implement khris' code, the process keeps repeating itself when I keep the key pressed

Code: ags
bool down;

//rep_ex

  if (IsKeyPressed(32)) {
    if (!down) {
      down=true;
      // do stuff
    }
  }
  else down=false;


Thank you for helping me :wink:

Khris

Did you put the line "bool down;" above the repeatedly_execute function?

Code: ags
bool down;

function repeatedly_execute() {

  if (IsKeyPressed(32)) {
    if (!down) {
      down=true;
      // do stuff
    }
  }
  else down=false;
}

Melissa

#2
Quote from: Khris on Mon 01/04/2013 19:30:03
Did you put the line "bool down;" above the repeatedly_execute function?

Code: ags
bool down;

function repeatedly_execute() {

  if (IsKeyPressed(32)) {
    if (!down) {
      down=true;
      // do stuff
    }
  }
  else down=false;
}

Ups! :shocked:

Thank you again Khris!

SMF spam blocked by CleanTalk