Entitize
Entitize

Reputation: 4969

Change FPS of Sprite-Kit Game?

Is it possible to change the FPS of a Sprite-Kit game? If it is possible, how can I implement this into my code?

For example, if a user wants to conserve battery the game can change the FPS from 60 (default value) to 30 or 20.

Thanks for helping

Upvotes: 1

Views: 1828

Answers (2)

Aaron Halvorsen
Aaron Halvorsen

Reputation: 2680

let gameView = SKView()

if #available(iOS 10.0, *) {
    gameView.preferredFramesPerSecond = 30
} else {
    gameView.frameInterval = 2 //Deprecated
}

Upvotes: 1

Kendel
Kendel

Reputation: 1708

Set the SKView's frameInterval to the desired value.

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

Setting the interval to 2 will cause half the default frame rate. (It is an integer though so it appears that the only option would be to cut the frame rate by half, third, fourth, etc.

Upvotes: 3

Related Questions