(Yes, I know this question is about SceneKit , not SpriteKit, but it touches on the common features and differences between the two structures, so I will address these answers.)
In SpriteKit, game loop methods ( update , didSimulatePhysics , etc.) were originally part of the SKScene scene SKScene . However, this is not always the best idea - you can consider a scene instance as data rather than a place for implementing game logic (especially now that scenes can be completely created in the Xcode 6 graphic scene editor). So, in iOS 8 and OS X Yosemite, these methods are in two places. If you already subclass SKScene for game logic for each frame, you can continue to do so. But if you prefer to use this code elsewhere, you can set the delegate to your scene and implement the equivalent SKSceneDelegate methods SKSceneDelegate .
SceneKit shares problems more. SCNScene much closer to a pure data model object, and all functions of the visualization cycle are controlled by the view (or other object) responsible for rendering the scene. Usually you show a scene in SCNView , but there are other classes that can also display scenes, so their common API is in SCNSceneRenderer . Use the delegate property defined by this protocol to set the delegate for your presentation, and in your deletet you can implement the SCNSceneRendererDelegate methods to participate in the key stages of the visualization cycle.
The phases of the SceneKit loop are almost the same as those in SpriteKit: update: becomes renderer:updateAtTime: didEvaluateActions: becomes renderer:didApplyAnimationsAtTime: (since it includes CoreAnimation-style animations, as well as SpriteKit-style actions), etc.
So, for the SceneKit equivalent of the SpriteKit method for each update frame, do the following:
Set one of your custom objects (e.g., a view controller) as the delegate your SCNView instance.
In this custom class, execute the following method:
func renderer(_ aRenderer: SCNSceneRenderer!, updateAtTime time: NSTimeInterval) {
Or do the same for other SCNSceneRendererDelegate methods if your logic for each frame should happen after processing actions or physics.
source share