Losing focus

0 favourites
  • 3 posts
From the Asset Store
A game template with a great amount of assets! You will be able to create a full game just with the assets provided!
  • 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 ?

  • Try Construct 3

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

    Try 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)