How to draw SKNode PhysicsBody for debugging?

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

I tried using accurate collision detection, but that does not help. I checked some debug library, but it attracts only direct descendants of the scene, and my nodes have several levels. The author, apparently, does not know what recursion is.

How to draw a red frame around the body of physics if my body is a rectangle?

+7
ios sprite-kit
source share
1 answer

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

In this example, I use the mySKView variable to place the SKView in 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 a viewcontroller owning an SKView.

Obj-C:

mySKView.showsPhysics = YES; 

Swift

 mySKView.showsPhysics = true 
+24
source share

All Articles