Remove a timer created with SDL_AddTimer().
Defined in SDL_timer.h
SDL_bool SDL_RemoveTimer(SDL_TimerID id);
id | the ID of the timer to remove |
Returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't found.
This function is available since SDL 2.0.0.
// Function to be called after a certain time
void* name) {
Uint32 callback(Uint32 interval,
"Hello %s!\n", (const char*)name);
printf(
return 0;
}
/* ... */
// Initialize timer
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
"SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) failed: %s", SDL_GetError());
SDL_Log(
}
/* ... */
// Set timer to 1 second
1000, callback, "SDL");
SDL_TimerID timerID = SDL_AddTimer(
// Main loop
SDL_bool quit;while(!quit) {
/* ... */
}
// Remove timer after main loop
SDL_RemoveTimer(timerID);
CategoryAPI, CategoryAPIFunction