Game Development Reference
In-Depth Information
This code is used to create almost all the Scene Kit primitives that you can use within a
scene. Right now they don't do much, and they are not all that interesting to see. Remem-
ber, if you want to see these obstacles, you will need to add them to the scene in the
GameViewController . Feel free to adjust the sizes and locations so that you can get a
better understanding of how these variables change the object.
Using SCNText
Adding text in Scene Kit is straightforward because the kit has an SCNText object that is
derived from SCNGeometry . There are two ways to provide the text that is used by the
geometry object: either NSString or NSAttributedString .
Starting Screen
For this game, you will use the SCNText to create an open start node and then a "game
over" node. You need to go into the GameViewController.swift file and create a
new function called createStartingText() -> SCNNode .
In this function, you will do a few things in order to create the text and be able to use it
within the main scene.
func createStartingText() -> SCNNode {
let startText = SCNText(string: "Start!", extrusionDepth:
5)
startText.chamferRadius = 0.5
startText.flatness = 0.3
startText.font = UIFont(name: "Copperplate", size: 30)
startText.firstMaterial?.specular.contents
= UIColor.blueColor()
startText.firstMaterial?.shininess = 0.4
let textNode = SCNNode(geometry: startText)
textNode.scale = SCNVector3Make(0.75, 0.75, 0.75)
textNode.position = SCNVector3Make(200, 0, 1000);
return textNode
}
Search WWH ::




Custom Search