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

2024-08-12移动开发问题
4

本文介绍了在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7