[英]create multiple textures with rotation of original texture and save them in a list
Not sure if I am on the right way. 不确定我的方法是否正确。
I have a smal texture which I draw multiple times (1000). 我有一个小的纹理,我绘制了多次(1000)。 But I like to have them with different rotations (around 10) for that texture.
但是我喜欢让它们的纹理具有不同的旋转角度(大约10度)。 So I thought to rotate the textures and save the in a list (10) for the reuse (performance).
所以我想旋转纹理并将其保存在列表(10)中,以供重用(性能)使用。
When my approach is good, how can I rotate an original texture and store it to a new texture (in memory during start) ? 当我的方法很好时,如何旋转原始纹理并将其存储到新纹理(在启动过程中存储在内存中)?
You can use Sprite class that wraps a Texture and provides many useful methods to work with it. 您可以使用包装了Texture的Sprite类,并提供许多有用的方法来处理它。 For example: scaling, rotating.
例如:缩放,旋转。
So you will have one Texture instance and 10 sprites. 因此,您将有一个Texture实例和10个Sprite。
Texture texture = new Texture("path.png");
for (int i = 0; i < 10; i++) {
Sprite sprite = new Sprite(texture);
sprite.setSize(..);
sprite.setRotation(..);
someList.add(sprite);
}
And then you can just select which sprite you want set it's position and draw it: 然后,您可以选择要设置其位置的精灵并绘制它:
sprite.draw(spriteBatch);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.