- 通过Code初始化View及Scene的方法
override func viewDidLoad() {
super.viewDidLoad()
//Initialize scene
let scene = GameScene(size: CGSize(width: 1920, height: 1080))
//Initialize skView
let skView = self.view as! SKView
//Set FPS & node count present in the scene
skView.showsFPS = true
skView.showsNodeCount = true
//A Boolean value that indicates whether parent-child and sibling relationships affect the rendering order of nodes in the scene.
skView.ignoresSiblingOrder = true
//Set the scaleMode
scene.scaleMode = .aspectFill
//Present scene in skView
skView.presentScene(scene)
}
- Sprite在scene中不考虑其他因素的自然移动,需在update()方法中添加:
zombie.position = CGPoint(x: zombie.position.x+1, y: zombie.position.y)