在 Cocos2d & 中获取身体的接触点Box2d

Getting contact points on bodies in Cocos2d amp; Box2d(在 Cocos2d amp; 中获取身体的接触点Box2d)

本文介绍了在 Cocos2d & 中获取身体的接触点Box2d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Cocos2d 和 Box2d 非常,我一直在关注教程和一般是黑客攻击.不过,我有一个我无法解决的问题.

I'm very new to Cocos2d and Box2d, I have been following tutorials and generally hacking. However, I have one problem I cannot solve.

我创建了 2 个物体和固定装置(在 Box2d 世界中)并创建了一个Contact Listener"对象.此对象存储联系人列表以及联系人".

I create 2 bodies and fixtures (in the Box2d world) and create a "Contact Listener" object. This object stores a list of contacts along with the "contact point".

当两个物体发生碰撞时,会报告一个接触点,但这(我认为)是在世界坐标系中.

When the two bodies collide a contact point is reported but this (I think) is in the world co-ordinate system.

我的问题是我似乎无法将接触点转换为两个身体上的可用坐标.

My problem is I can't seem to convert the contact point to a usable co-ordinate on both of the bodies.

我想在精灵(连接到身体)在双方的联络点身体/固定装置.

I want to add a crack graphic to the sprite (connected to the body) at the point of contact on both bodies/fixtures.

有人解决了吗?我可能存储相对于世界"的接触点"是完全错误的方式.

Has anyone solved this? I may be storing the "contact point" relative to the "world" is completely the wrong way to go.

推荐答案

查看 这个.看看 b2Body::GetLocalPoint(const b2Vec2 &worldPoint)

这篇关于在 Cocos2d & 中获取身体的接触点Box2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 Cocos2d & 中获取身体的接触点Box2d