【发布时间】:2016-04-01 18:13:50
【问题描述】:
在我的 SpriteKit 游戏的标题屏幕中,我想要一个 SKLabelNode 显示“Play”。然而,当我运行下面的代码时,节点并没有添加到场景中。
import UIKit
import SpriteKit
class TitleScreen: SKScene {
var title: SKLabelNode!
override func didMoveToView(view: SKView) {
backgroundColor = SKColor(colorLiteralRed: 0.4, green: 0.835, blue: 1, alpha: 1)
//The color is a light blue, so the node should not be hidden by the color of the screen.
title = SKLabelNode()
title.text = "Play"
title.color = SKColor.blackColor()
title.fontSize = 70
self.addChild(title)
}
我应该怎么做才能完成这项工作?
【问题讨论】:
-
验证 didMoveToView 是否被调用
标签: ios swift sprite-kit swift2 skscene