【发布时间】:2017-06-30 14:27:22
【问题描述】:
我正在使用 Swift 开发一个 macOS 项目,并且在我创建的几个类中覆盖变量时遇到了很多麻烦。在classTwo Xcode 出现错误Cannot override with a stored property 'texture' 就行了;
override var texture: SKTexture?
这是我正在使用的一些代码。
public class classOne: SKSpriteNode {
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// Other functions
}
还有二等;
class classTwo: classOne {
override var texture: SKTexture? // Cannot override with a stored property 'texture'
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// Some other functions
}
我确实计划为classTwo 定义一个特定的纹理,但现在我什至无法完成这项工作。在此先感谢,如果能帮助我解决这个问题,我将不胜感激!
【问题讨论】:
-
有可能吗? SpriteKit 是 Apple 的一个框架,所以我认为这种覆盖是不可能的
-
没看懂你的意思,UIView也是苹果类...
-
为什么需要覆盖纹理?
-
developer.apple.com/library/content/documentation/Swift/… 并搜索
super.在搜索中包含.并通读...
标签: swift inheritance sprite-kit