deepnight / ldtk

Modern, lightweight and efficient 2D level editor
https://ldtk.io
MIT License
3.44k stars 192 forks source link

Metadata for autolayer rules #152

Closed TheNeikos closed 4 years ago

TheNeikos commented 4 years ago

I'm using the autolayer feature to create 'grass decorations': image, and I'd like to render them above the player. But since they share the same tileid as the actual 'solid' grass I cannot differentiate between them. I could see multiple ways this might be helped:

I'd also be willing to help implement this if you accept pull-requests!

deepnight commented 4 years ago

The current way to do that is to create a separate AutoLayer (a pure one, not an IntGrid) that uses the IntGrid where collisions are. This separate layer can hold any "front" object easily.

Then, in your game, just render the layer above player.

deepnight commented 4 years ago

There is a demo of this in the Typical 2d platformer sample:

bg_textures uses collisions as source for its data.

image

TheNeikos commented 4 years ago

image

Ah! That works like a charm! I guess that covers my use case then. I didn't know you could apply autolayers from other intlayers. Thanks!