tags:

views:

25

answers:

1

Hi,

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.

+1  A: 

After you process the event to active the result screen, call this before processing the next event:

SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);

After the result screen has loaded, call:

SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_ENABLE);
Matt Joiner