Getting started with HTML5

This is brilliant, works fine for me, with the odd quirk now and then that I have to track down. But well done!

There is one thing I cannot figure out how to do – send a file to a browser. I have an app where the user ‘plays’ it, and they get a summary. I want them to be able to save the summary (which I convert to html for the app version and send to Dropbox). But I cannot figure out how to do anything that would allow a download in an html5 app except using a mailto link, which is not a good idea on a public server. 

Is there any way to send a file or a large string to the browser from an html5 app? I can write a file to the usual directories, but cannot bring it back to load into a url or a webview.

Hey! Glad it works for you. About “sending back to browser” you can do a small JavaScript plugin, following a tutorial: https://coronalabs.com/blog/2019/02/06/adding-speech-recognition-to-html5-apps/

Thank you, I think that will do nicely. I assumed it would be something going through js, but did not realize the connection to js was that simple. Thanks, well done!

Thank you for kind words.

This is great!  I’m just now getting to play around with HTML builds and I’d love to see a working sample that shows module integration and all the other cool stuff from here: https://docs.coronalabs.com/guide/html5/plugins/index.html

Link above has a sample plugin: https://coronalabs.com/blog/2019/02/06/adding-speech-recognition-to-html5-apps/

Wait. . . so essentially all I do is give my lua modules a .js extension and the JavaScript Module Loader loads them in HTML5?

Uh… I’m not sure what you meant, but you can use javascript from your Corona (lua) game. To do that you would have to put JavaScript object with specific name into specifically named file and include it as part of your Corona project. Then you would be able to import it as it were a Lua module. See docs & example for details.

I’m finding my way now, thanks for the demos and docs - it’s helpful to see the actual files.  My projects without modules work fine and now I’m trying to adjust a few larger projects to be suitable for HTML builds.

OK, I’m having success now and I want to say thank you to the Corona engineers who made HTML builds a reality.  Once I identified the particular parts of my apps that weren’t “HTML5 friendly” I found the process of making HTML builds as seamless as making all the other build types Corona supports. 

Wow, I’m delighted.  Go Corona!

Any tips for using sounds in HTML builds?  I’m getting unreliable results with audio (particularly streaming) and wondering if there are some best practices that I’m unaware of.  I’ve tried both WAV’s and MP3’s.  Am I missing something?

Hey I have ported my game to html5 and uploaded to itch.io for testing but it doesn’t work. https://itch.io/game/1771192

You can try out your builds locally in your browser. After building a Solar2D game for HTML5, you get the option to “Open in Browser”.

If it’s not running, you will likely get some error message explaining why. If you don’t, then you need to add some of your own logging to the project. You can do so by using my module:

Is there a place I can look up to see which plugins I shouldn’t use etc. ?

Generally speaking, if a plugin has some native features, like IAPs, ads, or other platform specific features, it won’t work on HTML5 platform (apart from JS plugins).

You can just check your build.settings and then check the documentation for each of the plugins separately. It should throw you an error message as soon as you try to run a plugin that isn’t supported.

Umm…
This is my plugin section in the build.settings

	--
	-- Plugins section
	--
	plugins =
	{

	},

This is the error I get (I tried a blank app and that worked both on itchio and local server)
image
I can share my whole game, I was gonna make it open source anyways
(it has clear comments, variables names and all that)

That error makes me feel like it’s just crashing right away from some syntax error.

it turns out these 3 lines are at fault here. It works fine when I comment out* these. What is the problem here?

local background = display.newImageRect( "Pixel2.png", display.contentWidth, display.contentHeight )
background.x = display.contentCenterX
background.y = display.contentCenterY

For future people: First try commenting out the whole code and see if it works like that, you can select start of the every line and add “–” using “shift+alt+mouse left click drag”

The answer likely lies in Solar2D console. There’s probably a message about the filename being different on disk, which may get handled on the simulator, but not on all other platforms, like HTML5.

Your game crashes because it fails to create the image, which then means background does not exist as a table and the crash happens when you treat it like a table afterwards by assigning it the x property.

I’m closing this topic as it hasn’t been active for 3 years and now it has veered off to an entirely new and different topic. If you need further help with your particular issue, please start a new topic.