NullPointerException on Render-Collection of common programming errors
when I try to debug this, I got a nullpointerexception. I just don’t get it, something must not been initialized correctly but I can’t see what… Thanks!
@Override
public void create()
{
Texture.setEnforcePotImages(false);
camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
camera.setToOrtho(true,VIRTUAL_WIDTH,VIRTUAL_HEIGHT);
batch = new SpriteBatch();
labyrinthe = new Labyrinthe(2, VIRTUAL_WIDTH);
labyrinthe.generer();
joueur = labyrinthe.getJoueur();
}
@Override
public void dispose()
{
batch.dispose();
}
@Override
public void render()
{
camera.position.set(joueur.getX(), joueur.getY(), 0);
camera.update();
camera.apply(Gdx.gl10);
Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height);
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
batch.begin();
dessinerLabyrinthe();
dessinerJoueur();
batch.end(); // Exception on this line
}
Edit : here is the exception :
08-24 09:22:02.413: W/dalvikvm(224): threadid=21: thread exiting with uncaught exception (group=0x4001b188)
08-24 09:22:02.413: E/AndroidRuntime(224): Uncaught handler: thread GLThread exiting due to uncaught exception
08-24 09:22:02.480: E/AndroidRuntime(224): java.lang.NullPointerException
08-24 09:22:02.480: E/AndroidRuntime(224): at com.badlogic.gdx.graphics.g2d.SpriteBatch.renderMesh(SpriteBatch.java:1042)
08-24 09:22:02.480: E/AndroidRuntime(224): at com.badlogic.gdx.graphics.g2d.SpriteBatch.end(SpriteBatch.java:269)
08-24 09:22:02.480: E/AndroidRuntime(224): at com.me.crazymazes.CrazyMazes.render(CrazyMazes.java:60)
08-24 09:22:02.480: E/AndroidRuntime(224): at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:452)
08-24 09:22:02.480: E/AndroidRuntime(224): at com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake$GLThread.guardedRun(GLSurfaceViewCupcake.java:713)
08-24 09:22:02.480: E/AndroidRuntime(224): at com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake$GLThread.run(GLSurfaceViewCupcake.java:646)
Edit2: Never mind I forgot to call the function that generates the textures…. Thanks anyway