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.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.