Open chucklepie opened 2 years ago
I am not able to reproduce this. tex.get_data()
returns the cropped image for me. A minimal reproduction project would help debugging.
And FYI, since AtlasTexture
is returned for these kind of frames, you can use its region
property to get the rect.
@timothyqiu I was originally trying to use get_data() but it returns an Image not a texture and on converting to an ImageTexture the output was blank, so presumed this was not the way and switched to my above method trying to get the texture in the way you normally would by grabbing the texture but AnimatedSprites made this difficult.
i.e. this was what I originally had
var itex = ImageTexture.new()
itex.create_from_image(image) #the grabbed image using get_data()
shard_texture=itex
But trying to debug I had to give up because for whatever reason the Godot IDE cannot show ImageTextures so you have no idea what the output actually is because passing in a Texture shows up just fine and displays image not ID, so dunno if this is a 'feature' or bug :(
So this might just be a miscalculation on my behalf.
You can try using a TextureRect
to display that texture.
Also in case you're using AtlasTexture
(i.e. what you get from that sprite frame) in something related to Ploygon2D
/ Particles2D
, there are some long existing issues like #25049 and #13923.
Godot version
3.4.2
System information
PopOS
Issue description
In code you want to grab a texture of the current frame, or even just the first frame, e.g.
size is correct and holds the size, e.g. 64x64
However, unless I'm missing something, tex contains the entire sprite sheet and there is no data holding the rect/region where the sprite is.
The only place I can find it is inside the scene file, e.g.
But this is not referenced in the animated sprite or the sprite frame.
Note, I am using .tres files to represent individual regions within the sprite sheet so my 'add frame from region' points to my .tres file not the whole sprite sheet, but texture still returns the whole sprite sheet, so the same problem occurs.
Steps to reproduce
As description
Minimal reproduction project
No response