You forgot to add the label to the node graph. For example:
[self addChild:myLabel];
Question
so I am trying to make a game with a timer and a score counter in the bottom right of the screen. but it is not appearing and I am not sure as to why
in - (void)didMoveToView:(SKView *)view
I have the code
SKAction *wait = [SKAction waitForDuration:1.0f];
SKAction *sequence = [SKAction sequence:@[[SKAction performSelector:@selector(timer) onTarget:self], wait]];
SKAction *repeat = [SKAction repeatActionForever:sequence];
[self runAction:repeat];
and timer looks like
-(void)timer
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
float multi = [defaults floatForKey:@"multi"];
if(!_time)
{
_time=0;
}
else if(_time == 30)
{
multi = 1.5;
}
else if(_time == 60)
{
multi = 2;
}
else if(_time == 90)
{
multi = 2.5;
}
else if(_time == 120)
{
multi = 3.0;
}
else if(_time == 150)
{
multi = 3.5;
}
else if(_time == 180)
{
multi = 4.0;
}
else if(_time == 210)
{
multi = 4.5;
}
[defaults setFloat:multi forKey:@"multi"];
_time++;
_score = multi * (float)_time;
SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];
myLabel.fontSize = 30;
myLabel.position = CGPointMake(150,850);
myLabel.text = [NSString stringWithFormat:@"Time %d Score %f",_time,_score];
}
_timer and _score are properties I have created for this scene
any help would be awesome thank you
Solution
You forgot to add the label to the node graph. For example:
[self addChild:myLabel];