0
|
1 <HTML
|
|
2 ><HEAD
|
|
3 ><TITLE
|
|
4 >Time</TITLE
|
|
5 ><META
|
|
6 NAME="GENERATOR"
|
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61
|
|
8 "><LINK
|
|
9 REL="HOME"
|
|
10 TITLE="SDL Library Documentation"
|
|
11 HREF="index.html"><LINK
|
|
12 REL="UP"
|
|
13 TITLE="SDL Reference"
|
|
14 HREF="reference.html"><LINK
|
|
15 REL="PREVIOUS"
|
|
16 TITLE="SDL_CondWaitTimeout"
|
|
17 HREF="sdlcondwaittimeout.html"><LINK
|
|
18 REL="NEXT"
|
|
19 TITLE="SDL_GetTicks"
|
|
20 HREF="sdlgetticks.html"><META
|
|
21 NAME="KEYWORD"
|
|
22 CONTENT="time"><META
|
|
23 NAME="KEYWORD"
|
|
24 CONTENT="function"></HEAD
|
|
25 ><BODY
|
|
26 CLASS="CHAPTER"
|
|
27 BGCOLOR="#FFF8DC"
|
|
28 TEXT="#000000"
|
|
29 LINK="#0000ee"
|
|
30 VLINK="#551a8b"
|
|
31 ALINK="#ff0000"
|
|
32 ><DIV
|
|
33 CLASS="NAVHEADER"
|
|
34 ><TABLE
|
|
35 WIDTH="100%"
|
|
36 BORDER="0"
|
|
37 CELLPADDING="0"
|
|
38 CELLSPACING="0"
|
|
39 ><TR
|
|
40 ><TH
|
|
41 COLSPAN="3"
|
|
42 ALIGN="center"
|
|
43 >SDL Library Documentation</TH
|
|
44 ></TR
|
|
45 ><TR
|
|
46 ><TD
|
|
47 WIDTH="10%"
|
|
48 ALIGN="left"
|
|
49 VALIGN="bottom"
|
|
50 ><A
|
|
51 HREF="sdlcondwaittimeout.html"
|
|
52 >Prev</A
|
|
53 ></TD
|
|
54 ><TD
|
|
55 WIDTH="80%"
|
|
56 ALIGN="center"
|
|
57 VALIGN="bottom"
|
|
58 ></TD
|
|
59 ><TD
|
|
60 WIDTH="10%"
|
|
61 ALIGN="right"
|
|
62 VALIGN="bottom"
|
|
63 ><A
|
|
64 HREF="sdlgetticks.html"
|
|
65 >Next</A
|
|
66 ></TD
|
|
67 ></TR
|
|
68 ></TABLE
|
|
69 ><HR
|
|
70 ALIGN="LEFT"
|
|
71 WIDTH="100%"></DIV
|
|
72 ><DIV
|
|
73 CLASS="CHAPTER"
|
|
74 ><H1
|
|
75 ><A
|
|
76 NAME="TIME"
|
|
77 >Chapter 13. Time</A
|
|
78 ></H1
|
|
79 ><DIV
|
|
80 CLASS="TOC"
|
|
81 ><DL
|
|
82 ><DT
|
|
83 ><B
|
|
84 >Table of Contents</B
|
|
85 ></DT
|
|
86 ><DT
|
|
87 ><A
|
|
88 HREF="sdlgetticks.html"
|
|
89 >SDL_GetTicks</A
|
|
90 > — Get the number of milliseconds since the SDL library initialization.</DT
|
|
91 ><DT
|
|
92 ><A
|
|
93 HREF="sdldelay.html"
|
|
94 >SDL_Delay</A
|
|
95 > — Wait a specified number of milliseconds before returning.</DT
|
|
96 ><DT
|
|
97 ><A
|
|
98 HREF="sdladdtimer.html"
|
|
99 >SDL_AddTimer</A
|
|
100 > — Add a timer which will call a callback after the specified number of milliseconds has
|
|
101 elapsed.</DT
|
|
102 ><DT
|
|
103 ><A
|
|
104 HREF="sdlremovetimer.html"
|
|
105 >SDL_RemoveTimer</A
|
|
106 > — Remove a timer which was added with
|
|
107 <A
|
|
108 HREF="sdladdtimer.html"
|
|
109 >SDL_AddTimer</A
|
|
110 >.</DT
|
|
111 ><DT
|
|
112 ><A
|
|
113 HREF="sdlsettimer.html"
|
|
114 >SDL_SetTimer</A
|
|
115 > — Set a callback to run after the specified number of milliseconds has
|
|
116 elapsed.</DT
|
|
117 ></DL
|
|
118 ></DIV
|
|
119 ><P
|
|
120 >SDL provides several cross-platform functions for dealing with time.
|
|
121 It provides a way to get the current time, a way to wait a little while,
|
|
122 and a simple timer mechanism. These functions give you two ways of moving an
|
|
123 object every x milliseconds:
|
|
124
|
|
125 <P
|
|
126 ></P
|
|
127 ><UL
|
|
128 ><LI
|
|
129 ><P
|
|
130 >Use a timer callback function. This may have the bad effect that it runs in a seperate thread or uses alarm signals, but it's easier to implement.</P
|
|
131 ></LI
|
|
132 ><LI
|
|
133 ><P
|
|
134 >Or you can get the number of milliseconds passed, and move the object if, for example, 30 ms passed.</P
|
|
135 ></LI
|
|
136 ></UL
|
|
137 > </P
|
|
138 ></DIV
|
|
139 ><DIV
|
|
140 CLASS="NAVFOOTER"
|
|
141 ><HR
|
|
142 ALIGN="LEFT"
|
|
143 WIDTH="100%"><TABLE
|
|
144 WIDTH="100%"
|
|
145 BORDER="0"
|
|
146 CELLPADDING="0"
|
|
147 CELLSPACING="0"
|
|
148 ><TR
|
|
149 ><TD
|
|
150 WIDTH="33%"
|
|
151 ALIGN="left"
|
|
152 VALIGN="top"
|
|
153 ><A
|
|
154 HREF="sdlcondwaittimeout.html"
|
|
155 >Prev</A
|
|
156 ></TD
|
|
157 ><TD
|
|
158 WIDTH="34%"
|
|
159 ALIGN="center"
|
|
160 VALIGN="top"
|
|
161 ><A
|
|
162 HREF="index.html"
|
|
163 >Home</A
|
|
164 ></TD
|
|
165 ><TD
|
|
166 WIDTH="33%"
|
|
167 ALIGN="right"
|
|
168 VALIGN="top"
|
|
169 ><A
|
|
170 HREF="sdlgetticks.html"
|
|
171 >Next</A
|
|
172 ></TD
|
|
173 ></TR
|
|
174 ><TR
|
|
175 ><TD
|
|
176 WIDTH="33%"
|
|
177 ALIGN="left"
|
|
178 VALIGN="top"
|
|
179 >SDL_CondWaitTimeout</TD
|
|
180 ><TD
|
|
181 WIDTH="34%"
|
|
182 ALIGN="center"
|
|
183 VALIGN="top"
|
|
184 ><A
|
|
185 HREF="reference.html"
|
|
186 >Up</A
|
|
187 ></TD
|
|
188 ><TD
|
|
189 WIDTH="33%"
|
|
190 ALIGN="right"
|
|
191 VALIGN="top"
|
|
192 >SDL_GetTicks</TD
|
|
193 ></TR
|
|
194 ></TABLE
|
|
195 ></DIV
|
|
196 ></BODY
|
|
197 ></HTML
|
|
198 > |