dimanche 2 août 2015

Why is my scoreTextNode not returning score?

After my game ends, I added a PNG file with custom font and tried adding score in front of it, but when the game is over, the PNG file gets added and instead of putting the score in front of it, it prints out the details of the PNG file like this, 'ScoreText' (150 x 50 ) position:(465.4356789)....

All of this is happening in my didBeginContact method:

            let score = SKSpriteNode(imageNamed: "ScoreText")
            score.position = CGPoint(x: size.width / 2.2, y: size.height / 1.9)
            self.addChild(score)


            let scoreTextNode = SKLabelNode(fontNamed: "Copperplate")
            scoreTextNode.text = "\(score)"
            scoreTextNode.fontSize = 12
            scoreTextNode.fontColor = SKColor.whiteColor()
            scoreTextNode.position = CGPoint(x: size.width / 2.2, y: size.height / 1.9)
            addChild(scoreTextNode)

Aucun commentaire:

Enregistrer un commentaire