Reputation: 750
I'm using an SKLabelNode to display a score on a universal game. The font size is perfect for iPhone but naturally needs to be bigger for iPad. I was wondering if there is any way to change the font size just for iPad? I tried this in didMoveToView: (could be completely wrong but the only thing I could think of)
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
scoreLabel.fontSize = 45 }
This didn't work. any ideas?? NOTE: I'm using a custom font not an apple font if this makes any difference.
let scoreLabel = SKLabelNode(fontNamed: "DS Digital")
scoreLabel.position = CGPoint(x: size.width * 0.07, y: size.height * 0.9)
scoreLabel.text = "0"
scoreLabel.fontSize = 15
addChild(scoreLabel)
scoreLabel.zPosition = 3
let waitScore = SKAction.waitForDuration(1.0) //add score every second
let incrementScore = SKAction.runBlock ({
++self.score
self.scoreLabel.text = "\(self.score)"}) //update score label with score
self.runAction(SKAction.repeatActionForever(SKAction.sequence([waitScore,incrementScore])))
Upvotes: 1
Views: 355
Reputation: 4654
Try replacing
scoreLabel.fontSize = 15
with
scoreLabel.fontSize = UIDevice.currentDevice().userInterfaceIdiom == .Pad ? 30 : 15
Upvotes: 2