\n 在 Sklabel SpriteKit 中不起作用 [英] \n not working in Sklabel SpriteKit
问题描述
我一直在我的游戏中使用以下代码.问题是我无法在 spritekit 中制作多行标签,因为我可以使用 CCLabelTTF ...... 有人可以帮助我吗?此外,我无法在我的代码中使用 \t 或 \n...提前感谢您的回复
I have been using the following code in my game. The Problem is that i am unable to make multi-line label in spritekit as i was able to do using CCLabelTTF...... Can Somebody help me. Also i am unable to use either \t or \n in my code... Thanks for the reply in advance
SKLabelNode *winner = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
winner.text = @"Another\nTest";
winner.fontSize = 32;
winner.fontColor = [SKColor blueColor];
winner.position = CGPointMake(100 , 160);
[self addChild:winner];
推荐答案
看来 SKLabelNode
一次只支持一行文本.我在 SpriteKit 文档或其他任何官方文档中都找不到它,但在 这个 WWDC 演示文稿.你必须使用 UILabel
代替,你可以看到解释 此处.
It appears that SKLabelNode
only supports one line of text at a time. I can't find it in the SpriteKit documentation or anywhere else official, but it's mentioned on the 47th slide of this WWDC presentation. You'll have to use UILabel
instead, which you can see explained here.
这篇关于\n 在 Sklabel SpriteKit 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!