Game Development Reference
In-Depth Information
3.
Inside the GameViewController.viewDidLoad() , downcast the
UIView to an SKView and set the showFPS property to true .
let skView = view as SKView
skView.showsFPS = true
4.
Create an instance of the SKScene named GameScene , passing it its size
in the constructor and setting the scaleMode property.
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill
5.
Inside the init() of the GameScene , add the SKSpriteNode objects
to the scene.
backgroundNode = SKSpriteNode(imageNamed:
"Background")
backgroundNode!.anchorPoint = CGPoint(x: 0.5, y:
0.0)
backgroundNode!.position = CGPoint(x: size.width
/ 2.0, y: 0.0)
addChild(backgroundNode!)
playerNode = SKSpriteNode(imageNamed: "Player")
playerNode!.position = CGPoint(x: size.width
/ 2.0, y: 80.0)
addChild(playerNode!)
6.
Present the complete scene in the GameViewControl-
ler.viewDidLoad() method.
skView.presentScene(scene)
At this point, you have a complete scene with a complete node tree. You can always add
more nodes as the game progresses, but these are the basic steps that you will complete
whenever you create a new SKScene .
The SKScene Rendering Loop
Search WWH ::




Custom Search