基于 box2D body 角度旋转 textureRegion(无精灵)

Rotating textureRegion based on box2D body angle (without sprite)

我正在尝试使用 spriteBatcher 绘制方法基于 box2d body 角度旋转一个 textureRegion:

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

但是结果旋转看起来像这样

我不知道我做错了什么,尝试了很多不同的 originX、originY 组合,但它总是坏掉。试图将原点设置为 body 的中心,左下角,但没有成功。

查看了文档,分析了 SpriteBatch.class 但我不清楚原因是什么。

如何正确旋转贴图?

编辑:我不能使用 Sprite class,因为正在绘制的 textureRegion 是一个动画帧,而且你不能用 Sprite 制作动画帧 class

原点在图片的左下角,把它放在图片的中央。所以让 originX width/2 和 originY height/2.

像这样设置 box2d 体的多边形形状

float width=x,height=y;

PolygonShape polygonShape=new PolygonShape();
polygonShape.setAsBox(width/2, height/2,new Vector2(width/2,height/2),0);

PolygonShape 的setAsBox 方法被重载。