Creating a game with SpriteKit and its actually working out very well. I am using physics and having the ability to see actually where my bodies are because I might have some alpha inside of my sprites will really be helpful. This will also be helpful for creating more precise bodies.
In the documentation for SpriteKit they talk about a debugOverlay but the only example they give is to draw the direction of gravity. Here is the link: https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Actions/Actions.html
Scroll to area of debugging overlay.
Has anybody written some code that can easily access the body of all objects in a scene and draw the exact size of them and place them where they should be in the correlation? I'm very surprised apple did not just add some type of DrawGizmos property to the physics body.
Thanks in advance.
I'm sure you've long since answered your question, but as of iOS 7.1 it is now possible to use:
skView.showsPhysics = YES;
Which works much better than the YMCPhysicsDebugger. YMCPhysicsDebugger is also no longer supported.
This is from RW tutorial book.
- (void)attachDebugRectWithSize:(CGSize)s {
CGPathRef bodyPath = CGPathCreateWithRect( CGRectMake(-s.width/2, -s.height/2, s.width, s.height),nil);
[self attachDebugFrameFromPath:bodyPath];
CGPathRelease(bodyPath);
}
- (void)attachDebugFrameFromPath:(CGPathRef)bodyPath {
//if (kDebugDraw==NO) return;
SKShapeNode *shape = [SKShapeNode node];
shape.path = bodyPath;
shape.strokeColor = [SKColor colorWithRed:1.0 green:0 blue:0 alpha:0.5];
shape.lineWidth = 1.0;
[self addChild:shape];
}
To use this on a node,
[mySpriteToDebug attachDebugRectWithSize:contactSize];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With