菜鸟教程小白 发表于 2022-12-11 18:49:32

c++ - SDL iOS 禁用事件泵


                                            <p><p>我对以下 SDL 函数有疑问:</p>

<pre><code>void SDL_iPhoneSetEventPump(SDL_bool enabled)
</code></pre>

<p>文档说:</p>

<blockquote>
<p>Use this function to enable or disable the SDL event pump on Apple iOS. </p>
</blockquote>

<p>现在在什么情况下需要或推荐使用这个功能?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>当您不希望轮询事件触发您添加到公共(public)或默认运行循环的任何 <code>CADisplayLink</code> 时,这很有用。 </p>

<pre><code>    self.displayLink = CADisplayLink(target: self, selector: #selector(self.runTick(step:)))
    self.displayLink?.add(to: .main, forMode: .default)
</code></pre>

<p>如果您在此处对 SDL2 事件进行轮询或迭代,它将触发另一个回调。 </p>

<pre><code>       @objc func runTick(step: CADisplayLink) {
            //poll events.
      }
</code></pre>

<p>因为这个 SDL2 片段:</p>

<pre><code>SInt32 result;
do {
       result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE);
} while (result == kCFRunLoopRunHandledSource);
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于c&#43;&#43; - SDL iOS 禁用事件泵,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/46463119/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/46463119/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: c&#43;&#43; - SDL iOS 禁用事件泵