Placing my sprite between Tile Map Layers

I've tried pretty much everything! I'm currently adding my sprite to the tileMap with tileMap.AddChild(...), this works fine but will always display the sprite on top of all tile map layers. I've tried adding the sprite directly to other layers but it doesn't display.

I want my sprite to be able to walk under some of the tiles.

Any ideas greatly appreciated!

Answers

  • BadgerByteBadgerByte GBMember

    Ok, resolved. I was setting DepthTesting = True in the wrong place!.

    For anyone who's struggling with this, here's how I did it (almost certainly not the best solution).

    I'm using the VertexZ property of the sprite to set it's depth.
    With the tilemap editor I'm adding property "cc_vertexz" to each layer eg. base layer = -100, tree layer = -50.
    This automatically populates the VertexZ of each tile.
    I then apply a VertexZ between the two values to my sprite (eg. -75).
    DepthTesting = true needs to be applied to the gameView in the GameDelegate.

    Works fine, for now at least!

Sign In or Register to comment.