title: Sprite setTexture not working
body: <p>I'm new to libgdx and I don't know yet how the Sprite class works, so I run into a bit of a problem with Sprite.setTexture() not woking(I need this for animations). Long story short(as an example):</p>
  
  <pre><code>sprite = new Sprite (imgb); //work flawlessly
  
  sprite2 = new Sprite ();
  sprite2.setTexture (imgb); //doesn't do anything
  </code></pre>
  
  <p>Is there a problem with the way I did things or there is something else?</p>
  
  <p>Original code My Player class:</p>
  
  <pre><code>package com.triodefender.game;
  
  import java.util.Vector;
  import com.badlogic.gdx.graphics.Texture;
  import com.badlogic.gdx.graphics.g2d.Sprite;
  import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  import com.badlogic.gdx.graphics.g2d.TextureRegion;
  
  
  import jdk.nashorn.internal.runtime.Debug;
  
  public class Player {
      SpriteBatch batch = new SpriteBatch ();
      Sprite sprite = new Sprite ();
      //Animator animator;
      float cx, cy;
      float hp;
      Texture img = new Texture ("bullet.png"), imgp = new Texture("turret.png");
      Vector&lt;Bullet&gt; bullets = new Vector&lt;Bullet&gt;();
  
      void Debug () {
          Sprite debug = new Sprite (new Texture("debug.png"), 0, 0, 15, 15);
          debug.setPosition (sprite.getX(), sprite.getY());
          batch.begin ();
          debug.draw (batch);
          batch.end ();
  
          debug.setPosition (cx, cy);
          batch.begin ();
          debug.draw (batch);
          batch.end();
      }
  
      Player (com.badlogic.gdx.graphics.Color color) {
          //animator = new Animator(a);
      //sprite = new Sprite (imgp); //this works
          sprite = new Sprite ();
          sprite.setTexture(imgp); //this doesn't work
          sprite.setOriginCenter();
          sprite.setColor(color);
  
          hp = 100f;
      }
  
      void Update (float ox, float oy, float rotation, boolean shoot) {
          cx = ox; cy = oy;
  
          sprite.setPosition(ox - sprite.getWidth()/2, oy - sprite.getHeight()/2);
          sprite.setRotation(-rotation);
  
          if (shoot) {
              AddBullet();
              //animator.lockRow(0, 1, 5);
          }
  
          UpdateBullets();
      }
  
      void AddBullet () {
          float l = sprite.getWidth()/2f;
          float sn = (float) Math.sin(Math.toRadians(-sprite.getRotation()));
          float cs = (float)Math.cos(Math.toRadians( -sprite.getRotation() ));
  
          float newpx = cx + (float)(l+16f)*sn;
          float newpy = cy + (float)(l+16f)*cs;
  
  
          bullets.add(new Bullet(new Sprite(img), newpx, newpy, -sprite.getRotation(), 10f, sprite.getColor()));
      }
  
      void UpdateBullets () {
          for (int i = 0; i &lt; bullets.size(); i++)
              if (bullets.elementAt(i).Update() == false) {
                  bullets.remove(i);
                  i--;
              }
      }
  
      void DrawBullets () {
          for (int i = 0; i &lt; bullets.size(); i++)
              bullets.elementAt(i).Draw();
      }
  
      float getRotation () {
          return sprite.getRotation();
      }
  
      void Draw () {
          //Debug ();
          batch.begin();
          sprite.draw(batch);
          batch.end();
  
          DrawBullets ();
      }
  }
  </code></pre>