这是我正在使用的代码,但第二个按钮"得分"我测试应用时没有出现,为什么?
class GameScene: SKScene {
let playbutton = SKSpriteNode (imageNamed: "play")
let score = SKSpriteNode (imageNamed: "score")
override func didMoveToView(view: SKView) {
self.playbutton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
self.addChild(self.playbutton)
self.backgroundColor = UIColor(hex: 0x80D9FF)
func didMoveToView(view: SKView) {
self.score.position = CGPointMake(180, 100)
self.addChild(self.score)
self.backgroundColor = UIColor(hex: 0x80D9FF)
}
}
答案 0 :(得分:1)
你有没有调用第二个didMoveToView()?您是否尝试过将代码添加到原始覆盖func didMoveToView(查看:SKView)中的分数,如下所示:
class GameScene: SKScene {
let playbutton = SKSpriteNode (imageNamed: "play")
let score = SKSpriteNode (imageNamed: "score")
override func didMoveToView(view: SKView) {
self.playbutton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
self.addChild(self.playbutton)
self.backgroundColor = UIColor(hex: 0x80D9FF)
self.score.position = CGPointMake(180, 100)
self.addChild(self.score)
self.backgroundColor = UIColor(hex: 0x80D9FF)
}
}