Reputation: 90
I have an image which is 100x100 size. I want to use the whole image but with size of 50x50. When I try to use it, it crops my image and uses only 1/4 of the image (top - left corner).
Texture img = new Texture("snake.png");
Sprite mySnake = new Sprite(img);
I have tried using mySnake.setSize(50,50)
but it doesn't do anything.
Upvotes: 4
Views: 8880
Reputation: 949
You can scale sprite like:
Set the Actor's scale: sprite.setScale(factor);
With animation: Use Tween engine (LibGDX animation library)
Use a custom width in your SpriteBatch call: batch.draw(Sprite, float x, float y, float width, float height);
Upvotes: 2