[feature req] detect browser & nw not in focus / blurred

0 favourites
  • 3 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Presently the Browser object will return triggers On Suspended and On Resumed when the game tab comes back into focus when switching back from a new tab or if the game was minified into the task bar. For very sensible security reasons, a blurred or out of focus game is unable to register key down and key up triggers during the time is is blurred - which means that the c2 key is down will incorrectly register a key position as down if it misses the key up trigger. If you code your events only using key down/up triggers then you also cannot detect key triggers when the game is out of focus. Using the browser On Suspended and Resumed triggers allows you to code your events to manage the possibility of missing key triggers.

    However, it is not possible for c2 developers to set events to detect if the player has returned to a running game after they have clicked on something else on their desktop - although the game loses focus and becomes blurred, the triggers will not fire when focus is regained. For example, if the game is not minified and another program is opened over the top of it then these triggers will not fire, and if the game was in a stand alone browser window and the player just clicks on something else then the triggers will not fire on returning as well.

    If you're exporting in nw then these can make your game look rather amateur when the player clicks on something else accidentally or just opens another program momentarily - and then, when they return to the fruits of your hard work, they discover (for example) that they are stuck in a run-right-to-suicide loop until they press the Right key again (the right key release trigger being missed by the game logic).

    Now, the debug "pause on unfocus" option clearly uses a more complete not in focus / blur detection system than the aforementioned browser triggers - because it will pause the game in the above 2 situations during preview. This feature request is to give us access to this same blurred / out of focus condition information.

    Anyone any thoughts / ideas / comments / work-arounds?

  • I think it would be better to fix this directly in the keyboard/mouse object: if the window loses focus, then it will immediately fire mouse up/key up triggers for any keys which were held down. Then keys never get stuck, and games don't have to reinvent this feature every time in the events if they want to avoid the problem. Does that sound reasonable?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley - that sounds excellent .

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)