我的问题是每当我尝试加载下面的代码时,会弹出一个空白的灰色屏幕,上面没有我的精灵。没有错误,但模拟器中什么都不会发生。
import SpriteKit
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
/* Setup your scene here */
backgroundColor = SKColor.brownColor()
let start = SKLabelNode(fontNamed: "Chalkduster")
start.position = CGPoint(x: self.frame.size.width/4, y: self.frame.size.height/2)
start.text = "start"
start.color = SKColor.blackColor()
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
}
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
}
答案 0 :(得分:0)
要解决这个问题的两件事。
你必须打电话,
self.addChild(start)
实际在场景中添加节点。
这不在屏幕的可见区域
CGPoint(x: self.frame.size.width/4, y: self.frame.size.height/2)
尝试使用此代码。
override func didMoveToView(view: SKView) {
/* Setup your scene here */
backgroundColor = SKColor.brownColor()
let start = SKLabelNode(fontNamed: "Chalkduster")
start.text = "start"
start.position = CGPoint(x: (self.scene?.size.width)!/2, y: (self.scene?.size.height)!/2)
start.color = SKColor.blackColor()
self.addChild(start)
}