4
\$\begingroup\$

I'm sure it is something unrelated is why my program won't work, but I still want to know:

core/image.cpp:1746 - Loaded resource as image file, this will not work on export: 'res://ball.png'. Instead, import the image file as an Image resource and load it normally as a resource.

What does this actually mean!? What is it telling me to do?!

\$\endgroup\$
1
  • \$\begingroup\$ i'm gonna be honest i think there's a not insignificant possibility i just made an unrelated bug, but also like, it really does just say that it won't work at all, so even then i'm wondering what its even advising i do \$\endgroup\$ Mar 22, 2019 at 12:51

2 Answers 2

4
\$\begingroup\$

I'm not deeply familiar with Godot, but here's my interpretation based on reading the docs:

Many game systems include a concept of "baking" data. The authoring tools might accept a wide range of "raw" asset formats — like png or jpeg — but these are often not ideal for use in the game runtime for various reasons:

  • Their data layout is different than what the game uses internally (eg. GPUs use specialized compressed formats for rendering)

  • The workload of converting/recompressing the assets in-game would bloat the runtime and slow down loading the game / levels

  • Pre-digesting the data lets the game load faster, say by breaking the data into chunks to load only what's needed, or batch loading a group of needed assets in one pass

  • The raw formats lack metadata information that the game needs to use them as intended

So the authoring tools accept a reference to these raw asset files, and then "bake" them into a form that's efficient for use in the published game. This means the files your game uses at runtime might not be the exact same source files you provided originally.

In Godot specifically, the docs say:

In Godot 3+, image files are no longer native resources and they must be imported. The reason behind this is the large amount of configuration parameters that image files can be imported with.

So, it looks like that's what's happening here. The engine wants to used a baked asset ("imported resource") here, and you're giving it a raw asset ("native resource") like a png.

The error warns you that while this might work in the editor, it won't work in the exported game because the game only knows how to handle baked assets like imported resources;

core/image.cpp:1746 - Loaded resource as image file, this will not work on export: 'res://ball.png'. Instead, import the image file as an Image resource and load it normally as a resource.

So, you can follow this guide to import your image to be able to use it as an imported resource, which should fix the error.

\$\endgroup\$
2
\$\begingroup\$

The answer by DMGregory is correct, though the solution given is not complete.

The most common cause is the project including icon.png as a default setting. For running on the web, you should convert this to icon.icns. You can use this free converter page to do that.

Once you have the converted icon, go to Project/Project Settings/Application/Config/icons and select your new icon.icns. This doc page may help.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .