没有透明背景的SKLabelNode [英] SKLabelNode without transparent background
本文介绍了没有透明背景的SKLabelNode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在SKLabelNode上使用了自定义字体.
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?
到目前为止我的代码
scoreLabel.fontColor = [SKColor colorWithRed:0.0 green:0 blue:0.0 alpha:1.0];
推荐答案
我找到的最简单的方法是将SKSpriteNode和SKLabelNode组合在一起. 您只需将SKLabelNode作为子级添加到SKSpriteNode.
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...
这篇关于没有透明背景的SKLabelNode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文