How to turn on showPhysics in a Swift UI SpriteView?

301 Views Asked by At

I have been playing with the SpriteView in iOS14 and its working quite well however, I noticed that some collisions that worked fine when using a UIViewcontroller would be missed using the SpriteView. So I thought to turn on showsPhysics to help with the debug. However I am stumped as to how I can do that as the skView is not available?

Can anyone help, I must be missing something.

cheers S

2

There are 2 best solutions below

0
CodeSpringsEnternal On

So now I feel a bit dumb. The answer was to put the view.showsPhysics = true into the didMove(to view: SKView) call!

0
Vitor Cheung On

it is simple, you just need to add a new parameter wend you initialize the SpriteView:

SpriteView(scene: SKScene(), debugOptions: .showsPhysics)