Mercurial > sdl-ios-xcode
annotate docs/html/sdlsettimer.html @ 432:80a35d43a58f
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 01 Aug 2002 23:08:41 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_SetTimer</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="Time" | |
14 HREF="time.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_RemoveTimer" | |
17 HREF="sdlremovetimer.html"></HEAD | |
18 ><BODY | |
19 CLASS="REFENTRY" | |
20 BGCOLOR="#FFF8DC" | |
21 TEXT="#000000" | |
22 LINK="#0000ee" | |
23 VLINK="#551a8b" | |
24 ALINK="#ff0000" | |
25 ><DIV | |
26 CLASS="NAVHEADER" | |
27 ><TABLE | |
28 WIDTH="100%" | |
29 BORDER="0" | |
30 CELLPADDING="0" | |
31 CELLSPACING="0" | |
32 ><TR | |
33 ><TH | |
34 COLSPAN="3" | |
35 ALIGN="center" | |
36 >SDL Library Documentation</TH | |
37 ></TR | |
38 ><TR | |
39 ><TD | |
40 WIDTH="10%" | |
41 ALIGN="left" | |
42 VALIGN="bottom" | |
43 ><A | |
44 HREF="sdlremovetimer.html" | |
45 >Prev</A | |
46 ></TD | |
47 ><TD | |
48 WIDTH="80%" | |
49 ALIGN="center" | |
50 VALIGN="bottom" | |
51 ></TD | |
52 ><TD | |
53 WIDTH="10%" | |
54 ALIGN="right" | |
55 VALIGN="bottom" | |
56 > </TD | |
57 ></TR | |
58 ></TABLE | |
59 ><HR | |
60 ALIGN="LEFT" | |
61 WIDTH="100%"></DIV | |
62 ><H1 | |
63 ><A | |
64 NAME="SDLSETTIMER" | |
65 >SDL_SetTimer</A | |
66 ></H1 | |
67 ><DIV | |
68 CLASS="REFNAMEDIV" | |
69 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
70 NAME="AEN8169" |
0 | 71 ></A |
72 ><H2 | |
73 >Name</H2 | |
74 >SDL_SetTimer -- Set a callback to run after the specified number of milliseconds has | |
75 elapsed.</DIV | |
76 ><DIV | |
77 CLASS="REFSYNOPSISDIV" | |
78 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
79 NAME="AEN8172" |
0 | 80 ></A |
81 ><H2 | |
82 >Synopsis</H2 | |
83 ><DIV | |
84 CLASS="FUNCSYNOPSIS" | |
85 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
86 NAME="AEN8173" |
0 | 87 ></A |
88 ><P | |
89 ></P | |
90 ><PRE | |
91 CLASS="FUNCSYNOPSISINFO" | |
92 >#include "SDL.h"</PRE | |
93 ><P | |
94 ><CODE | |
95 ><CODE | |
96 CLASS="FUNCDEF" | |
97 >int <B | |
98 CLASS="FSFUNC" | |
99 >SDL_SetTimer</B | |
100 ></CODE | |
101 >(Uint32 interval, SDL_TimerCallback callback);</CODE | |
102 ></P | |
103 ><P | |
104 ></P | |
105 ></DIV | |
106 ></DIV | |
107 ><DIV | |
108 CLASS="REFSECT1" | |
109 ><A | |
110 NAME="SDLTIMERCALLBACK" | |
111 ></A | |
112 ><H2 | |
113 >Callback</H2 | |
114 ><P | |
115 >/* Function prototype for the timer callback function */ | |
116 typedef Uint32 (*SDL_TimerCallback)(Uint32 interval);</P | |
117 ></DIV | |
118 ><DIV | |
119 CLASS="REFSECT1" | |
120 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
121 NAME="AEN8182" |
0 | 122 ></A |
123 ><H2 | |
124 >Description</H2 | |
125 ><P | |
126 >Set a callback to run after the specified number of milliseconds has | |
127 elapsed. The callback function is passed the current timer interval | |
128 and returns the next timer interval. If the returned value is the | |
129 same as the one passed in, the periodic alarm continues, otherwise a | |
130 new alarm is scheduled.</P | |
131 ><P | |
132 >To cancel a currently running timer, call | |
133 <TT | |
134 CLASS="FUNCTION" | |
135 >SDL_SetTimer(0, NULL);</TT | |
136 ></P | |
137 ><P | |
138 >The timer callback function may run in a different thread than your | |
139 main constant, and so shouldn't call any functions from within itself.</P | |
140 ><P | |
141 >The maximum resolution of this timer is 10 ms, which means that if | |
142 you request a 16 ms timer, your callback will run approximately 20 ms | |
143 later on an unloaded system. If you wanted to set a flag signaling | |
144 a frame update at 30 frames per second (every 33 ms), you might set a | |
145 timer for 30 ms (see example below).</P | |
146 ><P | |
147 >If you use this function, you need to pass <TT | |
148 CLASS="LITERAL" | |
149 >SDL_INIT_TIMER</TT | |
150 > | |
151 to <TT | |
152 CLASS="FUNCTION" | |
153 >SDL_Init()</TT | |
154 >.</P | |
155 ><DIV | |
156 CLASS="NOTE" | |
157 ><BLOCKQUOTE | |
158 CLASS="NOTE" | |
159 ><P | |
160 ><B | |
161 >Note: </B | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
162 >This function is kept for compatibility but has been superseded |
0 | 163 by the new timer functions |
164 <A | |
165 HREF="sdladdtimer.html" | |
166 >SDL_AddTimer</A | |
167 > and | |
168 <A | |
169 HREF="sdlremovetimer.html" | |
170 >SDL_RemoveTimer</A | |
171 > which support | |
172 multiple timers.</P | |
173 ></BLOCKQUOTE | |
174 ></DIV | |
175 ></DIV | |
176 ><DIV | |
177 CLASS="REFSECT1" | |
178 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
179 NAME="AEN8196" |
0 | 180 ></A |
181 ><H2 | |
182 >Examples</H2 | |
183 ><P | |
184 ><PRE | |
185 CLASS="PROGRAMLISTING" | |
186 >SDL_SetTimer((33/10)*10, my_callback);</PRE | |
187 ></P | |
188 ></DIV | |
189 ><DIV | |
190 CLASS="REFSECT1" | |
191 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
192 NAME="AEN8200" |
0 | 193 ></A |
194 ><H2 | |
195 >See Also</H2 | |
196 ><P | |
197 ><A | |
198 HREF="sdladdtimer.html" | |
199 ><TT | |
200 CLASS="FUNCTION" | |
201 >SDL_AddTimer</TT | |
202 ></A | |
203 ></P | |
204 ></DIV | |
205 ><DIV | |
206 CLASS="NAVFOOTER" | |
207 ><HR | |
208 ALIGN="LEFT" | |
209 WIDTH="100%"><TABLE | |
210 WIDTH="100%" | |
211 BORDER="0" | |
212 CELLPADDING="0" | |
213 CELLSPACING="0" | |
214 ><TR | |
215 ><TD | |
216 WIDTH="33%" | |
217 ALIGN="left" | |
218 VALIGN="top" | |
219 ><A | |
220 HREF="sdlremovetimer.html" | |
221 >Prev</A | |
222 ></TD | |
223 ><TD | |
224 WIDTH="34%" | |
225 ALIGN="center" | |
226 VALIGN="top" | |
227 ><A | |
228 HREF="index.html" | |
229 >Home</A | |
230 ></TD | |
231 ><TD | |
232 WIDTH="33%" | |
233 ALIGN="right" | |
234 VALIGN="top" | |
235 > </TD | |
236 ></TR | |
237 ><TR | |
238 ><TD | |
239 WIDTH="33%" | |
240 ALIGN="left" | |
241 VALIGN="top" | |
242 >SDL_RemoveTimer</TD | |
243 ><TD | |
244 WIDTH="34%" | |
245 ALIGN="center" | |
246 VALIGN="top" | |
247 ><A | |
248 HREF="time.html" | |
249 >Up</A | |
250 ></TD | |
251 ><TD | |
252 WIDTH="33%" | |
253 ALIGN="right" | |
254 VALIGN="top" | |
255 > </TD | |
256 ></TR | |
257 ></TABLE | |
258 ></DIV | |
259 ></BODY | |
260 ></HTML | |
261 > |