Skip to content

Commit

Permalink
Float cast in vertical adjustment for correct positioning for labels …
Browse files Browse the repository at this point in the history
…with even numbered lines
  • Loading branch information
nickfalk committed Apr 11, 2014
1 parent 423190d commit 81df88b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions NORLabelNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ - (void)setBlendMode:(SKBlendMode)blendMode{

- (void)repositionSubNodesBasedOnParentPosition:(CGPoint)position {
CGFloat lineSpacingAdjustment = self.fontSize * self.lineSpacing;
CGFloat numberOfPositionsLabelsShouldMoveUp = 0;
CGFloat y = 0;//position.y;
CGFloat numberOfPositionsLabelsShouldMoveUp = 0.0f;
CGFloat y = 0.0f;

switch (self.verticalAlignmentMode) {
case SKLabelVerticalAlignmentModeBaseline:
case SKLabelVerticalAlignmentModeCenter:
numberOfPositionsLabelsShouldMoveUp = (self.numberOfLines - 1) / 2;
numberOfPositionsLabelsShouldMoveUp = (CGFloat)(self.numberOfLines - 1) / 2;
break;
case SKLabelVerticalAlignmentModeBottom:
numberOfPositionsLabelsShouldMoveUp = self.numberOfLines - 1;
Expand All @@ -222,10 +222,11 @@ - (void)repositionSubNodesBasedOnParentPosition:(CGPoint)position {
default:
break;
}

y += numberOfPositionsLabelsShouldMoveUp * lineSpacingAdjustment;

for (SKLabelNode *subNode in self.subNodes) {
CGFloat x = 0;
CGFloat x = 0;
subNode.position = CGPointMake(x, y);
y -= lineSpacingAdjustment;
}
Expand Down

0 comments on commit 81df88b

Please sign in to comment.