• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

I have to press my HTML5 game's start button 2 times to begin a game.

K12gamer

Member
My game is embedded on my website.
I have to press the START button for a second time when the initial screen of my game is shown.
If I run it as a regular windows game the start button works as intended with just one click.

Is there a way to get the HTML5 version of my game to start with just one click?

Example of one of my HTML5 games: PokeNUMBERS
 
I'm not sure if I'm correct, but I thought I read somewhere that it has something to do with initialization within the web browser. I guess maybe it has something to do with focus? Anyhow, what if in a controller object we could simulate a mouse press automatically at initialization, it might take care of ensuring focus? I think it is worth a try anyway. Let me know if it works, I believe this code would do it!

GML:
event_perform(ev_mouse, ev_left_press);
 

K12gamer

Member
I'm not sure if I'm correct, but I thought I read somewhere that it has something to do with initialization within the web browser. I guess maybe it has something to do with focus? Anyhow, what if in a controller object we could simulate a mouse press automatically at initialization, it might take care of ensuring focus? I think it is worth a try anyway. Let me know if it works, I believe this code would do it!

GML:
event_perform(ev_mouse, ev_left_press);
Thanks...I'll give it a try.
I will make an object...then put the code into it with a Create event...then put the object in the opening room.
Do you think this is the best way to try the code?
 

Padouk

Member
@K12gamer
Ahoy mate. You're first Click should work just fine without any workarround. Looking at your example you have some javascript error on the first click.
That's what you want to make disapear.
1608561180750.png

A) If you are controlling the embedding frame (aka the html in itch.io) you can simply call $('iframe').focus() when the game starts.
B) If you dont.. well you can change your index.html with 2 lines of codes: have a look here
 
Last edited:
Top