I made a SKShapeNode subclass called Player:
import UIKit
import SpriteKit
let MOVE_UP: CGFloat = 3
class Player: SKShapeNode{
var lifePoints = 3
init(circleOfRadius: CGFloat, fillColor: UIColor, strokeColor: UIColor) {
super.init()
self.fillColor = fillColor
self.strokeColor = strokeColor
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
class func movePlayerUp(mPlayer: SKShapeNode){
mPlayer.position.y += MOVE_UP
}
}
in GameScene
I'm trying to create a sprite of type Player
and show it on the screen.
I have no error and the build does not fail but the sprite won't show up on the screen.
this is how I'm creating the sprite:
override func didMove(to view: SKView) {
let sprite = Player(circleOfRadius: 45, fillColor: myColors.blue, strokeColor: myColors.yellow)
sprite.position = CGPoint(x: frame.midX, y: frame.midY)
self.addChild(sprite)
}