我最近更新到Xcode 7 Beta,现在我收到一条错误消息“实例成员'视图'不能在类型'GameScene'中用于第5行。有任何想法如何解决这个此外,如果你想成为额外的帮助,请参阅我的其他问题:ConvertPointToView Function not working in Swift Xcode 7 Beta实例成员'视图'不能在类型'GameScene'上使用
import SpriteKit
class GameScene: SKScene {
var titleLabel: StandardLabel = StandardLabel(x: 0, y: 0, width: 250, height: 80, doCenter: true, text: "Baore", textColor: UIColor.redColor(), backgroundColor: UIColor(white: 0, alpha: 0), font: "Futura-CondensedExtraBold", fontSize: 80, border: false, sceneWidth: view.scene.frame.maxX)
override func didMoveToView(view: SKView) {
self.scene?.size = StandardScene.size
self.view?.addSubview(titleLabel)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in (touches) {
let location = touch.locationInNode(self)
}
}
override func update(currentTime: CFTimeInterval) {
}
}
什么是StandardLabel? – ABakerSmith
@ABakerSmith Line 5.不要担心标准标签,我会传递它的有效参数。我可以告诉你,如果你想,但它只是一堆初始化。问题是'view',我得到错误信息''view'不能用于类型'GameScene'“ –
@ABakerSmith好吧,你使用的是Xcode beta 7吗?不,StandardLabel是UILabel的一个子类。它与self.view?.addSubview(titleLabel)没有任何关系。它仅适用于提到'视图'时的第5行。 –