I’ve got a GameScreen class that has a touchpad within it. I have a method (setTouchpadY()) within the GameScreen class that gets the touchpad’s getKnobPercentY.
public float setTouchpadY() {
return touchpad.getKnobPercentY();
}
In my WorldRenderer class, the render() method, I’m trying to rotate a sprite with the touchpad. gs is the GameScreen class
public void render() {
//render stuff
moveCamera(leon.getPosition().x, CAMERA_HEIGHT / 2);
spriteBatch.setProjectionMatrix(cam.combined);
spriteBatch.begin();
drawVillage();
drawTile();
drawLeon();
spriteBatch.end();
if (leon.isAiming()) {
leonAimArmSpriteR.rotate(gs.setTouchpadY()); //This line causing crash
}
}
I’ve put the touchpad and buttons into the Gamescreen class because it’s implementing Screen and Input Processor. Tried to put them into WorldRenderer with no luck so far.Here is my logcat/console, this is from trying to run the desktop version, if I need to post the android I will
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NullPointerException
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: java.lang.NullPointerException
at com.me.RE4.view.WorldRenderer.render(WorldRenderer.java:142)
at com.me.RE4.screens.GameScreen.render(GameScreen.java:151)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:191)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)
EDIT
So I’ve found that I had not instantiated GameScreen, when I did that it was saying that WorldController is the null. So I instantiated WorldController in WorldRenderer, but then it’s saying that TouchpadY() method within GameScreen is null, set the break point and that’s giving me all sorts of variables as null.

Alright, I was trying to do the rotation within WorldRenderer initially, within the render method so that holding the touchpad steady at a certain point would keep rotation going at that degree. I would have had to instantiate / reference a lot of items within WR for that to work, so I ended up instatiating gamescreen in WR and then referenced my sprite that I wanted to rotate in GS and then the touchpad values worked within the render method of the GS. Mucho sloppy