我正在尝试将GameScene.sks文件中添加的播放器生成到我的GameScene.swift文件中,然后在屏幕上显示此播放器。它总是给我一个错误。
代码GameScene.swift文件:
let player = self.childNode(withName: "player") as! SKSpriteNode
player.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2)
代码GameViewController.swift文件:
override func viewDidLoad() {
super.viewDidLoad()
// Configure the view.
let skView = view as! SKView
skView.isMultipleTouchEnabled = false
// Create and configure the scene.
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .aspectFill
// Present the scene.
skView.presentScene(scene)
}
(GameScene.sks中的玩家是名为player的Color Sprite)。
我希望有人可以帮助我。谢谢!