When I try to set the showPhysics
property to true
in the didMove(to:)
function of my Scene it doesn't do anything when I present it using a SpriteView in SwiftUI. The same thing happens when I try to show the FPS and node count. Here is the code:
class GameScene: SKScene {
override func didMove(to view: SKView) {
view.showsFPS = true
size = view.frame.size
addChild(SKSpriteNode(color: .yellow, size: CGSizeMake(50, 50)))
}
}
struct ContentView: View {
var body: some View {
VStack {
Text("My Game")
SpriteView(scene: GameScene())
}
.padding()
}
}
Is this a bug or am I using SpriteView wrong?
You'll want to set these using the SpriteView.DebugOptions when you create your SpriteView
.
For example:
struct ContentView: View {
var body: some View {
VStack {
Text("My Game")
SpriteView(scene: GameScene(), debugOptions: [.showsFPS, .showsNodeCount, .showsPhysics])
}
.padding()
}
}