1
\$\begingroup\$

I'm learning libgdx and don't understand the purpose of parameters passed to flip(boolean x, boolean y). For example, I have code like this:

texture = new Texture(Gdx.files.internal("data/texture.png"));
textureRegion = new TextureRegion(texture, 0, 0, 20, 20);
textureRegion.flip(false, false);

My TextureRegion is flipped when both parameters are true and not flipped when they are false. But why does it need two parameters when it could have only one? The documentation says nothing about that.

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

textureRegion.flip(false, false); this will keep the original image as it is.

sample

textureRegion.flip(true,false) it will mirror the image as below.ie it will flip the original image horizontally and preserve its y direction. enter image description here

textureRegion.flip(false,true) ; it will flip the original image vertically and preserve its x direction

enter image description here

textureRegion.flip(ture,true) ; it will flip the original image vertically and horizontally enter image description here

\$\endgroup\$
3
\$\begingroup\$

The parameters control which axis the image will be flipped around; sometimes you only want to flip around one or the other axis, instead of both.

The first parameter, if true, causes the image to be flipped in the X direction (horizontal flip) The second parameter, if true, causes the image to be flipped in the Y direction (vertical flip).

If both are true, the image is flipped around both axes.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .