user3396986
user3396986

Reputation: 23

how re-size a texture in libgdx

I have a .png image that I need to re-size to an integer scale that I have defined. I need to re-size it for use in a TextureAtlas to make a button.

buttonAtlas.addRegion(colors[i], new Texture(colors[i] + ".png"),00,00,scale,scale);

I do this and it cuts it up. Is there a way to do this? I have also tried all the methods in the texture-region class.

Upvotes: 2

Views: 2402

Answers (1)

asherbret
asherbret

Reputation: 6018

The signature of the method you're using is (from the docs):

addRegion(java.lang.String name, Texture texture, int x, int y, int width, int height)

From the names of the arguments it's clear that the two last arguments have nothing to do with scaling (as your code suggests) but rather define the width and height of the region.

If you want to resize your texture, I suggest you use Sprite:

Sprite sprite = new Sprite(new Texture(colors[i] + ".png")); // Creates a sprite from a Texture
sprite.scale(scale); // Scale the sprite

Upvotes: 1

Related Questions