SKSpriteNodeの子クラスでコンストラクタであるinitを普通にオーバーライドしようとしたら、こんなエラーメッセージが表示されてしまった。
「must call a designated initializer of the superclass SKSpriteNode」
init()は子クラスから呼べないみたいです。
対処方法として、init(texture, color, size)を呼ぶことにします
import UIKit
import SpriteKit
class Man: SKSpriteNode {
init() {
let texture = SKTexture(imageNamed: "man")
super.init(texture: texture1, color: nil, size: texture.size())
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
ちなみに、init(coder aDecoder: NSCoder)はrequired initとして指定されているので、こいつもオーバーライドしてあげないとエラーになります。基本的に呼ばれることはないので、中身はxcodeで自動生成されたエラー処理が入っています。
Did you hear there is a 12 word sentence you can communicate to your partner... that will induce intense feelings of love and impulsive attraction for you deep within his chest?
返信削除Because deep inside these 12 words is a "secret signal" that triggers a man's impulse to love, look after and care for you with all his heart...
12 Words Will Fuel A Man's Love Instinct
This impulse is so built-in to a man's mind that it will make him try harder than before to to be the best lover he can be.
As a matter of fact, triggering this mighty impulse is so important to having the best possible relationship with your man that the instance you send your man a "Secret Signal"...
...You'll instantly notice him open his soul and mind to you in a way he never expressed before and he'll perceive you as the one and only woman in the world who has ever truly fascinated him.