Game Development Reference
In-Depth Information
This is similar to the
PyramidNode
; you are just adjusting the rotation in the
.toValuevalue
property around the y-axis.
Run the game now, and you will see the globe rotating slowly around the y-axis similar to
Figure 13-2
.
If you want to give the world a real turn, change the duration to something
fast like one second.
Figure 13-2
.
Globe node y-axis rotation
TubeNode
For the
TubeNode
, how about rotating it around the z-axis?
// Spin around the Z-Axis
let rotation = CABasicAnimation(keyPath: "rotation")
rotation.fromValue = NSValue(SCNVector4:SCNVector4Make(0,
0, 0, 0))
rotation.toValue = NSValue(SCNVector4:SCNVector4Make(0, 0,
1, Float(2.0*M_PI)))
rotation.duration = 10
rotation.repeatCount = .infinity
tubeNode.addAnimation(rotation, forKey: "rotation")
Again, you are creating the same animation but just changing the z-axis.
Now when you run the game, you will see the tube rotating along the z-axis, similar to