0

我有这段代码应该测试鼠标移动并改变相机,如果它这样做:

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 轴,DifferenceY 实际上是 X 轴。

为什么是这样?

4

1 回答 1

4
 Rotation -> y += DifferenceX/Sensitivity;
           //^^ y and x seems reversed
 Rotation -> x -= DifferenceY/Sensitivity;

可能应该是

 Rotation -> x += DifferenceX/Sensitivity;
 Rotation -> y -= DifferenceY/Sensitivity;
于 2013-04-21T23:40:19.660 回答