0 votes

I want to download image from a particular http path using httpRequest and load that image as texture on a Sprite Node.

Thanks in advance.

in Engine by (46 points)

2 Answers

+1 vote
Best answer

This is demonstrated in Unpackaged images question, just replace the TextureRect node with a Sprite.

by (12,495 points)
selected by

Thank You it worked. i have two questions, if we want jpg images to download, is there any function for that? and second is how to show a loading image that it is downloading.

+2 votes

I'm not sure if you can do that. I managed to download the image but it only appears on the project files after restarting the game. Try yourself with the code below:

func download_texture(url : String, file_name : String):
    var http = HTTPRequest.new()

func _ready():
    download_texture("https://opengameart.org/sites/default/files/player_19.png", "my_new_texture.png")
by (521 points)

Thanks for your answer, but the answer below is perfect.

This is exactly what I was looking for. Thank you!

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.