Farseer:碰撞检测,但没有进一步的身体交互
我有一个球,可以滚动穿过迷宫般的世界。如果球越过某条线,我希望事件发生。我不想在这条线上放置纹理,也不希望球偏转。怎么办呢?
谢谢你!
I have a ball that rolls through a maze-like world. I want an event to rise if the ball crosses a certain line. I don't want to place a texture at this line and I don't want the ball to be deflected. How can it be done?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Farseer 3.3.1 中,您可以创建一个主体,例如
sensorLine
,其夹具的Fixture.IsSensor
设置为true
。这样灯具就不会参与碰撞。然后,您可以通过迭代sensorLine.ContactList
来轮询固定装置是否有重叠的主体,或者您可以注册对世界实例的World.ContactManager.BeginContact
事件的回调。听起来
EdgeShape
将是用于sensorLine
中的夹具的形状。如果您只创建一个 Farseer 主体,屏幕上将看不到任何内容,因此您无需担心将纹理放置在任何地方。In Farseer 3.3.1 you can create a body, say
sensorLine
with a fixture that hasFixture.IsSensor
set totrue
. That way the fixture won't take part in collisions. You can then poll the fixture for overlapping bodies by iterating oversensorLine.ContactList
or you can register a callback to theWorld.ContactManager.BeginContact
event of your world instance.It sounds like
EdgeShape
would be the kind of shape to use for the fixture insensorLine
. If you only create a Farseer body, nothing will be visible on screen, so you need not worry about placing textures anywhere.