Hi guys,
Is there a functionality here in AGS that checks for a keypress regardless of what key was pressed? For example, if I want to skip a cutscene, pressing any key would skip it.
Although I can just manually list down all the keys on the keyboard if ( IsKeyPressed(eKeyA) && IsKeyPressed(eKeyB... and so on) but I was wondering if there was an easier way of doing this?
Thanks!
First of all, you can set what's going to skip a cutscene using the parameter:
StartCutscene(eSkipAnyKey);
If you need to do it with IsKeyPressed(), you can iterate through the ascii codes:
bool IsAnyKeyPressed() {
int i = eKeySpace; // 32
while (i <= eKeyUnderscore) { // 95
if (IsKeyPressed(i)) return true;
i++;
}
return false;
}
Import it in the header (Global.ash):
import bool IsAnyKeyPressed();
This covers most of the keypresses that generate characters. You can look up the rest here (http://www.adventuregamestudio.co.uk/manual/ASCIIcodes.htm).
Why not just use the on_key_press function?
function on_key_press(eKeyCode keycode)
{
// A KEY WAS PRESSED!!
}
Now on_key_press isn't fired for some of the keycodes that can be detected by IsKeyPressed, but for what you actually need.
If you need any keycode, even during blocking interactions, including things like Alt-combinations, I wrote a module for that, but it might not play nicely with the built-in on_key_press..I forget, but I think I was planning to update it to make it more useful. In any case, I'd say that you can probably just use the existing built-in function.