2022.09.25 Programming  spritekit  swiftui  
 2022.09.19 Programming  swiftui  
 2022.09.11 Programming  swiftui  
 2022.09.04 Programming  swiftui  
 2022.08.28 Programming  spritekit  
 2022.08.28 Programming  spritekit  
 2022.08.28 Programming  spritekit  
 2022.07.31 Programming  spritekit  
 2022.07.10 Programming  spritekit  
 2022.07.03 Programming  spritekit  
 2022.06.26 Programming  spritekit  
 2022.06.19 Programming  spritekit  
 2022.06.14 Programming  spritekit  swiftui  
 2022.06.04 Programming  spritekit  
 2022.05.22 Programming  spritekit  
 2022.05.04 Programming  spritekit  
 2022.04.29 Programming  spritekit  
 2022.04.24 Programming  spritekit  

SpriteKitBase


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()
}
}
///////////////////////////
GameScene.swift

import SpriteKit
import GameplayKit
class GameScene: SKScene {
override func didMove(to view: SKView) {
backgroundColor = .yellow
physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
}
func touchDown(atPoint pos : CGPoint) {      
 }
func touchMoved(toPoint pos : CGPoint) {       
}    
func touchUp(atPoint pos : CGPoint) {   
}
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
guard let touch = touches.first else { return }
let location = touch.location(in: self)
let box = SKSpriteNode(color: SKColor.red, size: CGSize(width: 50, height: 50))
box.position = location
box.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: 50, height: 50))
addChild(box)
}
override func touchesMoved(_ touches: Set, with event: UIEvent?) {      
}
override func touchesEnded(_ touches: Set, with event: UIEvent?) {
}    
override func touchesCancelled(_ touches: Set, with event: UIEvent?) {
}  
override func update(_ currentTime: TimeInterval) {
 }
}