Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the alignment of a SKLabelNode

I'm trying to keep the left side of an SKLabelNode fixed after updating it. The thing is that the SKLabelNode is growing in both directions. All I want is to grow only in the right side. Thanks a lot.

like image 676
Ady Năstase Avatar asked Jan 24 '15 19:01

Ady Năstase


1 Answers

The problem is, that SKNodes have their origin in the center of their node. So you will have to set the SKLabelHorizontalAlignmentMode to "left" to resolve this problem.

var label:SKLabelNode = SKLabelNode()
label.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Left

Here a picture, what the different modes do:

enter image description hereLink to picture origin

like image 127
Christian Avatar answered Sep 24 '22 01:09

Christian