c++ - SDL iOS 禁用事件泵

标签 c++ ios iphone events sdl

我对以下 SDL 函数有疑问:

void SDL_iPhoneSetEventPump(SDL_bool enabled)

文档说:

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

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

最佳答案

当您不希望轮询事件触发您添加到公共(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/

相关文章:

iphone - iOS 开发 : Why doesn't loadScoresWithCompletionHandler ever return?

ios - 无法验证 iPhone 开发者应用程序

c++ - 为什么 '#pragma omp critical' 部分不能在同一行上有左大括号?

c++ - 引用的编译器优化

c++ - 声明一个 const 变量作为引用

ios - 应用程序因调用 PFUser enableAutomaticUser 而崩溃

ios - 如何在 iOS App Swift 4 中集成 Paypal 支付方式?

ios - 从 json 数据中拆分 ios 字符串中的字符串?

iphone - NSURL 到 NSData(Cocoa 错误 256。)

C++11:有没有办法强制类只能用作右值?