Stencil and tilemaps

Here’s is my problem: I have a tilemap for a top down zelda like thingy, with open doors.
The tiles in question contain both the floor and the actual door.

42

The player should pass on top of the floor part and under the door. In love2d I would normally set a stencil with a rectangle mask for the top part so that the player is not drawn.

What’s the best way to approach this in Defold? Stencils from what I can see are only available in gui.

If you use two layers, with different Z, your player should be able to pass between them.
Seems like that should work in this case?

2 Likes

Even if I use 2 layers the problem is in the way the tile is built (I got these from the internet). Part of the floor is still in the door tile itself.

Ideally the player should be able walk on that tile and be partially obscured. Is there no way to get masking?

You could totally mask it, but you would need to create render targets and do multiple draw calls for the multiple parts.

Honestly, using a stencil is an overkill solution for just drawing one thing on top of another. If you don’t want to edit the graphic yourself and are happy with a simple, rectangular cutout, I could do that for you in about 5 minutes…

…Just kidding, I already tried it! There was an open column on the right side of that tileset (not enough space to do all the rotated versions though). I tried adding a shadow under it too, though it’s not very pretty (the bottom 3 tiles in that column)

Dungeon%20Tileset_by_Buch_Plus_Transparent_Arches

5 Likes