本系列文章是对<3D Apple Games by Tutorials>一书的学习记录和体会node
此书对应的代码地址git
SceneKit系列文章目录github
SCNView有一个delegate属性,须要遵照SCNSceneRendererDelegate
协议,这样就能够在每帧画面的动画和渲染过程当中收到代理方法的调用.swift
Update:会调用renderer(_:updateAtTime:)
代理方法,能够在这里写一些基础逻辑,好比添加或移除node节点.app
Execute Actions&Animations:执行actions(动做)和animations(动画).post
Did Apply Animations:会调用renderer(_: didApplyAnimationsAtTime:)
方法,此时场景中全部节点在这一帧的actions(动做)和animations(动画)都已经更新完成.学习
Simulates Physics:物理效果模拟.动画
Did Simulate Physics:会调用renderer(_:didSimulatePhysicsAtTime:)
方法,此时物理效果模拟已经完成,能够在这里添加和物理效果有关的代码,好比node在受到一个力影响后改变颜色.lua
Evaluates Constraints:约束更新.spa
Will Render Scene:会调用renderer(_:willRenderScene:atTime:)
方法,此时即将要渲染场景,能够在这里对场景作最后的更改.
Renders Scene In View:SceneKit在view中渲染场景.
Did Render Scene:会调用renderer(_: didRenderScene: atTime:)
方法,它标识着一个渲染循环的结束,能够写一些逻辑更新代码在这里,好比游戏中血量增减.
注意 默认状况下,若是一个场景中没有任何改变时,Scene Kit会进入"paused"(暂停)状态,渲染循环暂停后代理方法将不会继续调用,为了防止这种状况,须要在建立SCNView实例时设置playing属性为true如
scnView.playing = true
复制代码
这样渲染循环的代理就会一直调用.