简体   繁体   English

在Libgdx Java中翻转纹理

[英]Flipping a Texture in Libgdx Java

I am trying to figure out how to flip a Texture in libgdx using Java. 我试图弄清楚如何使用Java在libgdx中翻转Texture I can't find any methods of doing this and I can't just do some code to flip the Texture itself. 我找不到任何这样做的方法,我不能只是做一些代码来翻转Texture本身。 Is there any way that I can flip the texture some way in libgdx? 有没有什么方法可以在libgdx中以某种方式翻转纹理?

You can make a Sprite object and when you initialize it, you can pass in the Texture object. 您可以创建一个Sprite对象,并在初始化它时,可以传入Texture对象。 Then you can call methods such as rotate, flip, etc. Here is a code example 然后你可以调用旋转,翻转等方法。下面是一个代码示例

    Texture tex = new Texture("path");
    Sprite sprite = new Sprite(tex);
    sprite.flip(true, false);

true as the first parameter for flipping over x-axis and false for y-axis, which is what you are looking for in your specific example. true表示翻转x轴的第一个参数,y轴表示false,这是您在特定示例中要查找的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM