Using .sks files with custom classes as reference nodes?

What is the proper way to do this? For example: I have two .sks files that both have a custom class associated with them. If I include a reference node on one of them and link that reference node to the other .sks file and run the project I experience a crash.


Attemped to add a SKNode which already has a parent: <SKSpriteNode> name:'SKSpriteNode_0' texture:['nil'] position:{596.5, 412.5} scale:{1.00, 1.00} size:{100, 100} anchor:{0.5, 0.5} rotation:0.00


The reference node works without custom classes. I am also unsure whether I should be inheriting from SKScene, or SKNode in my custom classes. Doing either seems to cause a crash. If I inherit from SKNode I get the above message. If SKScene I get an error about adding a physics world to one that already exists, which makes sense.

Replies

Yes this would be good to know! It would be really nice to be able to create a .sks file and add objects with physics bodies, and then reference that file in another .sks file. Currently this doesnt seem to work either.

I've failed to get this to work as well. I set custom subclass in the SKS file. But when placing this as a refernce node in a scene I then fail to cast it as that class when getting the referecen node.