ldtk icon indicating copy to clipboard operation
ldtk copied to clipboard

Store level background image sizes

Open Trouv opened this issue 3 years ago • 3 comments
trafficstars

The __bgPos stores a lot of good information about the background image, which makes rendering it pretty easy. However, the total size (not cropped) of the background image isn't stored anywhere, like it is for tileset definitions. This can be a bit annoying when importing into engines that load assets asynchronously.

In the case of bevy, you give entities an asset handle component for rendering rather than the raw asset data itself, meaning you don't need to wait for the asset to load before assigning said component to an entity. But doing a crop on the image with a texture atlas requires knowing the size of the total image on creation of the texture atlas component. You can't figure out the size of the image from the asset data itself until that asset has finished loading.

Storing a pxHei and pxWid, maybe in the __bgPos, would go a long way to alleviate this problem.

Trouv avatar Apr 27 '22 06:04 Trouv

Good suggestion, thank you :)

deepnight avatar Apr 27 '22 06:04 deepnight

For my needs in Unity, I didn't have a problem with this; as long as it had the slice data, then that works for me, as I can already get the width/height of the source texture. But I can see that would be useful to have the source texture width and height in the json.

Cammin avatar Apr 27 '22 17:04 Cammin

Adding to this. I've now found a need to access the background image's width/height; To maintain performance, I don't load the texture to check its width/height. So adding a source texture width/height to the json would be very valuable to me as well. 🙂 This feature will be critical for me sometime in the far future.

Cammin avatar May 28 '22 21:05 Cammin