Search code examples
swiftsprite-kitsklabelnode

SKLabelNode higher when it contains (q,y,p,g or j)


For exemple I have two SKLabelNode: "Easy" and "Medium"

I set them at the same height but because easy contains a 'y', it is higher because of his tail

How can I put them at the same height?


Solution

  • You just need to set them in order to have the same position.y value

    let easy = SKLabelNode(fontNamed:"Chalkduster")
    easy.text = "Easy"
    easy.fontSize = 45
    easy.position = CGPoint(x:CGRectGetMidX(self.frame) - 200, y:CGRectGetMidY(self.frame))
    self.addChild(easy)
    
    let medium = SKLabelNode(fontNamed:"Chalkduster")
    medium.text = "Medium"
    medium.fontSize = 45
    medium.position = CGPoint(x:CGRectGetMidX(self.frame) + 200, y:CGRectGetMidY(self.frame))
    self.addChild(medium)
    

    enter image description here