Keep Part of a SpriteKit Scene from Scrolling

August 8th, 2016

Filed under: Game Development, iOS Development, Mac Development | Be the first to comment!

I covered the basics of scrolling a SpriteKit scene with a camera node in my Scrolling a SpriteKit Scene with SKCameraNode article. But I didn’t cover one thing many games need. Many games use part of the screen to display vital information to the player such as score and health. When you scroll the game world, the player’s score shouldn’t scroll off the screen. How do you keep things like the score from scrolling off the screen?

The answer is to make the nodes that shouldn’t scroll child nodes of the camera node. You can set a node’s parent in the scene editor. Select the node, go to the attributes inspector, and choose the camera node from the Parent combo box.


Access the nodes in your code by calling childNodeWithName on the camera node.

scoreLabel = boardCamera.childNodeWithName("scoreLabel") as! SKLabelNode


Leave a Reply

Your email address will not be published. Required fields are marked *