1

I've seen a lot of these types of questions, but most of them were in Swift - also none of them seemed to have concrete answers. I am attempting to add a "worldNode" SKNode to a GameScene.sks file using the GUI editor. This node will be used as a basis for a "moving camera" I have added all child nodes of the scene to the worldNode (in the GUI editor) and my next step is to link it to my code implementation, this is where it stops working. I have tried to use this code:

SKNode *myWorld = [SKNode node];
SKNode *camera = [SKNode node];
camera.name = @"camera";
myWorld = [GameScene nodeWithFileNamed:@"worldNode"];
[self addChild:myWorld];
[myWorld addChild:camera];

The problem is from the line: myWorld = [GameScene nodeWithFileNamed:@"worldNode"]; This, from my understanding, should "tie" that worldNode from the GameScene.sks to my GameScene.m file, but when running I get the error: Attemped to add nil node. I am basing the camera idea on the Advanced Scene Processing tutorial provided by Apple. I would like to be able to add all node in my GameScene.sks file to a main "worldNode" so I don't have to manually set up each level in code.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Solsma Dev
  • 481
  • 6
  • 22
  • I basically found the answer here: http://stackoverflow.com/questions/26764267/how-do-i-obtain-the-skspritenode-of-an-item-created-through-spritekit-editor/26766648#26766648 - Part of my trouble finding the answer was that I didn't realize the "GUI editor" had a name - Sprite Kit Editor. Not very creative if you ask me. Knowing this helped find the answer. – Solsma Dev Feb 21 '15 at 01:02
  • `[GameScene nodeWithFileNamed:@"worldNode"]` will load an instance of GameScene from a file named worldNode. Did you mean to use -childNodeWithName: –  Feb 21 '15 at 13:05

0 Answers0