title: Resizing an SKSpriteNode without losing quality
body: <p>I have an SKSpiteNode:</p>
  
  <pre><code>private var btnSound = SKSpriteNode(imageNamed: "btnSound")
  </code></pre>
  
  <p>Now I made this image in Adobe Illustrator with a size of 2048x2048 pixels (overkill really), so it has good resolution. My problem is when I set the size of it the image, the lines in it go serrated or jagged...not smooth.</p>
  
  <p>This is how I size it:</p>
  
  <pre><code>        btnSound.position = CGPoint(x: self.frame.width * 1 / 5 , y: self.frame.height * (5.2 / 8))
          btnSound.size.width = self.frame.width * 1 / 7
          btnSound.size.height = btnSound.size.width
          btnSound.zPosition = 1
          self.addChild(btnSound)
  </code></pre>
  
  <p>This is the image when in Illustrator (screenshot)<a href="https://i.stack.imgur.com/5YSIy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5YSIy.png" alt="image"></a>and this is the image in the app (screenshot) <a href="https://i.stack.imgur.com/aGo1J.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aGo1J.png" alt="image"></a></p>
  
  <p>Things I have tried:</p>
  
  <ul>
  <li>Making the image PDF</li>
  <li>Making the image PNG</li>
  <li>Making the PNG 72 DPI, making it 300 DPI</li>
  <li>Run on simulator / device (iPhone7)</li>
  <li><code>btnSound.setScale(preDetermineScale)</code></li>
  <li><p>Using the following function, though I am not familiar with the UIGraphicsBeginImageContext method. The image just comes out blurry with this. Heres the code and the resulting image:</p>
  
  <pre><code>func resizeImage(image: UIImage, newWidth: CGFloat) -&gt; UIImage? {
  
  let scale = newWidth / image.size.width
  let newHeight = image.size.height * scale
  UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))
  image.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
  
  let newImage = UIGraphicsGetImageFromCurrentImageContext()
  UIGraphicsEndImageContext()
  
  return newImage
  }
  
  func setup() {
  let btnSoundImg = UIImage(named: "btnSound")
  let resizeBtnSoundImage = resizeImage(image: btnSoundImg!, newWidth: self.frame.width * 1 / 7)
  let btnSoundTexture = SKTexture(image: resizeBtnSoundImage!)
  
  btnSound.texture = btnSoundTexture
  btnSound.position = CGPoint(x: self.frame.width * 1 / 5 , y: self.frame.height * (5.2 / 8))
  btnSound.size.width = self.frame.width * 1 / 7
  btnSound.size.height = btnSound.size.width
  btnSound.zPosition = 1
  self.addChild(btnSound)
  }
  </code></pre></li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/j9YjT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/j9YjT.png" alt="blurry image"></a></p>
  
  <p>I am self taught and haven't done a whole lot of programming so I'd love to learn how to do this correctly as I'm only finding solutions for resizing UIImageViews.</p>
  
  <p>Another thought I had was maybe it shouldn't be a spriteNode as its just used for a button?</p>