一个SKLabelNode是一个绘制字符串的节点。
要使用标签节点,首先通过调用labelNodeWithFontNamed:方法创建一个新的标签节点。然后配置标签的其他属性,尤其是text属性。
节点的大小由节点的fontName属性,fontSize属性,和text属性共同的隐蔽的决定。默认情况下,文字相对于节点的原点水平居中,字体的基线穿过原点。verticalAlignmentMode属性和horizontalAlignmentMode属性可以调整标签相对于原点的位置。
An SKLabelNode is a node that draws a string.
Just about every game needs to display text at some point, even if it is just to display “Game Over” to the player. If you had to implement this yourself in OpenGL, it would take a fair amount of work to get it correct. But the SKLabelNode class does all of the work necessary to load fonts and create text for display.
To use a label node, create a new label node by calling the labelNodeWithFontNamed: class method. Then configure the other label properties, especially the text property. The size of a label node is determined implicitly by the label node’s fontName, fontSize, and text properties.
By default, the text label is centered horizontally on the label node’s origin, with the font’s baseline passing through the origin. The verticalAlignmentMode and horizontalAlignmentMode properties can be used to adjust the label’s position relative to the origin.