O'Reilly logo

Build iOS Games with Sprite Kit by Josh Smith, Jonathan Penn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Aligning Label Nodes Within Groups

To match the design of our HUD, we need two parent nodes as groups to hold the title and value labels for the score and the elapsed time. Let’s start by building the first group, and you’ll learn how to align text label nodes inside it. We’ll create an empty node as the score group and then add the two label nodes as children. We’ll add an ‑init method to the top of the implementation in RCWHUDNode.m.

05-HUD/step02/SpaceRun/RCWHUDNode.m
 
- (instancetype)init
 
{
 
if​ (self = [super init]) {
 
SKNode *scoreGroup = [SKNode node];
 
scoreGroup.name = @​"scoreGroup"​;
 
SKLabelNode *scoreTitle =
 
[SKLabelNode labelNodeWithFontNamed:@​"AvenirNext-Medium"​];
 
scoreTitle.fontSize = 12;
 
scoreTitle.fontColor = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required