Does SDL timer sussystem have pause an restart timer function?

or , can you tech me how to do myself?

Thank you very mach.-----------------------------------------------------------------
< ??? Yahoo!?? > www.yahoo.com.tw

For “pausing” I would recommend keeping track of the time paused.

This can be done in a number of ways, I’ll show a simple way here to
give you the idea:

Uint32 timePaused=SDL_GetTicks(),pausedTime; //at the beggining

void Pause()
{
pausedTime = SDL_GetTicks();
}

void Restart()
{
timePaused = SDL_GetTicks();
}

void Unpause()
{
timePaused += SDL_GetTicks()-pausedTime;
}

Uint32 GetTime()
{
return SDL_GetTicks()-timePaused;
}

timePaused is used to keep track of the total time paused
pausedTime is the time the application was paused (yes, i should have
named it something else)

Also if you use this code I’d say to use a boolean value to check if the
timer is actually paused so you dont mess up your timer by unpausing.

My project ZEngine http://sourceforge.net/projects/zengine/ has a
relatively complete time system and class. Feel free to use some of my
source (or the entire engine) In your own programs.

leolarrel wrote:> or , can you tech me how to do myself?

Thank you very mach.


< ??? Yahoo!?? > www.yahoo.com.tw

I think Pause and Restart is an important function.
It should be add to SDL System.

Do you think ??-----------------------------------------------------------------
< ??? Yahoo!?? > www.yahoo.com.tw

I think Pause and Restart is an important function.
It should be add to SDL System.

Do you think ??

It is already there, that is what removeTimer and addTimer are for.
Those two functions and a little arithmetic do the job for you. If you
don’t like that then I don’t think anyone would try to stop you from
writing the code to add those functions to SDL.

	Bob PendletonOn Tue, 2002-10-22 at 06:00, leolarrel wrote:

< ??? Yahoo!?? > www.yahoo.com.tw


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±-----------------------------------+