问题
Hi I'm using a custom font on a SKLabelNode.
I'm able to set the font colour but ok, but the inner parts of the text, are transparent.
Is there a way i can set this colour to white for example?
my code so far
scoreLabel.fontColor = [SKColor colorWithRed:0.0 green:0 blue:0.0 alpha:1.0];
回答1:
The easiest way I found is to combine an SKSpriteNode and a SKLabelNode. You simply add the SKLabelNode as a child to the SKSpriteNode.
SKLabelNode *label = [[SKLabelNode alloc]initWithFontNamed:@"Courier"];
label.text = @"blah";
label.fontColor = [UIColor blueColor];
SKSpriteNode *background = [SKSpriteNode spriteNodeWithColor:[UIColor whiteColor] size:CGSizeMake(label.frame.size.width, label.frame.size.height)];
background.position = CGPointMake(200, 100);
[background addChild:label];
label.position = CGPointMake(0, -label.frame.size.height/2);
[self addChild:background];
The result looks like this...
来源:https://stackoverflow.com/questions/23252899/sklabelnode-without-transparent-background