我试图旋转一个纹理区域,基于box 2d身体角度,使用spriteBatcher绘制方法:
SpriteBatch.draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height,float scaleX, float scaleY, float rotation)
但是,生成的旋转如下所示
查看文档,分析SpriteBatch。但我不清楚原因是什么。
如何适当的旋转纹理?
编辑:我不能使用Sprite类,因为正在绘制的纹理区域是一个动画帧,并且您不能使用Sprite类制作动画帧
像这样设置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方法被重载。
原点在图像的左下角,将其放在图像的中心。因此,使原点X宽度/ 2和原点Y高度/ 2。