这里我创建了一个菜单类,其中包含几个项目。我想在主类中显示这些精灵。我尝试通过在touches started方法中创建一个与sknode类关联的对象,但是当我使用addChild事件在主类中添加菜单对象时,什么都没有显示出来。sknode看不到添加的孩子
class menu:SKNode {
let background = SKSpriteNode(imageNamed:"background")
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(){
super.init()
var fixedSize = self.frame.width/11
background.size = CGSizeMake(self.frame.width-fixedSize, self.frame.size.height-fixedSize)
background.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2)
self.addChild(background)
}
}
//In the main method i said let settings = menu() self.addChild(settings) nothing shows up
为什么要定义背景大小和位置?因为“背景”不是在任何地方创建的 – Eric
对不起,我的意思是在菜单类 – user302692