#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
void cIntroState::HandleEvents()
{
RECT clientRect;
GetWindowRect(m_GameEngine->GethWnd(), &clientRect);
GetCursorPos(&mousePos);
POINT relMousePos;
relMousePos.x = mousePos.x - clientRect.left;
relMousePos.y = mousePos.y - clientRect.top;
static bool StartButtonDown = false;
if(KEY_DOWN(VK_LBUTTON))
{
if(relMousePos.x< 180 && relMousePos.x > 140 && relMousePos.y < 250 && relMousePos.y > 225 && StartButtonDown == false)
{
StartButtonDown = true;
}
}
if(KEY_UP(VK_LBUTTON))
{
if(relMousePos.x< 180 && relMousePos.x > 140 && relMousePos.y < 250 && relMousePos.y > 225 && StartButtonDown)
{
cPlayState *playState = new cPlayState;
m_GameEngine->getStateManagerPtr()->PushState(playState);
}
StartButtonDown = false;
}
}
button problem
Normally one responds to these sorts of things via Windows messages, which basically takes care of the issue for you -- assuming you are using actual Win32 button controls and the like.
Otherwise, you will basically need to track which control the mouse is currently over (by checking when the mouse moves) and if the button is down and mouse hasn't been captured and the mouse leaves the control, cancel the is-down state.
If you're using Win32 buttons and Windows messages, this is much easier.
Otherwise, you will basically need to track which control the mouse is currently over (by checking when the mouse moves) and if the button is down and mouse hasn't been captured and the mouse leaves the control, cancel the is-down state.
If you're using Win32 buttons and Windows messages, this is much easier.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement