Search code examples
javaandroidlibgdxpolygon

PolygonSprite in LibGdx shows only part of the Texture.


i have got this beautiful looking image:

enter image description here

I decided to use the PolygonSprite class in LiGgdx to display a part of that Image.

It ended up looking like that: enter image description here

As you can see the very left corner of my image is visible.

Here comes my question: What can i do to display a larger part of that image inside the polygonSprite above, without changing the polygonSprite's size ?

I do really appreciate any answer and please don't hesitate to ask if something isn't clear.


Solution

  • I've never used it myself, but looking at the documentation it looks like this: you have to create the polygonsprite with a correct polygonregion (vertices with pixel coordinates of the texture) and then use setSize to "scale" it to the size you want to display it (world/viewport coordinates).