目前我正在研究可放大和縮小的遊戲編輯器。有問題,我可以做或者向上或向下滾動鼠標滾輪。我無法實現滾動,即如果我在編輯器類中調用input->mouseWheelUp()
,我只能向上滾動。向下滾動不起作用了。我該如何解決這個問題?在編輯器的update
方法鼠標滾輪只能向上或向下滾動
獲取鼠標滾輪meesage
LRESULT Game::messageHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (initialized) // do not process messages if not initialized
{
switch (msg)
{
case WM_MOUSEWHEEL:
input->mouseWheelIn(wParam);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam); // let Windows handle it
}
Input類
void Input::mouseWheelIn(WPARAM wParam)
{
mouseWheel = GET_WHEEL_DELTA_WPARAM(wParam);
}
bool mouseWheelUp()
{
int wheel = mouseWheel;
mouseWheel = 0;
return wheel > 0;
}
bool mouseWheelDown()
{
int wheel = mouseWheel;
mouseWheel = 0;
return wheel < 0;
}
Editor類
void Editor::update()
{
if (input->mouseWheelUp())
{
zoom += 0.1f;
}
if (input->mouseWheelDown())
{
zoom -= 0.1f;
}
}