0 votes

I know we can use the [img]res://icon.png[/img]

However, I am writing a Emoji Parser for chat and was curious if we could somehow use a spritesheet within the [img] tags instead of using hundreds of individual images. Any idea how to do this? Thanks in advance

in Engine by (311 points)

Waaaaaaaaaait a minute, you can add images to a rich text label? Holy mother of jesus.

@mateusak what do you mean?

Just for curiosity tried this on a RTL and worked:

var texture = preload("res://icon.png")
var subimage = texture.get_data().get_rect(Rect2(10,10,10,10))
var subtexture = ImageTexture.new()


add_text(str("subimage: "))

This code on RTL ready will cut a bit of icon file and create a new image from the texture then crop the image to make a new resource

So, it seems that will work, you need to find a good way to organize your "virtual resources", and maybe get rid of them when not used too.

Made this with zero knowledge on the subject so maybe there is a better/direct way to get the final resource, look at Texture, TextureImage, Image and related classes.
Try and share your findings ^_^

Please log in or register to answer this question.

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.