How can I build a check (I guess it needs to be in repeat exec.) that checks whether the
escape button is pressed or not even when fade-in or fade-out of a room is happening?
This part works but not when fading in or out of a room, only when a room is normally show:
------------------------------------------------------------------------------------------
function on_key_press(eKeyCode keycode) {
// FUNCTION KEYS AND SYSTEM SHORTCUTS
if (keycode == eKeyEscape) {
// ESC
mouse.Visible = true;
QuitGame(1);
mouse.Visible = false;
------------------------------------------------------------------------------------------
Thanx.
I guess you should rather check inside "before fade in" function using IsKeyPressed.
In this situation, lot's of random rooms are shown.
During this being shown, I'd like to be able to check if the Esc button has been hit, also during the fading between the rooms.
"On_key_press" is used but only works when before and after the fading.
Is there another way then adding the "enter room before fade in" options of all these rooms
in order to get this esc-button check working during fading?
Hmm... what about putting the IsKeyPressed check into global repeatedly_execute function?
You can use the "on_event" function to capture fade ins and fade outs for every room.
This still doesn't work when the fadeout starts...:
Can't find an event for when the fadeout has started already.
function on_event(EventType event, int data) {
if (event == eEventEnterRoomBeforeFadein) {
if ((data >= 1) && (data <= 10)) { // only set the timer for the rooms that are going to use it
SetTimer(1, GetGameSpeed() * sldSpeed.Value);
}
else SetTimer(1, 0); // disable the timer for other rooms
}
if (event == eEventEnterRoomBeforeFadein) {
if (IsKeyPressed(eKeyEscape)){
mouse.Visible = true;
QuitGame(1) ;
mouse.Visible = false;
if (event == eEventLeaveRoom){
if (IsKeyPressed(eKeyEscape)){
mouse.Visible = true;
QuitGame(1) ;
mouse.Visible = false;
}
}
}
}
}
on_event and room_Load are only run once; the check must be inside a function that runs repeatedly.
Not sure if it's possible to catch keypresses during fading.
Have you tried checking in repeatedly_execute_always? I think it's your best shot...
If tried the function repeatedly_execute() but that only works when there's no fading...
So like Khris said, I'm not sure if there a way to catch keypressing during fading.
eEventEnterRoomBeforeFadein sometimes seems to work.
So I can't find a way to catch the keypress when having a fade-out plus
the eEventEnterRoomBeforeFadein doesn't always react ???
Like I said, it is called once.
Before the new room fades in, AGS calls on_event(eEventEnterRoomBeforeFadein, room), then the room's room_Load.
If you happen to hold Esc down right when the function is run, it is catched.
Try putting it in rep_ex_always.
rep ex always is not called during fades
What about setting room transition to "instant" and making manual fade-in/out? This sounds complicated, but could still be useful if you seek perfection.
Don't have any more ideas atm.
Yeah, that's the only feasible way it seems.
Use a screen-sized black GUI and fade its transparency. Either check for IsKeyPressed(eKeyEsc) during the fade loops or fade it non-blocking, then you can use on_key_press.
Darn. But thanx. :)