Jump to content

How can I force my game to be in focus?


kleepklep
 Share

Recommended Posts

I've been watching your thread but haven't (and still don't) have anything useful to add from a raw IE11/mouse event standpoint. Thanks for documenting it, though.

 

I bet a steak dinner that there's no way to focus a canvas element quite like there is for input elements, i.e. calling ".focus()" on it.

 

You might be better off making a small buffer zone around the edge of the canvas and, in IE11, if the mouse goes into that buffer zone it does the same thing it would do if it received a mouse up event. That wouldn't mitigate the problem entirely, but it might help? You could call "game.input.reset(false);" to reset the values under those conditions.

Link to comment
Share on other sites

I'm having a (possibly) similar issue. 

 

Originally I was experiencing odd behavior in IE9 -- click and drag out of canvas, then click and drag within canvas.... would produce serious lag. Preventing the default event on the canvas div (<div id="gameCanvas" onmousedown="event.preventDefault ? event.preventDefault() : event.returnValue = false">) fixed that and everything seemed ok until we tested in IE11.

 

Also since this is a pull back and release to launch kind of game... I added a mouseOutCallback... which basically sees the mouse leaving the canvas then does the same thing that onInputUp was doing. (Similar to what @drhayes suggested above) This way if the user drags out of the game the loss of the mouseUp in IE isn't a big deal.
 

game.input.mouse.mouseOutCallback = (function(scope){
return function(){scope.launchBall();};
})(this)

 

The problem that remains is that coming back into the game after releasing the mouse outside forces the user to have to click twice -- once (seemingly) to regain focus... then again to actually interact with the game. 

 

 The only other solution that I can think of so far... and it's not really what I would want to do... is force the game to pause when the mouse goes out of frame... and have a "Click to Continue" button appear... that way the user has to click in the frame to regain focus (even if it might still be twice) before they are actually playing again.

 

 A true technical solution for this would be amazing though.

Link to comment
Share on other sites

Though I never could figure out the focus thing, I posted the mouse up / onInputUp after dragging off the canvas issue in the Phaser issues forum and it was resolved: https://github.com/photonstorm/phaser/issues/2000

This was my related post: http://www.html5gamedevs.com/topic/16304-sprites-oninputup-doesnt-fire-if-off-canvas-in-ie11-is-there-a-fix/

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...