Using a timer against an update to launch SpriteKit

I am curious what to use for my game. Timer:

let goodFPS = SKAction.wait(forDuration: 0.01666)
let mainGameRunner = SKAction.run {
//my code is here
}
let toRepeat = SKAction.repeatForever(SKAction.sequence([goodFPS,mainGameRunner]))
inGameHighScore.run(toRepeat,withKey:"mainGame")

or update function:

override func update(_ currentTime: TimeInterval){
//my code is here
}

What provides faster approval of updates?

Note: my frame rate is between 45 and 58

+4
source share
3 answers

I decided to completely rewrite my answer to make it clearer.

, FPS. "" , . , , . , , , . DOS , , , .

, " " , .

update() , . , , .

. , , . , , , , , . , ? , .

SKAction - , . - , . , "", - , - "", , node. , . . , . , , , SKScene. , , , , : . , , , . , , , , ! , .

update()? , . , , update() . . update() , , . / , , , .

:

, .

+1

, SKAction , update.

SKAction , , update .

+1

SpriteKit, iOS.

, CADisplayLink, , , , , , .

, SpriteKit update, , - . .

SKActions .

wait, - , , .

, 0.01 ( ). , , 0.009 , , wait 0.001 , 0.009 , 0.018 0.01. , .

If you use the function update, you may know that your logic will be executed after each screen update and no more.

+1
source

Source: https://habr.com/ru/post/1674433/


All Articles