Unfortunately I get the error message 'self' used in property access 'healthPoints' before 'super.init' call
again and again with my code:
First Class Unit
import UIKit
import SpriteKit
class Unit {
// var gameScene : GameScene!
var healthPoints = 10
var damage = 5
var movement = 1
init(pHealthPoints: Int, pDamage: Int,pMovement: Int) {
self.healthPoints = pHealthPoints
self.damage = pDamage
self.movement = pMovement
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Subclass Knight
import UIKit
import SpriteKit
class Knight: Unit {
override init(pHealthPoints: Int, pDamage: Int, pMovement: Int) {
self.healthPoints = pHealthPoints
self.damage = pDamage
self.movement = pMovement
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Where exactly do I have to write super
in the subclass?
How can I access the class Unit
or the class Knight
via the GameScene.swift
or create an object of the class Knight
?
For each answer I am very grateful