Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Libgdx 使用批处理绘制围绕中心旋转图像_Libgdx - Fatal编程技术网

Libgdx 使用批处理绘制围绕中心旋转图像

Libgdx 使用批处理绘制围绕中心旋转图像,libgdx,Libgdx,我编写了上面的代码,用于围绕任意点旋转纹理。我的问题是,当纹理围绕中心点旋转时,纹理不围绕中心点旋转。使用精灵。并根据要旋转的点更改中心 您需要的是setCenter功能。将圆心设置为图像(注释中的图像)中圆的圆心。然后使用sprite.draw(…)函数 精灵非常有用,可以节省您的时间。您可能需要更改一些代码和/或删除一些代码。您的意思是什么?解释旋转方式。我希望出现这种情况->但我的代码是,立方体的边不按照中心旋转。transform.position.set(rotatedX,rota

我编写了上面的代码,用于围绕任意点旋转纹理。我的问题是,当纹理围绕中心点旋转时,纹理不围绕中心点旋转。

使用精灵。并根据要旋转的点更改中心

您需要的是
setCenter
功能。将圆心设置为图像(注释中的图像)中圆的圆心。然后使用
sprite.draw(…)
函数


精灵非常有用,可以节省您的时间。您可能需要更改一些代码和/或删除一些代码。

您的意思是什么?解释旋转方式。我希望出现这种情况->但我的代码是,立方体的边不按照中心旋转。transform.position.set(rotatedX,rotatedY);sprite.setOrigin(bird.center.x,bird.center.y);设置位置(transform.position.x,transform.position.y);雪碧.抽(批);我照你说的做了。但它不起作用。@SemihY使用旋转函数。我不知道我必须说使用旋转函数。我以为你能弄明白。对不起,我弄错了。我在你说之前就做了。但它不旋转(你能给出旋转的代码示例吗
float rotateBy= (float) (bird.clockWise?(-1):(1)*1/deltaTime*(Math.PI/180))/30;


float rotatedX = (float) (Math.cos(rotateBy) * (transform.position.x - bird.center.x) - Math.sin(rotateBy) * (transform.position.y-bird.center.y) + bird.center.x);
float rotatedY = (float) (Math.sin(rotateBy) * (transform.position.x - bird.center.x) + Math.cos(rotateBy) * (transform.position.y - bird.center.y) + bird.center.y);
transform.position.set(rotatedX, rotatedY);
Gdx.app.log("RenderingSystem","Rotate:"+rotatedX);
batch.draw(texture.textRegion,transform.position.x,transform.position.y,bird.center.x,bird.center.y
        ,texture.textRegion.getRegionWidth(),texture.textRegion.getRegionHeight(),1,1,  MathUtils.radiansToDegrees * rotateBy);