I'm creating a game where you can to all four directions ( up, down, right, left ) and I've encoutered a problem: I can't find a way to make player to be displayed behind the object if player is behind that object.
While I was doing it totally top-down style, it was ok. But now I'm trying to add some "3D" effect to it ( see images below ).
And one more thing - I'm making so that when the player enters a house, the full house look ( the full height wall and roof ) disappears and only the layout of the wall ( where is the actual collision layer ) is beeing shown( I haven't done that yet, but I have a pretty clear vision of how I'm going to implement that ).
To make it more clear, I'm gonna give some images as examples:
When player is below object - everything is ok!
But when player get's behind object - things start to become pretty weird :D
Anyone knows how to put the player behind the objects which he should atcually be behind ?
EDITED:
@Override public void show( )
{
/** Initializing InputProcessor **/
Gdx.input.setInputProcessor( this );
/** Creating map **/
tiledMap = new TmxMapLoader( ).load( "maps/medievalPlace.tmx" );
mapRenderer = new OrthogonalTiledMapRenderer( tiledMap );
/** Initializing Camera **/
camera = new PlayerCamera( ( TiledMapTileLayer ) tiledMap.getLayers( ).get( 0 ) );
/** Initializing spriteBatch **/
spriteBatch = new SpriteBatch( );
spriteBatch.setProjectionMatrix( camera.combined );
spriteBatch.maxSpritesInBatch = 1;
/** Initializing uiBatch **/
uiBatch = new SpriteBatch( );
uiBatch.maxSpritesInBatch = 5;
/** Creating Player **/
player = new Player( new Texture( "char/down/walk0.png" ) );
// Initializing font for FPS displaying //
font = new BitmapFont( );
}
private void renderScreen( )
{
Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
/** Rendering map **/
mapRenderer.setView( camera );
mapRenderer.render( );
/** spriteBatch rendering **/
spriteBatch.begin( );
player.draw( spriteBatch );
spriteBatch.end( );
/** uiBatch rendering **/
uiBatch.begin( );
arrow_right.draw( uiBatch );
arrow_left.draw( uiBatch );
arrow_down.draw( uiBatch );
arrow_up.draw( uiBatch );
action.draw( uiBatch );
font.draw( uiBatch, "Fps: " + Gdx.graphics.getFramesPerSecond( ), 100, Gdx.graphics.getHeight( ) - 100 );
uiBatch.end( );
}