Methods to take custom control over the view's render rate.
- iOS 10.0+
- macOS 10.12+
- tvOS 10.0+
By setting a SpriteKit view's
delegate with an object that implements
SKView, you can precisely control the frame rate of a game or app. You may choose to do this to maintain a consistent frame rate for computationally intensive code or for special effects such as simulating cine film.
Listing 1 shows an example of a class that implements the SpriteKit view delegate protocol to reduce the frame rate to a specified value. With each call of
view(_:, it checks the time since the last render and if that value exceeds the required frame duration (
1 / fps), the method returns
true and the frame is rendered.
The return value of
view(_: doesn't change the speed of physics simulations and actions in a SpriteKit scene. However, if you return
false, SpriteKit will skip updates and
SKScene methods are not called.