Button


GameScene
import SpriteKit
import GameplayKit

class GameScene: SKScene {
  let label = SKLabelNode(fontNamed: "HelveticaNeue-Light")
  let button = SKSpriteNode(imageNamed: "blue2.png")

    override func didMove(to view: SKView) {
      physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
      self.backgroundColor = .green

       label.text = "Hello World!"
       label.position = CGPoint(x: self.frame.midX, y: self.frame.midY + 10)
       label.fontSize = 20
       label.fontColor = SKColor.white
      self.addChild(label)

       button.position = CGPoint(x: size.width/2, y: size.height/2+120)
       button.zPosition = 1
       button.name = "button"
       button.setScale(0.4)
       self.addChild(button)
        button.run(SKAction.scale(to: 0.5, duration: 0.3))
       button.alpha = 1

    }
    override func touchesEnded(_ touches: Set, with event: UIEvent?) {
        button.alpha = 1
        button.setScale(0.5)
    }

    override func touchesBegan(_ touches: Set, with event: UIEvent?){
        for touch in touches {
          let location = touch.location(in: self)
          let touchedNode = atPoint(location)

          if touchedNode.name == "button" {
              button.alpha = 0.5
              button.setScale(0.6)
              if label.fontSize < 50 {
              label.fontSize += 2
              }
              else{
              label.fontSize = 20
             }
         }
         
      }
    }
}
//////////////////////////
ContentView.swift
import SwiftUI
import SpriteKit

struct ContentView: View {
    let screenWidth  = UIScreen.main.bounds.width
    let screenHeight = UIScreen.main.bounds.height
    var scene: SKScene {
        let scene = GameScene()
        scene.size = CGSize(width: screenWidth, height: screenHeight)
        scene.scaleMode = .fill
        return scene
    }
    var body: some View {
        SpriteView(scene: scene)
          .frame(width: screenWidth, height: screenHeight)
          .ignoresSafeArea()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

//////////////////////////
ButtonApp.swift

import SwiftUI
@main
struct ButtonApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}