Reputation: 8866
I'm trying to use SceneKit for the first time for a game and am wondering what you are supposed to do for a game loop for updating game state. I'm aware of
SCNSceneRendererDelegate.renderer:updateAtTime:
but this is not called if there are no changes to the scene and it does not need to be re-rendered. I also know that you can force rendering by using
SCNView.playing = true
but it seems wasteful to force a render when it's not necessary, as this is going to be frequent in my game. I could use an NSTimer
, but then how do you synchronise it with render:updateAtTime:
?
Upvotes: 1
Views: 939
Reputation: 7646
The Apple documentation for SCNSceneRendererDelegate
specifically calls out renderer:updateAtTime:
, renderer:didApplyAnimationsAtTime:
, and renderer:didSimulatePhysicsAtTime:
as the places to add custom game loop logic.
Have you measured (with Instruments) a performance or energy difference when SCNView.playing
is true
? This sounds like a premature optimization.
Upvotes: 1