+1 vote

Hi All!

I am currently trying to implement a system where the user can easily create and use their own custom sprites for my game, I.E. they can drag and drop their own folder with a particular set of images with particular names and have that appear in the game.

I initially just tried to load each of the images the user provided for the sprite using the plain old "load" function. This didn't work, presumably because the user provided images aren't properly imported into godot.

I fiddled around with the code a little bit and then tried the following method:

                var imageImport = Image.new()
                var animationImageTexture = ImageTexture.new()

                # Adding the frame to our animation at the correct location
                animationImageTexture, animationFrame)

This worked, and I tested it on a fresh machine, and I was able to provide custom user sprites on the new computer and it worked like a charm. However, allowing the user to provide their own sprite images caused a lot of nearly identical warnings to appear in the debugger. This is an example of a warning I received:

load: Loaded resource as image file, this will not work on export: 'res://Packages/Default/Player/Graphics/legs/default/0.png'. Instead, import the image file as an Image resource and load it normally as a resource.
  <C++ Source>  core/image.cpp:1890 @ load()
  <Stack Trace> WarSprite.gd:87 @ loadAnimation()
                WarSprite.gd:57 @ loadAnimations()
                WarSprite.gd:37 @ init()
                Actor.gd:9 @ init()
                Player.gd:9 @ init()
                WarScene.gd:21 @ init()
                TestScene.gd:20 @ _ready()

This is concerning to me both in that I may have done something wrong that will cause issues for me down the line and because the debug warning messages cause a notable slow down (about 7-8 seconds) in the startup time of the game in the editor. Outside of the editor it is fine.

Does anyone know if I'm doing something harmful here, if there is another, better way I could accomplish what I want to accomplishment, and finally, if what I'm doing is the best way to do this, does anyone know if I can suppress these warnings?

in Engine by (32 points)

2 Answers

0 votes

to fix error message
set the type to image in import setting and load like this

var image: Image = load("res://PixelLevel/Sprite/Template/BasicBack.png"),
by (1,672 points)
0 votes

That warning looks like it is telling you that the images you loaded that way won't be bundled when you export the game for release. But you shouldn't have to worry about that since the point is to load user images.

The performance issue is more concerning. Perhaps there is a way you can disable that warning with an optional parameter or config variable.

by (858 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.