import SwiftUI import SpriteKit struct Level1View: View { @State private var thrustActive: Bool = false @State private var rotationDegrees: CGFloat = 0.0 var body: some View { ZStack { SpriteView(scene: createGameScene()) .edgesIgnoringSafeArea(.all) .gesture( DragGesture() .onChanged { value in let startLocation = value.startLocation let dx = value.location.x - startLocation.x let dy = value.location.y - startLocation.y let angleRadians = atan2(-dy, dx) rotationDegrees = (angleRadians * 180 / .pi) + 180 } ) .onTapGesture { thrustActive = true DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { thrustActive = false } } } .navigationBarHidden(true) } private func createGameScene() -> SKScene { let screenBounds = WKInterfaceDevice.current().screenBounds let screenSize = CGSize(width: screenBounds.width, height: screenBounds.height) let scene = GameScene(size: screenSize) scene.scaleMode = .aspectFill scene.thrustActive = $thrustActive scene.rotationDegrees = $rotationDegrees // Configure the background with image "Level1", centered, at half scale. scene.configureBackground( imageName: "Level1", position: CGPoint(x: screenSize.width / 2, y: screenSize.height / 2), scale: 0.5 ) return scene } }