我不知道我是如何得到这个错误的。我创建了一个名为item的类,它继承了NSObject和NSCoding。该类解码并编码SKSpritenode。我决定我想要更复杂的项目,所以我创建了一个来自SKSpritenode的子类,它具有一些额外的功能。
import UIKit
import SpriteKit
class SpecialNodes: SKSpriteNode {
private var textAtlas: SKTextureAtlas
private var imageUniformName: String
init(Begintexture: SKTexture!, textAtlas: SKTextureAtlas, uniformName: String) {
self.textAtlas = textAtlas
let texture = Begintexture
self.imageUniformName = uniformName
super.init(texture: texture, color: UIColor.clear, size: (texture?.size())!)
print(Begintexture)
animateTextures(atlas: textAtlas)
}
convenience required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func animateTextures(atlas: SKTextureAtlas) {
let pacAtlas = atlas
var frames = [SKTexture]()
let numImages = pacAtlas.textureNames.count
for i in 1...numImages/2 {
let textName = "\(imageUniformName)\(i)"
frames.append(pacAtlas.textureNamed(textName))
}
let animation = SKAction.animate(with: frames, timePerFrame: 0.1)
self.run(SKAction.repeatForever(SKAction.sequence([animation,animation.reversed()])))
}
}
这给了我一个错误致命错误:init(编码器:)尚未实现。我猜测什么时候SKSpritenode的这个子类在项目类中被解码?我不确定发生了什么。