i'm trying to create a custom SKSpriteNode, by subclassing SKSpriteNode, using swift here the code:
import Foundation
import SpriteKit
class CustomNode:SKSpriteNode{
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init() {
super.init()
}
}
When i add it to the scene i got fatal error: use of unimplemented initializer 'init(texture:color:size:)' for class 'Sandbox.CustomNode'
if i change
super.init()
for
super.init(texture: nil, color:UIColor.whiteColor(),size: CGRect(0,0,100,100))
i got the compiler error:"Extra Argument 'color' in call.
I'm using XCode 6, beta 7. Its a iOS project.
That error message isn't exactly obvious, but it can be produced by incorrectly passing arguments to a method. In this case, the problem is that you're passing a CGRect, where the argument is supposed to be CGSize. This code should work for you.
super.init(texture: nil, color:UIColor.whiteColor(),size: CGSize(width: 100.0, height: 100.0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With