title: Why am I getting a null pointer exception when trying to use rotate(degrees) on my sprite?
body: <p>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.</p>
  
  <pre><code>public float setTouchpadY() {
    return touchpad.getKnobPercentY();
  </code></pre>
  
  <p>}</p>
  
  <p>In my WorldRenderer class, the render() method, I'm trying to rotate a sprite with the touchpad. gs is the GameScreen class</p>
  
  <pre><code>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
    }
  </code></pre>
  
  <p>}</p>
  
  <p>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</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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.</p>
  
  <p><img src="https://i.stack.imgur.com/ryFzT.png" alt="enter image description here"></p>