SKLabelNode not displaying the right CGPoint

69 views Asked by At

I have a problem in my game and i am trying to find out what it is and it is about the position of a SKSpriteNode and i made a SKLabelNode to display the position so i could see what is going wrong. I did:

testlable.text = "\(leftObstacle.position)"
testlable.zPosition = 50
testlable.fontSize = 60

It displays the position of (00,00) when it is in the top left corner or outside of the screen not ever the right position and it isn't ever at (00,00) so what should i do to make it display the right position?

1

There are 1 answers

0
Ali Beadle On BEST ANSWER

The position parameter is the position of a node relative to its parent node - so if leftObstacle is a child of another node in the scene that would explain why it always looks like it is at 0,0. In this case report the position of its parent (or its grand-parent etc.) to get what you need.