如何绘制SKNode PhysicsBody进行调试? [英] How to draw SKNode PhysicsBody for debugging?

查看:134
本文介绍了如何绘制SKNode PhysicsBody进行调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用矩形创建我的SKPhysicsBody,我将其设置为节点的大小,但是碰撞检测在节点的良好部分上不起作用。
如何在物理体周围绘制红框?

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?

推荐答案

这适用于iOS 7.1以及支持SpriteKit的所有OSX版本。

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

在这个例子中我是使用变量mySKView来保存游戏的SKView。

In this example I'm using the variable mySKView to hold the SKView of the game.

将SKView的showPhysics属性设置为true / YES。这通常通过在mySKView.showsFPS = true行之后添加以下行来完成。通常在拥有SKView的viewcontroller中。

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

这篇关于如何绘制SKNode PhysicsBody进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆