Purposely slowing down FPS Spritekit

元气小坏坏 提交于 2020-01-01 16:37:14

问题


Is it possible to purposely slow down the SpriteKit scene's FPS? I was thinking if this is possible to make debugging of my game easier.


回答1:


You can do something like this as well (as an addition to crashoverride777's answer) by slowing down nodes or physics:

To make nodes going into slow-mo (you can do this per node):

self.speed = 0.2 //where self is a scene

or to do the same with physics:

self.physicsWorld.speed = 0.2 //where self is a scene



回答2:


You can change the FPS value of your SKView when you load the first scene from your GameViewController.

Something like:

if #available(iOS 10.0, *) { 
     skView.preferredFramesPerSecond = 30 // 30 FPS 
} else {
     skView.frameInterval = 2 // Deprecated (1 default = 60FPS so 2 would = 30 FPS)
     skView.preferredFrameRate = ... // Deprecated
}

As Whirlwind so kindly pointed out in his answer:

"Also, this will not slowdown anything, you just skip frames you are seeing, eg. if you have a node that moves from point A to point B in 5 seconds, and you change preferredFrameRate to 30fps, the node will move from A to B still in 5 seconds, rather than 10. The only change you will see, is that some frames are skipped."

SKView API reference here



来源:https://stackoverflow.com/questions/41761176/purposely-slowing-down-fps-spritekit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!