尝试从GameViewController首次加载GameScene时执行SKTransition,但似乎没有任何事情发生。我们不能直接从GameViewController呈现场景时执行一些转换吗?在我看来,正常的当前场景正在发挥作用,而不是那个有过渡的场景,这对我来说非常有趣。这是代码:
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
let scene = GameScene(size: view.bounds.size)
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
//transition
let transition = SKTransition.doorsOpenVertical(withDuration: 2)
// Present the scene
view.presentScene(scene, transition: transition)
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
}
class GameScene: SKScene {
override func didMove(to view: SKView) {
self.backgroundColor = SKColor.red
}
}
请解决查询。