title: Swift SKNode position help - sprite position always 0,0 as it moves
body: <p>Problem: I’m working in swift playground on an iPad Pro.</p>
  <p>I’d like to get the current position coordinates of an <code>SKSpriteNode</code> with attached physicsBody as they move around the screen.  No matter what it try, the sprite position returns <code>0,0</code>, despite seeing it move across the screen.</p>
  <p>I’ve attempted various implementations of <code>convert(_:to:)</code> and <code>convert(_:from:)</code> but the sprite position always ends up <code>0,0</code>.  My understanding is that this isn’t really necessary in the specific case here since the sprite is the direct child of the scene so the sprite’s position property should already be what it is in the scene coordinate system.</p>
  <p>I’ve spent a lot of googling time attempting to figure this out without much success which makes me think I’m asking the wrong question.  If so, please help me figure out what the right question to ask is!</p>
  <p>The touch position print returns the correct position relative to the initial screen size.  That’s what I’d like to get for the sprite.</p>
  <p>Disclaimer - i don’t do this professionally so please forgive what I’m sure is ugly coding!</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  import SpriteKit
  import PlaygroundSupport
  
  var screenW = CGFloat(2732)
  var screenH = CGFloat(2048)
  
  struct ContentView: View {
      var scene: SKScene {
          let scene = GameScene()
          scene.size = CGSize(width: 2732, height: 2048)
          scene.scaleMode = .aspectFit
          scene.backgroundColor = #colorLiteral(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)
          return scene
      }
  
          class GameScene: SKScene {
              var ship1 = SKSpriteNode()
              public override func didMove(to view: SKView) {
                  // gravity edge around screen for convenience
                  physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
                  
                  //turn off default 1g gravity
                  physicsWorld.gravity = .zero
                  
                  //Add a ship sprite
                  let ship1 = SKSpriteNode(imageNamed: &quot;ship.PNG&quot;)
                  ship1.setScale(0.2)
                  ship1.position = CGPoint(x: screenW * 0.2, y: screenH * 0.2)
                  ship1.physicsBody = SKPhysicsBody(rectangleOf: ship1.size)
                  ship1.physicsBody?.velocity = CGVector(dx: 0, dy: 100)
                  
                  addChild(ship1)
  
              }
              
              //touch handling begin
              public override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
                  guard let touch = touches.first else { return }
                  //
                  let location = touch.location(in: self)
                  print(location)
                  print(ship1.position)
                  
              }
          }
  
      var body: some View {
          SpriteView(scene: scene)
              .ignoresSafeArea()
      }
  }
  
  //star the view
  let currentView = ContentView()
  
  
  //Playground view setup
  PlaygroundPage.current.setLiveView(currentView)
  PlaygroundPage.current.wantsFullScreenLiveView = true
  PlaygroundPage.current.needsIndefiniteExecution = true
  </code></pre>