I'm working on game, using LibGDX and have some problems with Input Processor. Wnen I launch my game and press Right button it crashes with NullPointerException
@Override
public boolean keyDown(int keycode) {
if (keycode == Input.Keys.RIGHT && player.b2body.getLinearVelocity().x <=0.5) {
player.b2body.applyLinearImpulse(new Vector2(0.1f, 0), player.b2body.getWorldCenter(),true);
return true;
}
return false;
}
public void update (float dt) {
world.step(1/10f,6,2);
player.update(dt);
// handleInput(dt);
MyInputProcessor inputProcessor = new MyInputProcessor();
Gdx.input.setInputProcessor(inputProcessor);
if(player.b2body.getPosition().x>=SonicZP.V_WIDTH/2/SonicZP.PPM)
gamecam.position.x = player.b2body.getPosition().x;
if(player.b2body.getPosition().y>=SonicZP.V_HEIGHT/2/SonicZP.PPM)
gamecam.position.y = player.b2body.getPosition().y;
gamecam.update();
renderer.setView(gamecam);
}