如何在使用后退调整精灵的大小后旋转精灵?(LIBGDX)
我有一个位图(png)加载到我的精灵中,具有特定的大小(200)和100/100的旋转中心:如何在使用后退调整精灵的大小后旋转精灵?(LIBGDX),libgdx,sprite,Libgdx,Sprite,我有一个位图(png)加载到我的精灵中,具有特定的大小(200)和100/100的旋转中心: Sprite round = loadSprite(200,200); round.setPosition(x,y) 旋转round.setRotation()时,精灵围绕正确的中心旋转 现在我想将精灵的大小调整为一个新的大小(400400),并且仍然希望围绕中心旋转(200/200): 再次旋转时,它仍围绕旧中心100/100旋转 如何正确执行此操作?设置精灵的中心(x,y)设置精灵的位置,使其位于
Sprite round = loadSprite(200,200);
round.setPosition(x,y)
旋转round.setRotation()
时,精灵围绕正确的中心旋转
现在我想将精灵的大小调整为一个新的大小(400400),并且仍然希望围绕中心旋转(200/200):
再次旋转时,它仍围绕旧中心100/100旋转
如何正确执行此操作?设置精灵的中心(x,y)
设置精灵的位置,使其位于该位置的中心:
/** Sets the position so that the sprite is centered on (x, y) */
public void setCenter(float x, float y){
...
}
您需要函数setOrigin(originX,originY)
:
/** Sets the position so that the sprite is centered on (x, y) */
public void setCenter(float x, float y){
...
}
/** Sets the origin in relation to the sprite's position for scaling and rotation. */
public void setOrigin (float originX, float originY) {
...
}