我有一个定义的精灵,当我运行应用程序时它没有出现。这是我的代码和一些图像,以帮助找出错误:
import SpriteKit
class GameScene: SKScene {
var SingleplayerButton: SKSpriteNode! = nil
override func didMoveToView(view: SKView) {
SingleplayerButton = SKSpriteNode(imageNamed: "Unknown")
SingleplayerButton.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
SingleplayerButton.size = CGSize(width: 200, height: 50)
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if SingleplayerButton.containsPoint(location) {
}
}
}
}
答案 0 :(得分:1)
你遗忘了addChild
到你的场景