I have a SKLabelNode that I want positioned centre, however I have had to align the label node left and bottom to remove the well documented "jitter effect". I currently set up the scene by positioning nodes by allocating their position using the following function:
func gridPointX(xPoint:CGFloat, pointY:CGFloat) -> CGPoint {
var xDivision:CGFloat = CGRectGetMaxX(frame)/5.0
var yDivision:CGFloat = CGRectGetMaxY(frame)/5.0
return CGPointMake(xPoint*xDivision, pointY*yDivision)
}
This works fine until I remove the "jitter effect" by using the following code:
myDateLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Left
myDateLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Bottom
I have tried to manually enter the x and y positions into the code via the following:
myDateLabel.position = self.gridPointX(0, pointY: 3.6)
However, this produces different label positions dependant on the device type. If I could work out the length of the SKLabelNode I could no doubt determine the centre, I've searched the documentation but can't get a solution. Any thoughts guys?