Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: ability to create standalone .html files with microStudio to open in mobile client browsers #210

Open
SugarRayLua opened this issue Jan 13, 2024 · 0 comments

Comments

@SugarRayLua
Copy link

Hi!

Novice mobile lua programmer that recently discovered microStudio and really like it! As a mobile iOS user, I'm not able to open folders with .html files and run them in my browser. Thus, in order to run microStudio projects, I either need to serve them up with a local server or access them from someone's website. However, it doesn't seem that difficult to convert microStudio projects to a single standalone .html file to be able to open in mobile browsers and have done so as a proof of the concept by:

  1. inline all the microStudio .js files into the index.html (e.g. microengine.js, fengari.js, etc.)
  2. store base64 encoded sprites in a javascript array in the body of the index.html project file (e.g.):
var imgArray = [base64dataURLSprite1, base64dataURLSprite2, etc]

then add names of sprites stored in imgArray (above) in the "resources" variable that microStudio exporter creates at the start of the index.html (e.g.):

var resources = {"images":[{"file":"icon.png","version":0,"size":0,"properties":{}},{"file":"sprite.png","version":2,"size":322,"properties":{"frames":1,"fps":5}},{"file":"sprite2.png","version":2,"size":322,"properties":{"frames":1,"fps":5}}],"assets":[],"maps":{},"sounds":[],"music":[]};

and finally, change the 9th line of the microengine.js "start()" function from:

s = LoadSprite(this.url + "sprites/" + i.file + "?v=" + i.version, i.properties, () => {

to

s = LoadSprite(imgArray[j], i.properties, () => {

The result will be a packed index.html that won't be so easy to read or debug, but it will be able to be opened easily by anyone who download the index.html file in their browser-- including users on mobile devices which will make it even easier to share projects with others cross-platform. While I can do this manually as indicated above, it would be much nicer if microStudio could provide an option to create a standalone .html file in its html exporter. In addition, the exporter could likely also be setup to inline other base64 encoded assets (e.g. sound files) in arrays.

Thanks for the considering the suggestion. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant