9
votes

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?

1
Author? Who are you talking about? What is the red frame that you are talking about?El Tomato
@ElTomato I just want to draw a red 1 pixel frame around my physics body.Dvole

1 Answers

27
votes

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.

Obj-C:

mySKView.showsPhysics = YES;

Swift

mySKView.showsPhysics = true