Map rendering Libgdx Java

Posted by user3165683 on Game Development See other posts from Game Development or by user3165683
Published on 2014-08-19T16:15:27Z Indexed on 2014/08/19 16:31 UTC
Read the original article Hit count: 160

Filed under:
|
|

Ok, so I am trying to create a 2D non-movable random tiled map. This is what I have so far:

private void generateTile(){

    System.out.print("tiletry1");
    while(loadedTiles != 8100){

    System.out.print("tiletry");
    Texture currentTile = null;
    int tileX = 0;
    int tileY = 0;

    if (tileX == 120);
        tileY = 16;
        tileX = 0;


    game.batch.begin();

    switch(MathUtils.random(2)){

    case 0:
        //game.batch.draw(tile1, tileX, tileY);
        System.out.print("tile1");
        currentTile = tile1;
        break;
    case 1:
        //game.batch.draw(tile2, tileX, tileY);
        System.out.print("tile2");
        currentTile = tile2;
        break;
    case 2:
        //game.batch.draw(tile3, tileX, tileY);
        System.out.print("tile3");
        currentTile = tile3;
        break;
        }

    tileX+=16;
    loadedTiles ++;

    game.batch.draw(currentTile, tileX, tileY);
    game.batch.end();
    }   

}

However, I can't see any of the tiles and the screen just looks green. This method is above my render method which I have:

camera.update();
batch.setProjectionMatrix(camera.combined);

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

game.batch.begin();
//other render stuff

Why am I not able to see the tiles?

© Game Development or respective owner

Related posts about java

Related posts about libgdx