You can subclass SKSpriteNode
and define your own type of sprite.
class Hero: SKSpriteNode {
//Use a convenience init when you want to hard code values
convenience init() {
let texture = SKTexture(imageNamed: "Hero")
self.init(texture: texture, color: .clearColor(), size: texture.size())
}
//We need to override this to allow for class to work in SpriteKit Scene Builder
required init?(coder aDecoder: NSCoder) {
super.init(coder:aDecoder)
}
//Override this to allow Hero to have access all convenience init methods
override init(texture: SKTexture?, color: UIColor, size: CGSize)
{
super.init(texture: texture, color: color, size: size)
}
}