need to change positioning of labels using cgpoint (swift3)

498 views Asked by At

I have two labels. One lane occupies the top left section of the screen and the other occupies the top right section of the screen. Even though it states bottom alignment mode the position is still on the top of the screen

    scoreLabel.text = " Score: 0"
    scoreLabel.fontSize = 70
    scoreLabel.fontColor = SKColor.white
    scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.left
    scoreLabel.position = CGPoint(x: self.size.width*0.15, y: self.size.height + scoreLabel.frame.size.height)
    scoreLabel.zPosition = 100
    self.addChild(scoreLabel)
    livesLabel.text = "LIVES: 5"
    livesLabel.fontSize = 70
    livesLabel.fontColor = SKColor.white
    livesLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.right
    livesLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.bottom
    livesLabel.position = CGPoint(x: self.size.width*0.85, y: self.size.height + livesLabel.frame.size.height)
    livesLabel.zPosition = 100
    self.addChild(livesLabel)

How can I write code so that both of these labels occupy the the bottom left and right sections of the screen?

0

There are 0 answers