Losing focus

Get help using Construct 2

Post » Wed Sep 19, 2012 4:12 pm

Hi, I'm trying to do a game with this amazing soft but I have a little problem when game loses focus (for exemple when pressing alt, opening another window etc...)

http://www.blommouth.com/vrac/constructTest/


The text is "1" when space key is down, otherwise it's "0"

If you leave the browser while space is pressed and then release the key, when you return to game the text still prints "1"              

The best solution would be to pause the game when losing focus but i don't know if it's possible to detect if game is active...
Furthermore, is it possible to disable "alt" key when playing ?mammouth312012-09-19 16:13:33
B
9
S
1
G
1
Posts: 7
Reputation: 1,689

Post » Sat Sep 22, 2012 3:30 pm

Well, I've managed to pause the game when losing focus by adding javascript in the index.html file.
function onBlur() {cr_setSuspended(true);};
function onFocus(){cr_setSuspended(false);};


Nevertheless, I still have keyboard detection issues. It seems that the "Key is down" event doesn't actually check if the key is down. It seems to be triggered on/off when pressing/releasing the key. That would be the reason why I get errors when releasing the key out of the game.

I don't know if it can be considered as a bug but if anyone knows a solution or a workaround, it would be great !
B
9
S
1
G
1
Posts: 7
Reputation: 1,689

Post » Thu Feb 07, 2013 9:02 am

Yep, I have the same problem. If you left the browser window and than returned the focus is lost until anything is clicked, and this leads to some glitches in the project.

There are two browser events: onResumed and onSuspenden, but they don't react when you switched to another application like e.g. skype or another browser and returned.

Anyone knows how to deal with that? xoros2013-02-07 09:16:59
B
42
S
11
G
4
Posts: 505
Reputation: 7,267


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests