使用SpriteKit创建游戏并且它实际上运行得非常好.我正在使用物理学并且有能力实际看到我的身体在哪里,因为我可能在我的精灵中有一些alpha会真的很有帮助.这对于创建更精确的实体也很有帮助.
在SpriteKit的文档中,他们讨论了debugOverlay,但他们给出的唯一例子是绘制引力方向.这是链接:https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Actions/Actions.html
滚动到调试覆盖区域.
是否有人编写了一些代码,可以轻松访问场景中所有对象的主体并绘制它们的确切大小并将它们放在应该在相关性中的位置?我很惊讶苹果不仅仅在物理机构中添加了某种类型的DrawGizmos属性.
提前致谢.
Rob*_*Rob 34
我确定你早就回答了你的问题,但从iOS 7.1开始,现在可以使用:
skView.showsPhysics = YES;
哪个比YMCPhysicsDebugger好得多.YMCPhysicsDebugger也不再受支持.
这是来自RW教程的书。
- (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];
}
Run Code Online (Sandbox Code Playgroud)
要在节点上使用它,
[mySpriteToDebug attachDebugRectWithSize:contactSize];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2821 次 |
| 最近记录: |