Search code examples
swiftmathsprite-kitgame-enginemetal

Problem trying to convert 2d touches to spritekit coordinates manually


I'm trying to convert 2d touches to sprite kit coordinates world space. I know there's some convenience methods such as "convert(_:from:)". but In my scenario i need to do it manually, I just don't know where to start.

Thank you


Solution

  •          let width = screenSize.width
         let height:CGFloat = screenSize2.height
    
         //convert screen space to cartesian space
         let x = ((point.x * 720) / (width))  - (width)
         let y = ((-point.y * 1280) / (height))  + (height)
    

    that worked, ratios