First game problems

Hello!
My first post on the Defold forum, about my first game with Defold :smiley:

So I made a very simple and very interesting game with Unity3D, but then I decided that I wanted it to be playable as a Facebook instant game. Thus I found Defold :slight_smile:
I just made a 2d rudimentary clone of my original game in Defold in about 2 days.
I made it as an android game, it works fine when I build it and I can test it on the PC, I can even build it into an APK and install it on my phone and it worksā€¦ But see, as I said I would like it to be a facebook instant gameā€¦ and I cant build it to html5. I bet I missed a simple thing or something, but could someone help me? I have no idea what to do, when I try to build the HTML5 it opens a window in my browser, gives me the offer for fullscreen but the game isnā€™t thereā€¦
Thanks for the help :slight_smile:

1 Like

Hello and welcome to Defold!

It would help if you provided a bit more information. What OS are you running? What browser are you using? If you open the browser developer console, are there any helpful logs?

If you bundle to HTML5 and access the game via a local web server from the bundle catalog instead of doing ā€œbuild html5 and launchā€, does the same thing happen?

1 Like

Hey @Johan_Beck-Noren thanks for the reply.
I will try to provide more info, but Iā€™m quite new to this so bare with me please :slight_smile:

OS: Windows 10 64bit
Browser: Edge (automatic), also tried it in Chrome and it was the same result.

Here are the logs from Chrome:

And for the last one, I donā€™t know how to do thatā€¦ Sorry.

If it would be helpful I can even send you the project.

Thanks for the help!

It looks like youā€™re running out of memory. What if you open game.project, scroll down to the HTML5 section and increase the heap size value?

Hey @britzl
I went ahead and increased it from 0 to 256.
The result is the same. Still, it loads but then no game.
The log seems a bit different thoughā€¦

Waitā€¦ my bad, itā€™s not the same, I forgot to check Set Custom Heap Size :slight_smile:

image

And now, the screen isnā€™t black, but itā€™s just the blank Defold screenā€¦
Here is the console:

And here is the screen:

1 Like

I believe the value is in bytes. Increase it above the value mentioned in the Chrome console.

BUT you should probably look into the size of your assets. How many atlases do you have and what are their sizes? Do you have a lot of sounds?

1 Like

No sounds at allā€¦ I do have one picture with 11.9 MB thoughā€¦

Yes, but what pixel dimensions of the atlas files? Open your atlas and check properties to see the size.

You can also check the Generate Build Report checkbox when bundling.

Atlas is here:
image
So 2048 * 1024

But I cant find Generate Build Report Checkbox in game.project

Is that the only atlas you have? Thatā€™s nothing to worry about then. The build report checkbox is in the bundle dialog. Did you get the project to run with a larger heap size?

Nopeā€¦ did not get it to runā€¦ I sent you a message with my project files perhaps that could help?

Ok, so I took a look at your project. You have one tilesource with a background image that is waaaaay to large:

The size of 4992x3648 will result in a texture that is 8192x4096 pixels, which equals 134Mb of memory (excluding mipmaps). You need to reduce this texture in size quite a bit. Your game.project specifies a screen size of 640x1136 so you should aim for a size closer to the screen dimensions.

If you take a look at the build report (which you get from checking the Generate build report checkbox:

You see that almost the entire bundle consists of this single texture. Nothing else comes close:

You should also consider using a texture profile to apply texture compression to your images to further reduce bundle and runtime memory requirements. Read more about this here: Texture Management in Defold

2 Likes

Holy Cā€¦ ok, thanks for that I will look into itā€¦ But the reason I have the picture so big is because I am rotating it on runtime to make it look like a moving universe, but I guess that is not the right solution.
But OK, I will fix that and come back to this post with Facebook instant games questions tomorrow if I still have problems.

Thanks a lot @britzl

1 Like

You could perhaps use a shader for the background instead? Perhaps this. We even have a tutorial on how to add such a shader.

1 Like

So I reduced it just a simple background imageā€¦ still canā€™t get the HTML 5 build to runā€¦


:confounded: :confounded: :confounded: :confounded: :confounded::confounded:

Is this using the bundled version? How did you start the file server? And whatā€™s the address you use in your browser? It should be for instance http://localhost:8000
Iā€™d recommend having python to start a file server:

> cd my_bundle_dir
> python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

(If you use ā€œBuild and Runā€, the editor starts a file server for you)

2 Likes

So when I just click build the server is started by the Editor?

image

I have never made a game in HTML so I honestly didnā€™t know a server is needed to run itā€¦
But I tried to upload it to itch.io andā€¦ still, it didnā€™t playā€¦

A Defold HTML5 game consists of an html page, some javascript files and some binary files with game assets. If you open the html file from disk in your browser it will try to load the javascript and the assets but the browser will prevent this for security reasons. In order to run it you need to either upload it to something like itch.io or run a local web server like Mathias suggests. If you select Build HTML5 and run Defold will start a webserver for you. Did this work when you tried it?

1 Like