I am getting an thread exception at planes.append(plane). I don't know what seems to be the problem. click on the link for code page error at planes.append(plane) https://i.stack.imgur.com/3cxA2.png
Asked
Active
Viewed 37 times
-4
-
Edit your question to include your code. Don't add images of your code. – Daniel Storm May 16 '17 at 20:06
1 Answers
0
I'm guessing your Plane class is this:
class Plane: SKSpriteNode {}
Listen. You are creating the wrong class. You need to create a Plane class, and not a SKSpriteNode class. They are different.
Initialize the plane class like this:
var plane = Plane(imageNamed: "Spaceship")
Problem solved :)

Nebojsa Nadj
- 621
- 3
- 12
-
yes my Plane class is Class Plane: SKSpriteNode{} and i am new to swift so still learning. if I don't create Plane class with SKSpriteNode then I have other attribute which i want each plane to have. and I also want physical body attach to it. – Brijesh Patel May 16 '17 at 20:14
-
This will solve your crash. Mark it as right answer when you test it :) – Nebojsa Nadj May 16 '17 at 20:15
-
Another Question? so do i have to put each plane into self.addChild() everytime in frame or I only do that once. – Brijesh Patel May 16 '17 at 20:28
-
If you want to have more planes, you gotta call addChild for each of them. Yeah :) – Nebojsa Nadj May 16 '17 at 20:45