I created the player class with:
class Player : SKSpriteNode, GameSprite {
var initialSize = CGSize(width:50, height:50 )
var textureAtlas: SKTextureAtlas = SKTextureAtlas(named: "Dino")
func onTap()
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
I then tried to add an instance of the player class in GameScene.swift with:
class GameScene: SKScene {
override func didMove(to view: SKView) {
self.anchorPoint = .zero
self.backgroundColor = UIColor(red: 0.95, green: 0.1, blue: 0.25, alpha: 1.0)
let player = Player()
player.size = CGSize(width: 50, height: 50)
player.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2)
self.addChild(player)
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in (touches) {
let location = touch.location(in: self)
let nodeTouched = atPoint(location)
if let gameSprite = nodeTouched as? GameSprite {
gameSprite.onTap()
}
}
}
}
But an error occurred saying:
Missing argument for parameter 'coder' in call
In the line that reads let player = Player()
Thanks!