Jcras Posted September 12, 2017 Share Posted September 12, 2017 Itch.io puts my game in an iFrame. This means that event listeners don't work unless the iFrame has been clicked on (so no keyboard input). But clicking on the WebGL area within the iFrame doesn't focus the iFrame! If I make the iFrame larger than the rendering area, then click on the border(area between WebGL rendering area and iFrame edge), then my iFrame is focused, and keyboard input works again. But I can't ask players to click on the border before playing! It should be that the player lands on my page, clicks on the WebGL rendering area, and starts playing. And since this is on itch.io, I can't change the .html of the parent window (the one that contains my iFrame). I'm using hexi, so I'm using pixi v3. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 12, 2017 Share Posted September 12, 2017 You can. Look at how "ga.me" (turbulenz) does it. They have special splash screen that asks player to focus the canvas. Whats hexi? Quote Link to comment Share on other sites More sharing options...
Jcras Posted September 12, 2017 Author Share Posted September 12, 2017 (edited) A link to my game is here: <edited> so you can see what I mean. I just don't know how to focus the WebGL rendering area when the player clicks on it! If you click on the grey border it works. Hexi is a collection of modules to go alongside pixi to add new features. It is on github: https://github.com/kittykatattack/hexi Edit: WASD are the controls, the snake is the green square in the middle, it sometimes(rarely) spawns within a wall so it may be need reloading(I just place the walls randomly at the moment) Edit: it is like the webgl rendering area is absorbing my clicks, so that the event listener on my index.html file doesn't get focus. Can I add the event listener to my webgl rendering area somehow? Edited April 2, 2018 by Jcras remove url as game no longer public Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 12, 2017 Share Posted September 12, 2017 Look how pixi interactionManager works. I'm tired and i want to sleep But yeah, its either pixi (which i doubt), either something like "pointer-events:none" on your canvas. Quote Link to comment Share on other sites More sharing options...
forleafe Posted October 16, 2017 Share Posted October 16, 2017 Second. Also having this exact problem. Can we work together to maybe come up with a solution here? Asking players to "click the white border so my code works" just looks sloppy and unprofessional.https://github.com/itchio/itch.io/issues/112 I saw this and tried including the mentioned code solution in my index.HTML file... but it didn't work for me. I still have to click the white border around my game to focus it and gain access to keyboard controls. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.