Search code examples
iossprite-kitskscene

Why is width of view incorrect? SKScene


My score label sprite node x position is set to size.width * 0.4 and it looks like this:

(The 'Time' sprite node on the right simply adds 100 to the score sprite node x position)

enter image description here

If I change the score label sprite node x position to size.width * 0.3 it looks like this:

enter image description here

Of course it seems size.width is returning larger than the actual screen size. Any ideas what is wrong?


Solution

  • Put this in the viewDidLoad:

    self.size = view.bounds.size