【问题标题】:Change FPS of Sprite-Kit Game?更改 Sprite-Kit 游戏的 FPS?
【发布时间】:2015-09-06 16:20:02
【问题描述】:

是否可以更改 Sprite-Kit 游戏的 FPS?如果可能的话,我该如何在我的代码中实现它?

例如,如果用户想要节省电池电量,游戏可以将 FPS 从 60(默认值)更改为 30 或 20。

感谢您的帮助

【问题讨论】:

    标签: swift ios8 sprite-kit frame-rate


    【解决方案1】:

    SKViewframeInterval 设置为所需的值。

    参考:https://developer.apple.com/library/mac/documentation/SpriteKit/Reference/SKView/index.html#//apple_ref/occ/instp/SKView/frameInterval

    将间隔设置为 2 将导致默认帧速率减半。 (虽然它是一个整数,所以看来唯一的选择是将帧速率降低一半、第三、第四等。

    【讨论】:

    • iOS 10.0 及更高版本改用preferredFramesPerSecond!
    【解决方案2】:
    let gameView = SKView()
    
    if #available(iOS 10.0, *) {
        gameView.preferredFramesPerSecond = 30
    } else {
        gameView.frameInterval = 2 //Deprecated
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-16
      • 1970-01-01
      相关资源
      最近更新 更多