Hi

I'm trying to make a simple tile mapping but I have a problem with the rendering. I have a NullPointer exception
1 2 3
| Caused by: java.lang.NullPointerException at Map.render(Map.java:51) at .render(LabC.java:47) |
I use 3 classes :
- Block => Each Tile
- Map => two dimensional "Block" array
- LabC => The main class
For rendering one Block I use this function:
Block.java:1 2 3 4
| public void render(){
sprite.draw(LabC.batch); } |
To display all tiles I use this function:
Map.java1 2 3 4 5 6 7
| public void render(){ for(int y = 0;y < map.length; y++){ for(int x =0;x < map[1].length; x++){ blockmap[x][y].render(); } } } |
And the render method :
LaboC.java1 2 3 4 5 6 7 8 9 10 11 12
| public static SpriteBatch batch; ... public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); batch.setProjectionMatrix(camera.combined); batch.begin(); test.render();
batch.end(); } |
Thx for the help