OGeek|极客世界-中国程序员成长平台

标题: c++ - SDL iOS 禁用事件泵 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:49
标题: c++ - SDL iOS 禁用事件泵

我对以下 SDL 函数有疑问:

void SDL_iPhoneSetEventPump(SDL_bool enabled)

文档说:

Use this function to enable or disable the SDL event pump on Apple iOS.

现在在什么情况下需要或推荐使用这个功能?



Best Answer-推荐答案


当您不希望轮询事件触发您添加到公共(public)或默认运行循环的任何 CADisplayLink 时,这很有用。

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

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

       @objc func runTick(step: CADisplayLink) {
            //poll events. 
        }

因为这个 SDL2 片段:

  SInt32 result;
  do {
       result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE);
  } while (result == kCFRunLoopRunHandledSource);

关于c++ - SDL iOS 禁用事件泵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46463119/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4