Skip to main content
Showed an example.
Source Link
Kylotan
  • 24.4k
  • 3
  • 55
  • 94

SDL_PollEvent will not change the content of the event you pass through if there is no new event to report. This means that type == SDL_KEYDOWN will stay true until some other event arrives.

You need to check the value returned from SDL_PollEvent and only continue on to your event handling code when there is a new event to handle.

eg.

if (SDL_PollEvent( &localEvent ) == 1)
{
    if ( localEvent.type == SDL_KEYDOWN )
    {
        if ( currentSplashImage < 3 && currentSplashImage >= 0)
        { 
            currentSplashImage++;
        }
    }
    else if ( localEvent.type == SDL_QUIT )
    {
        smgaEngine.setRunning(false);
    }
}

You may also consider using SDL_WaitEvent instead, which pauses the app until another event is available.

SDL_PollEvent will not change the content of the event you pass through if there is no new event to report. This means that type == SDL_KEYDOWN will stay true until some other event arrives.

You need to check the value returned from SDL_PollEvent and only continue on to your event handling code when there is a new event to handle.

You may also consider using SDL_WaitEvent instead.

SDL_PollEvent will not change the content of the event you pass through if there is no new event to report. This means that type == SDL_KEYDOWN will stay true until some other event arrives.

You need to check the value returned from SDL_PollEvent and only continue on to your event handling code when there is a new event to handle.

eg.

if (SDL_PollEvent( &localEvent ) == 1)
{
    if ( localEvent.type == SDL_KEYDOWN )
    {
        if ( currentSplashImage < 3 && currentSplashImage >= 0)
        { 
            currentSplashImage++;
        }
    }
    else if ( localEvent.type == SDL_QUIT )
    {
        smgaEngine.setRunning(false);
    }
}

You may also consider using SDL_WaitEvent instead, which pauses the app until another event is available.

Source Link
Kylotan
  • 24.4k
  • 3
  • 55
  • 94

SDL_PollEvent will not change the content of the event you pass through if there is no new event to report. This means that type == SDL_KEYDOWN will stay true until some other event arrives.

You need to check the value returned from SDL_PollEvent and only continue on to your event handling code when there is a new event to handle.

You may also consider using SDL_WaitEvent instead.