我有这段代码可以测试鼠标移动并更改相机,如果它:
POINT myMouse;
GetCursorPos(&myMouse);
float Sensitivity = 10;
if(myMouse.x != middleX || myMouse.y != middleY)
{
float DifferenceX = myMouse.x - middleX;
float DifferenceY = myMouse.y - middleY;
Rotation -> y += DifferenceX/Sensitivity;
Rotation -> x -= DifferenceY/Sensitivity;
if(Rotation -> x > 90) Rotation -> x = 90;
if(Rotation -> x < -90) Rotation -> x = -90;
if(Rotation -> y > 360) Rotation -> y = 0;
SetCursorPos(middleX, middleY);
}
由于某种原因,DifferenceX实际上是Y轴,而差异Y实际上是X轴。
为什么会这样?
答案 0 :(得分:4)
Rotation -> y += DifferenceX/Sensitivity;
//^^ y and x seems reversed
Rotation -> x -= DifferenceY/Sensitivity;
可能应该是
Rotation -> x += DifferenceX/Sensitivity;
Rotation -> y -= DifferenceY/Sensitivity;