Hello!
I made player class.Player class controls player and sets to render the player.
public class Player extends ObjectClass{
Main1 game;
Texture brick;
public void player() {
//Set Texture of player
brick = new Texture(Gdx.files.internal("glass.png"));
}
public void render(SpriteBatch batch) {
//start drawing brick
batch.begin();
batch.draw(brick,0,0);
batch.end();
}
}
Then i set PlayState class to render that entity
public void draw() {
//draw player
player.render(batch);
}
And then it all goes to main class where all of stuff renders
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
camera.update();
batch.setProjectionMatrix(camera.combined);
gsm.update(Gdx.graphics.getDeltaTime()); // update
gsm.draw(); // Draw all things in PlayState
}
But when i want run the game, i just see NullPointerException and error Player.render(Player.java:30).That is that line
batch.draw(brick,0,0);
I really dont know what is problem.I had tried to fix it but really that error stays.
How can i fix that error?
Can someone help me