你好,我正在使用Libgdx框架为Android创建一个游戏。我想把一个精灵放在屏幕顶部靠近X轴中心的位置。虽然我可以做到这一点,但是由于精灵需要旋转90度(为了在精灵表上节省空间),它会导致某种偏移,而我不明白为什么会这样。我认为这是因为原点旋转的缘故,但是我已经尝试将原点设置为精灵的中心,但仍未按计划工作。请帮助我理解为什么旋转会导致偏移,以及如何解决这个问题,谢谢。
regions [1] = new TextureRegion(menu, 395, 0, 115, 320);
logo=new Sprite(regions[1]);// the sprite
logo.setPosition(W/2-logo.getWidth()/2,H*0.95f); //draw right in the middle of X and 95% up Y
logo.rotate(90); //rotate the sprite 90 degrees
logo.setOrigin(logo.getWidth()/2,logo.getHeight()/2); //rotate around the centre of the sprite
logo.draw(spriteBatch); //in render method draw the sprite