title: Sprite animation Libgdx Java
body: <p>Trying to have a 2-d, top down sprite that rotates and is animated, i have the main class where it is rendered, and a separate 'assets' class where it is created. The rotation works, however the sprite stays on the same frame. I used the libgdx wiki to try and animate my sprite <a href="https://github.com/libgdx/libgdx/wiki/2D-Animation" rel="nofollow">https://github.com/libgdx/libgdx/wiki/2D-Animation</a></p>
  
  <p>Here is the code in the assets class:</p>
  
  <pre><code>public class Asset implements ApplicationListener, Screen{
  
      public static Texture walkSheet;
  
  
  
  
      private static final int    FRAME_COLS = 4;     
      private static final int    FRAME_ROWS = 2;     
  
      static Animation           walkAnimation;      
      static TextureRegion[]         walkFrames;     
      static TextureRegion           currentFrame;      
      static SpriteBatch spriteBatch;
  
      static float stateTime;                
  
  
      public static void load(){
          walkSheet = new Texture(Gdx.files.internal(".png"));
  
  
          TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth()/FRAME_COLS, walkSheet.getHeight()/FRAME_ROWS);              // #10
          walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
          int index = 0;
          for (int i = 0; i &lt; FRAME_ROWS; i++) {
              for (int j = 0; j &lt; FRAME_COLS; j++) {
                  walkFrames[index++] = tmp[i][j];
              }
          }
          walkAnimation = new Animation(0.1f, walkFrames);      // #11
          spriteBatch = new SpriteBatch();                // #12
          stateTime = 0f;
          stateTime += Gdx.graphics.getDeltaTime();
          currentFrame = walkAnimation.getKeyFrame(stateTime, true);
      }
  </code></pre>
  
  <p>And here is how it is rendered:</p>
  
  <pre><code>game.batch.draw(Asset.currentFrame, x, y, (float)85, (float)85, (float)170, (float)170, (float)1, (float)1, (float)angleDegrees + 270);
  </code></pre>
  
  <p>What do i need to do to correctly animate the sprite?</p>