title: LibGDX Scaling and Rendering Sprites from TextureAtlas
body: <p>I am currently experiencing issues when drawing and scaling sprites.</p>
  <p>I am loading my assets from a texture-atlas, which I packed no problem with the LibGDX texture packer gui tool. My texture atlas image currently looks like this.
  <img src="https://i.stack.imgur.com/CZhPp.png" alt="pack iamge" /></p>
  <p>These images are supposed to be buttons, but as you can see, the image is very small, so when the sprites are loaded, they load a sprite of say, 34x16 pixels. When I render these buttons, on a canvas of 1920x1080, they are much too small. I use <code>sprite.scale(int scale)</code> to scale the sprites, but when I scale them, they appear blurry. What I would like to happen, is when they are scaled, each pixel is scaled proportionally, keeping the pixelated effect on the button, rather than a blurry resized image from a really small texture. I currently render the sprites using <code>sprite.render(SpriteBatch batch)</code>. Is this the proper way of rendering a sprite, after they are loaded using <code>atlas.createSprite(String name)</code>? I am new to using sprites, and loading textures from a texture-atlas, so i am wondering if this is the correct way of doing things.</p>
  <p>Also, when I initialize my game, I load numerous different <code>Sprite</code> objects from a TextureAtlas. Each sprite holds a texture that will represent a game object, however it is my understanding that you render a sprite using <code>sprite.render(SpriteBatch batch)</code>, so therefore I could only use a sprite, loaded from the <code>TextureAtlas</code> for one game object, because I would also have to set the scale, and position of the sprite, as it represents the game object. I am used to loading a <code>Texture</code>, then rendering this texture using <code>batch.render()</code>, at a given position, but I don't see how this is possible if I am using a sprite. Even if I use <code>batch.render(Sprite, x, y)</code>, I am unable to scale the sprite properly, because as I mentioned before, I would like to scale the sprite while maintaining a pixelated effect, and even so, using the <code>Sprite.scale()</code> method, this would scale the Sprite object as a whole, making it impossible to use the <code>Sprite</code>'s texture multiple times for numerous game objects.</p>
  <p>Any suggestions would be greatly appreciated.</p>
  <p>The code I am currently using to render/load the sprites is as follows:</p>
  <p>Loading from TextureAtlas:</p>
  <pre><code>public static TextureAtlas atlas = new TextureAtlas(Gdx.files.internal(&quot;data/texture/pack/output/pack.pack&quot;));
      
  public static Sprite sprite = atlas.createSprite(&quot;buttonUp&quot;);
  sprite.setScale(10);
  </code></pre>
  <p>Rendering Sprite: GdxGame.WIDTH/HEIGHT are 1920x1080. Though the Desktop window is scaled down from that size. Thus, everything is rendered as if the screen were 1920x1080.</p>
  <pre><code>    batch = new SpriteBatch();
      camera = new OrthographicCamera(GdxGame.WIDTH, GdxGame.HEIGHT);
      camera.position.set(GdxGame.WIDTH/2, GdxGame.HEIGHT/2, 0);
      camera.setToOrtho(false, GdxGame.WIDTH, GdxGame.HEIGHT);
      
  public void render(float delta){
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      batch.setProjectionMatrix(camera.combined);
      batch.begin();
              
      camera.update();
      sprite.draw(batch);
              
      batch.end();
  }
  </code></pre>
  <p>After further investigation, I have discovered that I can use <code>Sprite.set(Sprite sprite)</code> to make <code>Sprite x</code> a copy of <code>Sprite y</code>, and therefore render each sprite multiple times. However, this does not solve the issue of scaling the sprite. I must emphasize further that when rendering a scaled sprite, the scaling is not done by pixel, meaning that it is blurry. But, when rendering a <code>TextureRegion</code>, like: <code>batch.draw(TextureRegion, x, y, width, height)</code> if the width and height are greater than that of the original texture, it will scale each pixel, rather than blur the whole thing to try and make it look better. The following is an image of the blurriness I am talking about:</p>
  <p><img src="https://i.stack.imgur.com/MXakR.png" alt="enter image description here" /></p>
  <p>Notice how this sprite is scaled to be blurry, even though the original image is small, and pixelated.</p>