Stop Mobile going to Sleep HTML5

I’ve got a html5 game which is designed for the mobile phone, how would I best go about stopping a device from going to sleep?

I’ve found the nosleep.js library, but can’t figure out how to place it in a specific event listener from Defold.

Cheers,
Spen

Do you have to do it from Defold? Can’t you just do it once on the page/html template directly?

1 Like

That’s a viable option, and one I’m pursuing, however I think there are sections of a game where it makes more sense to have a nosleep functionality than others, such as during an other player’s turn, but not whilst you are looking at the options menu. Does that make sense?

I don’t know how nosleep.js works, but can you include it on the page and then use it from html5.run()? Another option is to create an extension and make a Lua binding, but that seems overkill.

How is it supposed to be used?

3 Likes