Game Development Reference
In-Depth Information
ing the position of a node, after the actions were performed, and responding
accordingly.
4.
Next the scene executes any physics simulations on physics bodies in the
5.
The scene calls the
didSimulatePhysics()
method. This is much like
the
didEvaluateActions()
method in that this is where you would
add any game logic to be performed after all the physics simulations are
completed. This is your last chance to perform any game logic before the
scene is rendered.
6.
The scene is rendered.
You will see examples of each step in the rendering loop as you progress through each
chapter of this topic.
Note
When you have
showsFPS
in your
SKView
, you will see how many
frames your game is rendering per second. Each frame, being rendered, repres-
ents a single iteration of the render loop.
Building the Scene's Node Tree
Earlier in this chapter, I discussed how you set up a simple
SKScene
with a background
node and a player node. You did this using the
SKScene.addChild()
method. In this
section, you are going to take a more in-depth look at how scenes are created.
Earlier in this chapter I mentioned the types that the
SKScene
class extends. One of
those types is
SKNode. SKNode
is the class that holds all of the nodes in an
SKScene
object's node tree. It also defines the methods that are used to manipulate this node tree.
The most common of these methods are
addChild()
,
insertChild()
, and
re-
moveFromParent()
, as described in
Table 2-1
.