The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

In my game i am adding some sprite node dynamically when the game is running
and I set the texture property of those newly added sprite nodes.
The game works well in the computer. But when exported to the mobile phone texture [in PNG file formats ] are not loading in to the newly instantiated sprite nodes.

Godot version Version 3.2.3 stable
in Engine by (14 points)

Check your texture naming

PC is not case sensitive but android is

So if there is a mistake in your naming, it might still lead on pc but not on mobile

Are you using Directory to look for files?

The image textures are a series of .png files which are numbered.
First I read the "*.png" files stored in a particular directory using the method Directory.list_dir_begin() of the Directory class.
File name is obtained by using the Directory.get_next() method.
If the file name ends with ".png" then the file name is appended to an Array.
Then this array is used to set the texture property of Sprite node by calling the
The code with above setup works fine in computer.

But when exported to an apk file only files with ".png.import" extension are stored in the "assets" folder. From there those ".png.import" files point to some files with ".stex"
Even if I use "*.png.import " file names to point to the texture , texture are not loaded.

The sprite gets loaded in the mobile when I load each and every sprite
separately by using the load method without using the array.

var texture = load("res://An/Ch 1/01.png")
var ch:Sprite =
ch.texture = texture
ch.position.x = 99
ch.position.y = 6

But when I use the array to load the texture , The array size itself is zero.
Because no file with ".png" extension is not loaded in to the array.

1 Answer

+1 vote

So what you should do is get the file name of the .png.import file, remove the .import part, and then put it into the load function.

by (8,550 points)

Thanks. It worked.

can you explain that in more detail?

I just delete the .import portion of the files?

Use the directory to look for the import files. Remove the .import from the file name and then put the resulting string into the load function.

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 Frequently asked questions and 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 [email protected] with your username.