【发布时间】:2015-11-08 19:06:20
【问题描述】:
我有一个包含 SpriteKit 框架的 Swift 项目。当我在没有任何内容的情况下运行程序时,屏幕为黑色,节点计数器为 1。Main.storyboard 完全为白色,其中的类设置为SKView。节点计数器是否错误?它不应该是0,为什么背景是黑色而不是白色?
可能是一些必要的代码错误所在:
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let scene = GameScene() // class GameScene is a subclass of SKScene
let skView = self.view as! SKView
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = false
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
scene.size = skView.bounds.size
scene.anchorPoint = CGPointMake(0,0);
skView.presentScene(scene)
}
【问题讨论】:
标签: swift background sprite-kit storyboard skscene