使用SpriteKit创建游戏并且它实际上运行得非常好.我正在使用物理学并且有能力实际看到我的身体在哪里,因为我可能在我的精灵中有一些alpha会真的很有帮助.这对于创建更精确的实体也很有帮助.
在SpriteKit的文档中,他们讨论了debugOverlay,但他们给出的唯一例子是绘制引力方向.这是链接:https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Actions/Actions.html
滚动到调试覆盖区域.
是否有人编写了一些代码,可以轻松访问场景中所有对象的主体并绘制它们的确切大小并将它们放在相关的位置?我很惊讶苹果不仅仅在物理机构中添加了某种类型的DrawGizmos属性.
提前致谢.
解决方法
这是从
RW tutorial书.
- - (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];
- }
要在节点上使用它,
- [mySpriteToDebug attachDebugRectWithSize:contactSize];