无法轮询 SDL 中的鼠标单击事件
我的代码
int userinput()
{
while(hasquit == false)
{
while ( SDL_PollEvent(&event) )
{
if ( event.type == SDL_QUIT )
{
hasquit = true;
}
if ( event.type == SDL_KEYDOWN )
{
if ( event.key.keysym.sym == SDLK_ESCAPE )
{
hasquit = true;
}
if(event.type == SDL_MOUSEBUTTONDOWN)
{
if(event.button.button == SDL_BUTTON_LEFT)
{
//do something
}
}
}
}
}
}
几乎是从这些教程复制的事件结构。我可以获得 SDL_QUIT 和 SDLK_ESCAPE 事件,但如果我尝试
hasquit = true
使用任一鼠标按钮 if 语句,则不会发生任何情况。
I have the code
int userinput()
{
while(hasquit == false)
{
while ( SDL_PollEvent(&event) )
{
if ( event.type == SDL_QUIT )
{
hasquit = true;
}
if ( event.type == SDL_KEYDOWN )
{
if ( event.key.keysym.sym == SDLK_ESCAPE )
{
hasquit = true;
}
if(event.type == SDL_MOUSEBUTTONDOWN)
{
if(event.button.button == SDL_BUTTON_LEFT)
{
//do something
}
}
}
}
}
}
which is pretty much an event structure I copied from these tutorials. I can get the SDL_QUIT and SDLK_ESCAPE events, but if I try to make
hasquit = true
with either of the mousebutton if statements, nothing happens.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你拥有
街区内部
。它应该是分开的。
这应该有效:
You have the
inside the
block. It should be separate.
This should work: