0

I am trying to make this picture appear at the bottom center but it keeps moving towards the right. I have looked at scales and none of them have worked.

I have tried many different numerals for x and y such as x=7 and y=7 or x=20 and y=5 and they all end up exactly in the middle or to the right. I also considered using negative numbers but didn't know how

player = SKSpriteNode(imageNamed: "shuttle")
player.position = CGPoint(x: self.frame.size.width/7, y: player.frame.size.height/7)
self.addChild(player)

enter image description here

user3837868
  • 917
  • 1
  • 12
  • 24
Drobotjosh
  • 27
  • 5
  • You can give your image to constraint.. Check this out https://stackoverflow.com/questions/26180822/how-to-add-constraints-programmatically-using-swift – Said Alır May 30 '19 at 08:22
  • By default, sprites have their `anchorPoint` to their center. You could either change the `anchorPoint` of the parent (and set it to `.zero` for example in order to be on the bottom left) or calculate manually the positions by taking into account this fact (so if you would like to place something at the bottom center the position would be `(x: 0, y: -screenHeight/2)` – Alladinian May 30 '19 at 10:42

0 Answers0