获取Cocos2d& Box2d [英] Getting contact points on bodies in Cocos2d & Box2d
问题描述
我非常新到Cocos2d和Box2d,I
一直在追踪教程和
一般黑客。但是,我有一个
的问题,我无法解决。
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个身体和夹具创建一个联系人侦听器对象。此对象存储联系人列表以及联系点。
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.
我想在
body / fixtures的
联系点添加一个裂缝图形到
sprite(连接到正文)。
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)
check out this. Take a look at b2Body::GetLocalPoint(const b2Vec2 &worldPoint)
这篇关于获取Cocos2d& Box2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!