⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdlsettimer.html

📁 VC5.6.7的一个扩展库。跟DirectX的功能差不多。
💻 HTML
字号:
<HTML><HEAD><TITLE>SDL_SetTimer</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="SDL Library Documentation"HREF="index.html"><LINKREL="UP"TITLE="Time"HREF="time.html"><LINKREL="PREVIOUS"TITLE="SDL_RemoveTimer"HREF="sdlremovetimer.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFF8DC"TEXT="#000000"LINK="#0000ee"VLINK="#551a8b"ALINK="#ff0000"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">SDL Library Documentation</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="sdlremovetimer.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom">&nbsp;</TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="SDLSETTIMER"></A>SDL_SetTimer</H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN8557"></A><H2>Name</H2>SDL_SetTimer&nbsp;--&nbsp;Set a callback to run after the specified number of milliseconds haselapsed.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN8560"></A><H2>Synopsis</H2><DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN8561"></A><P></P><PRECLASS="FUNCSYNOPSISINFO">#include "SDL.h"</PRE><P><CODE><CODECLASS="FUNCDEF">int <BCLASS="FSFUNC">SDL_SetTimer</B></CODE>(Uint32 interval, SDL_TimerCallback callback);</CODE></P><P></P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="SDLTIMERCALLBACK"></A><H2>Callback</H2><P>/* Function prototype for the timer callback function */typedef Uint32 (*SDL_TimerCallback)(Uint32 interval);</P></DIV><DIVCLASS="REFSECT1"><ANAME="AEN8570"></A><H2>Description</H2><P>Set a callback to run after the specified number of milliseconds haselapsed. The callback function is passed the current timer intervaland returns the next timer interval.  If the returned value is thesame as the one passed in, the periodic alarm continues, otherwise anew alarm is scheduled.</P><P>To cancel a currently running timer, call<TTCLASS="FUNCTION">SDL_SetTimer(0, NULL);</TT></P><P>The timer callback function may run in a different thread than yourmain constant, and so shouldn't call any functions from within itself.</P><P>The maximum resolution of this timer is 10 ms, which means that ifyou request a 16 ms timer, your callback will run approximately 20 mslater on an unloaded system.  If you wanted to set a flag signalinga frame update at 30 frames per second (every 33 ms), you might set atimer for 30 ms (see example below).</P><P>If you use this function, you need to pass <TTCLASS="LITERAL">SDL_INIT_TIMER</TT>to <TTCLASS="FUNCTION">SDL_Init()</TT>.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>This function is kept for compatibility but has been supersededby the new timer functions<AHREF="sdladdtimer.html">SDL_AddTimer</A> and<AHREF="sdlremovetimer.html">SDL_RemoveTimer</A> which supportmultiple timers.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN8584"></A><H2>Examples</H2><P><PRECLASS="PROGRAMLISTING">SDL_SetTimer((33/10)*10, my_callback);</PRE></P></DIV><DIVCLASS="REFSECT1"><ANAME="AEN8588"></A><H2>See Also</H2><P><AHREF="sdladdtimer.html"><TTCLASS="FUNCTION">SDL_AddTimer</TT></A></P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="sdlremovetimer.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="index.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">&nbsp;</TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">SDL_RemoveTimer</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="time.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">&nbsp;</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -