I am trying to work on Project 1 and use SpriteKit and SwiftUI but for some reason the scene never fill the whole screen on my iPad.
import SwiftUI
import SpriteKit
struct ContentView: View {
var scene: SKScene {
let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height
let scene = GameScene()
scene.size = CGSize(width: screenHeight, height: screenWidth)
scene.scaleMode = .fill
scene.backgroundColor = .green
return scene
}
var body: some View {
let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height
print(screenWidth)
return SpriteView(scene: scene)
.frame(width: screenWidth, height: screenHeight)
.ignoresSafeArea()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Right now it looks like this:
Any ideas what I am missing here?
Max
You have height at width and width at height parameter at scene property. (How @aheze mentioned in the comment)