gpt4 book ai didi

java - java LibGDX 中的旋转 Sprite

转载 作者:行者123 更新时间:2023-12-01 12:45:58 25 4
gpt4 key购买 nike

拥有定义纹理的 Sprite 的资源类,然后将 Sprite 作为该纹理表,并带有该表的坐标。这是我想要旋转的 Sprite 。我得到了使用 Sprite Batch 旋转它的建议(它旋转到我的触摸输入:

batch.draw(TextureRegion region,
float x,
float y,
float originX,
float originY,
float width,
float height,
float scaleX,
float scaleY,
float rotation)

我收到错误:

SpriteBatch 类型中的方法 draw(Texture, float, float, int, int, int, int) 不适用于参数 (Sprite, int, int, int, int、int、int、int、float)

有没有一种方法可以将 Sprite 转换到纹理上,或者有更好的方法来旋转它,但它不起作用,请帮忙!

最佳答案

您可以简单地使用旋转(浮点度数)。设置 Sprite 相对于当前旋转的旋转角度。

您必须在类的渲染方法中使用旋转(浮点度数)。

Sprite Class documentation中给出的

关于java - java LibGDX 中的旋转 Sprite ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24706604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com