Game Development Reference
In-Depth Information
The .repeatCount property is how many times your animation will run.
For this movement, you set it to infinity. Again, this is another setting you
can adjust for some of your animations.
The final line adds the animation to the node. When the node is created, the animation
runs immediately.
When you run the game, you will be able to see the pyramid node rotating along the x-ax-
is, similar to Figure 13-1 . You may need to move your camera around to see it; you can do
this via the pinch-zoom gestures if need be.
Figure 13-1 . Pyramid node x-axis rotation
GlobeNode
In the GlobeNode you will rotate the globe around the y-axis so that it looks similar to
the earth's rotation.
// Spin around the Y-Axis
let rotation = CABasicAnimation(keyPath: "rotation")
rotation.fromValue = NSValue(SCNVector4:SCNVector4Make(0,
0, 0, 0))
rotation.toValue = NSValue(SCNVector4:SCNVector4Make(0, 1,
0, Float(2.0*M_PI)))
rotation.duration = 10
rotation.repeatCount = .infinity
globeNode.addAnimation(rotation, forKey: "rotation")
Search WWH ::




Custom Search