Game Development Reference
In-Depth Information
In this bit of code, you immediately set the scale for cylinderNode to 0.0 with a dura-
tion of 0.0. This way, when you scale up the cylinderNode , it will appear as though it
is growing. Like before, you will need to create the sequence so that these actions can run
in order. Now you repeat this action ten times instead of repeating forever. Figure 13-6
shows you how the cylinder should look as it's scaling up.
Figure 13-6 . Cylinder node scaling up
As you can see, the SCNAction has a pattern similar to CoreAnimation; the steps are
shown here:
1.
You create several types of actions.
2.
You create a sequence or grouping.
3.
You create a repeating action of the sequence or group, if so desired.
4.
You call the SCNode 's runAction with the newly created repeating se-
quence.
Summary
You now have your obstacles doing various animations. You learned that there are several
ways in which you can animate your SCNode s, by either using your CoreAnimation
knowledge or using SCNAction s. You can go back and experiment with different types
of SCNAction s and various durations. Make sure you run the game both in the simulator
and on your device to see how Scene Kit leverages the hardware in order to render the 3D
images proficiently.
In the next chapter, you will learn about hit testing and collision detection. You will also
get the enemy and hero moving around.
Search WWH ::




Custom Search