문제

Quick facts:

  • I'm using Tiled as my Tile-editor.
  • I'm using LibGDX. I got everything to work for a old Pokémon styled game.

My problem:

I'm not creating Pokémon. My sprite is 60x20 pixels, but I only want the bottom 20x20 pixels (my feet) as my collision area.

Now, take a tree, with a 20x20pixels unwalkable bottom:

When I'm coming from the bottom, I want the 40 pixels above the feet to be showed infront of the tree. That means 20 pixels infront of the bottom, and 20 pixels above, infront of the actual trees. But, when I'm standing just above the bottom of the tree, I want my player to be completly covered behind the tree.

When I was programming without LibGDX (to a desktop, low low-end) I just rendered all the pixels above my position first, then checked for any items to go above/below me, and then rendered everything else.

Now, I don't know anyway to render just a couple of pixels when I'm using a OrthogonalTileMapRenderer.

도움이 되었습니까?

해결책

I think there is no solution using only the TiledMapRenderer to render whole Layers.

Imagine you have two trees, one above the other with one tile of space in between. Your character is standing on this one tile and thus is between both trees. He would be behind one and in front of the other one. In this case it is impossible to render the whole Layer at once the standard way, because your character will either be in front of both, or behind both trees.

You can still create your map using TilEd, but you will need to analyze that special layer with objects and convert it to a List of Entites where you can apply manual Z-ordering (well, Y-Ordering in 2D-space) from background to foreground and render them individually in the correct order.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top