Coming back to coding after a break I am now trying to use SpriteKit within SwiftUI
I would like to use the full resolution of the iPad (2160 x 1620) for my Game Scene however the code I have renders the scene beyond the bounds of the screen. It's not scaled properly I suppose is what I mean. It seems the display is still in the 1024x768 size and my scene is rendering beyond the viewable area. Sorry if I am over explaining things here!
This is the code in my ContentView
let screenSize: CGRect = UIScreen.main.nativeBounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
print("Screen width = \(screenWidth), screen height = \(screenHeight)")
let scene = GameScene()
scene.size = CGSize(width: screenWidth, height: screenHeight)
scene.scaleMode = .aspectFit
return scene
}
var body: some View {
let screenSize: CGRect = UIScreen.main.nativeBounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
SpriteView(scene: scene)
.frame(width: screenWidth, height: screenHeight)
}