Getting started with HTML5

I think text fields in general are still WIP.  I tried some normal ones yesterday and they were oversized.

Emscripten

I can try to fix the issue but I need a testcase or a link to this app

I would appreciate if someone or Corona Team can give us example on the following. Thanks in advance.  :)

If your app makes calls to web servers, using API’s like network.request(), because of JavaScript cross-domain scripting rules, you can’t directly call REST type APIs. Instead you will need to write a local web script on the same domain that will make your REST API calls and then echo the returned data back to network.request().

+1

@roaminggamer: all your stuff works really well, even on mobile. Great job guys!!!

My game of course doesn’t work, there are too many plugins that I need to strip first.

Is there any documentation for html5 specific apis or things that are known issues or not implemented yet?

To debug an web app which uses network.request() one can to use a CORS plugin, it allows cross-domain requests. But it’s not secure and should be used only on localhost. For example, I use local web server and browser with CORS plugin to debug web apps.

No such doc for now.

By now implemented: all complete core functionalities and the following plugins and features: audio, sqlite3, file system, physics, json, network, sockets, all native display objects

Do you mean network.request is currently supported?

yes, network.request is supported

Lets say you host your game/app at You can only make network.request() calls to http://acme.com. But if your needing an API from https://superhighscores.com/api/sethighscore&score=100 as an HTTP GET call, you would need to write a script at http://acme.com and name it something that makes sense, perhaps sethighscore.php and drop that in the folder with your game (Not required, you can put it anywhere on acme.com).

In the PHP script you can use the $_GET[] array to access the parameters passed (score) and reform the URL to superhighscores.com in the PHP script adding the various GET or POST parameters. You can then use something like PHP’s curl or other technologies to call superhighscores.com. You would get JSON (or XML) data back, and then simply echo it out of the PHP script to return it to network.request.  You can see some examples of making REST calls with PHP here:

https://stackoverflow.com/questions/9802788/call-a-rest-api-in-php

Rob

A small game I made last weekend and with only a couple of tiny changes it works pretty well in HTML5, if anyone is able to give it a play and tell me if it runs for you too that’d be great - http://glitchgames.co.uk/labs/gravitee/live/

One small issue currently is it starts slightly too big for the window, if you resize your browser even by a pixel it will fix itself. 

Graham,

Fun game…  It does the same thing on my Mac, OS Sierra, safari 11.0.3

It starts oversized, then it settles in to correct size if I just stretch the window a hair.  But it does play in my browser.

Normal => select Level #2 => Menu => Select level #2 … freezes

Thanks for giving it a play! I’m pretty happy with the current state of HTML builds and amazed at how well it runs. It’s a little sluggish at times, and not sure if that’s down to my game or HTML5 in general.

Oops, thanks. Should be fixed now.

Is there a way to pass variables into the HTML5 build, or for it to read cookies?  For example if we have a user logged into our website, I’d like for our HTML5 Corona app to be able to read the username/id somehow.

yes, there are 2 ways:

  • using system.getPreferences/setPreferences

  • using a simple JS plugin which will get/set cookies; no ready solution for now

Thanks vitaly, do you have an example of how we can set a preference in HTML or JavaScript that Corona could then read?

sure, here many examples in Lua

https://docs.coronalabs.com/api/library/system/setPreferences.html

https://docs.coronalabs.com/api/library/system/getPreference.html

soon the HTML5 JavaScript plugin tutorial will be ready