Reputation: 67
I try to create multiple nodes when loading a level. For this I use the following code in GameScene.swift:
func createUnits() {
let myUnit = Unit()
myUnit.attack()
}
The Unit class is still kept very simple:
class Unit: GameScene {
var livePoints = 10
var damage = 5
var movement = 1
func attack() {
print("Attack!!")
}
}
When compiling, I get the following error at let myUnit = Unit()
:
Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee771cff8)
Does anyone have an idea, how to create a node without get this error?
Thank you in advance.
Upvotes: 0
Views: 28
Reputation: 208
looks like its not a Node, but a Scene. the first line in your Unit class shows you are subclassing GameScene instead of a SKNode
Upvotes: 1