Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purposely slowing down FPS Spritekit

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.

like image 416
GeneCode Avatar asked Dec 23 '22 21:12

GeneCode


2 Answers

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
like image 89
Whirlwind Avatar answered Dec 27 '22 10:12

Whirlwind


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

like image 24
crashoverride777 Avatar answered Dec 27 '22 12:12

crashoverride777