Dvole Dvole - 3 months ago 60
iOS Question

How to draw SKNode PhysicsBody for debugging?

I create my SKPhysicsBody with rectangle from size, I set it to size of the node, but the collision detection does not work on good portion of the node.
How do I draw the red frame around physics body?

I tried using precise collision detection, but it doesn't help.
I have checked some debug library but it draws only direct descendants of the scene, and my nodes are few levels deep. Author apparently doesn't know what recursion is.

How do I draw red frame around physics body if my body is rectangle?


This works as of iOS 7.1 and in all OSX versions supporting SpriteKit.

In this example I'm using the variable mySKView to hold the SKView of the game.

Set the "showPhysics" property of your SKView to true/YES. This is usually done by adding the following line after the line "mySKView.showsFPS = true". Usually in the viewcontroller owning the SKView.


mySKView.showsPhysics = YES;


mySKView.showsPhysics = true