晚安的朋友。libgdx固定点camera.rotateAround
我无法在屏幕旋转时在屏幕上绘制固定点。我从玩家的位置使用了“rotateAround”方法。
在我看来。我必须从玩家的位置旋转这个固定点。我用这个在这里学习的弹力在stackoverflow。
public void rotate(Vector3 position, Vector3 centerPoint){
this.cosTemp = MathUtils.cosDeg(this.anguloAtual);
this.senTemp = MathUtils.sinDeg(this.anguloAtual);
this.xTemp = centerPoint.x + ((position.x - centerPoint.x) * this.cosTemp) - ((position.y - centerPoint.y) * this.senTemp);
this.yTemp = centerPoint.y + ((position.y - centerPoint.y) * this.cosTemp) + ((position.x - centerPoint.x) * this.senTemp);
position.set(this.xTemp, this.yTemp, 0);
}
在屏幕上显示的玩家。我使用了播放器的位置,然后调用“camera.project”,然后使用“旋转”方法。固定点出现,但它不完全固定。 我使用稍微超前玩家的固定点的例子。
public void meDesenhar(SpriteBatch spriteBatch) {
spriteBatch.begin();
this.spritePlayer.setPosition(this.positionPlayer.x - (this.spritePlayer.getWidth()/2),
this.positionPlayer.y - this.spritePlayer.getHeight()/2);
this.spritePlayer.draw(spriteBatch);
spriteBatch.end();
originPosition.set(positionPlayer, 0);
fixedPosition.set(positionPlayer.x, positionPlayer.y + 10, 0);
cameraTemp.project(fixedPosition);
cameraTemp.project(originPosition);
cameraManagerTemp.rotate(fixedPosition, originPosition);
Debugagem.drawPointInScreen(Color.BLUE, fixedPosition);
}
我的问题:
1 - 我做错了什么,或者只是它是四舍五入的结果?我在调试时意识到。在“camera.project”之后,玩家的位置每转一圈都会改变一下。示例位置(540,320)转动(539.99,320.013)
2 - 我尝试使用并享受SpriteBatch绘制方法来执行旋转,但是无法从播放器进行旋转。我会得到同样的结果。
3 - 我可以使用两个摄像头吗?每个相机将是一个图层。在地图上的相机和玩家会。另一个是固定点。它是可行的?我找不到可以同时处理多个相机的任何示例。任何人都请知道任何例子。我不是在谈论悬挂式或摄像机的舞台。
视频如下。
https://www.youtube.com/watch?v=1Vg8haN5ULE
谢谢。
丹尼斯再次感谢你。当我回家时,我会尝试。有什么地方可以看到你的比赛吗? – Lovera
它工作得很好。非常感谢你。 – Lovera