0 Favourites

Losing focus

  • 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/

    <img src="http://www.blommouth.com/vrac/constructTest/events.png" border="0">

    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 ?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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 !

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Local storage/array losing data
26 1,865
SparklingAir's avatar
SparklingAir
Topic
22 2,293
Rhindon's avatar
Rhindon
Unread hot topic
40 4,121
PSI's avatar
PSI