如何正确使用SDL_MOUSEBUTTONDOWN?

时间:2015-09-20 04:37:01

标签: c++ c sdl

我试图在游戏中使用鼠标的x和y坐标,但我无法获得坐标。

这是我一直在阅读的事件:

typedef struct{
    Uint8 type;
    Uint8 button;
    Uint8 state;
    Uint16 x, y;
} SDL_MouseButtonEvent;

我需要类似的东西:

if(SDL_MouseButtonEvent.x >= 100)
{
//do something
}

我认为sintax非常不同,因为我看到了一些使用SDL_MOUSEBUTTONDOWN的例子。

修改

我道歉,知道这个问题可能不太清楚,但彼得的回答正是我需要的,谢谢你的时间。

2 个答案:

答案 0 :(得分:2)

如果您想首先拦截特定区域的点击,您需要轮询事件并检查SDL_MouseButtonEvent。

$app['model']->Post

我希望这会有所帮助。

答案 1 :(得分:2)

快速精确度:recvfrom()已被event.mouse.xevent.motion.x替换为分别为event.motion.xrel的绝对和相对鼠标移动。

相关问题