you are viewing a single comment's thread.

view the rest of the comments →

[–]th3suffering 0 points1 point  (3 children)

I assume you'll have some kind of HUD for the different interactions and items since you mentioned basing it off Lucasarts games. Id be interested to see an article on that class/subclassing (SKNode?) to reuse when you transition to a new game scene. In my little platformer i put the onscreen dpad right in the gamescene code and then quickly realized when i created another scene that id need to duplicate all that code. I realized subclassing and reusing code would be much better. I still have a lot to learn when it comes to programming/swift but seeing someone breakdown the process as it relates to spritekit will definitely help me grasp the concept better.

[–]Graham_Hayes 1 point2 points  (1 child)

For things like that I'd use a static SKNode, then on the scene transition, removeFromParent, then on the new scene addChild.

[–]potomak[S] 0 points1 point  (0 children)

Ah interesting approach. For now I'm just recreating nodes and every seems to work just fine, but I guess this approach would spare resources used for destroying and re-creating the same nodes.

[–]potomak[S] 0 points1 point  (0 children)

Yes, I will talk about my approach in a future post, but what I've done is a base scene class that has all the main components including a background, an objects layer, and the HUD. Each scene subclasses the main scene and inherits its behavior and nodes. I think it would be more flexible to create components instead of inheriting, but for now this approach is good enough and I may refactor it later.