SDL_WaitEvent:如何杀死队列中的所有内容?
我在我的主循环中使用它:
if (SDL_WaitEvent(&event)) {
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
mainClicker(event.button.x, event.button.y);
break;
..... etc
一切正常,但是:
在“屏幕 1”中,用户执行操作并单击按钮。然后应用程序执行其操作并显示带有其他按钮的结果屏幕。问题是,如果您在结果屏幕完全显示之前意外单击(2-5 秒 - 使用 SDL_Delay),MOUSEBUTTONDOWN 会被存储(缓存),然后立即在屏幕 2 中使用。因此,如果您足够“幸运”,您甚至可以在某些 screen2 按钮显示之前单击它们。
有没有办法清除SDL事件队列(不确定它实际上是如何调用的)?
谢谢。
I'm using this in my main loop:
if (SDL_WaitEvent(&event)) {
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
mainClicker(event.button.x, event.button.y);
break;
..... etc
Everything works fine, but:
In "screen 1" user does stuff and clicks a button. The app then does its stuff and shows a result screen with other buttons. The problem is that if you accidentally click before the result screen is fully displayed (2-5 seconds - using SDL_Delay), MOUSEBUTTONDOWN is kinda stored (cached) and then immediately used in screen 2. So if you're "lucky" enough, you can click some of the screen2 buttons even before they're displayed.
Is there a way how to clear SDL event queue (not sure how it's actually called)?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理事件以激活结果屏幕后,请在处理下一个事件之前调用此方法:
在结果屏幕加载后,调用:
After you process the event to active the result screen, call this before processing the next event:
After the result screen has loaded, call: