Draw tileset image by index instead of sprite

Hi, I have a tileset image that I’m using for the tilemap made in Tiled, a lot of items that im using are also part of tileset image used for tilemap, but same items are also used for rendering sprites above tilemap.

What im using right now is one image as tileset, for tile map, and another batch of same sprites loaded as atlas so i can easily call by name. Im using two diffrent images files for same items.

Is it possible to draw sprite using tileset image? so i can use only one image instead of two?

What im thinking about is to create function to crop tileset image and display as sprite only item that i need, but is that a right way to do it?

You can load the tileset image as a spritesheet. Choose the correct SpriteSheetConfig values.

1 Like

This will for example divide the whole image as 16x16 tiles?
What if I need to use some part of an image that is 16x32 and some 16x16, some 32x64? Maybe crop is still a better idea for what i need because assets are not always 16x16 some are more in height or width, but I will need to manually map what item is what index and how much to crop.

You could load the tileset image as an atlas, or you could add frames to the texture manually, any name or size.