碰撞检测使用的Box2D(Android版)? [英] Collision Detection using Box2d(for Android)?

查看:136
本文介绍了碰撞检测使用的Box2D(Android版)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释以何种方式使用作品的Box2D为Android碰撞检测。我不能用什么方式工作BBContactListener理解。

Can someone explain the in what way works the collision detection using box2d for android. I cannot understand in what way works BBContactListener.

BBContactListener listener = new BBContactListener();
world = new BBWorld(gravity, doSleep);
world.SetContactListener(listener);

如何使用监听器?我应该扩展非标准创建自己还是怎么样?

How to use that listener? Should I extend standart to create my own or how?

推荐答案

我没有使用Box2D的针对Android,但我认为这个想法是有相同的。你必须实现接触式加工方法。这是做在C ++的方式。

I did not use box2d for android, but I think the idea is the same there. You have to implement contact processing methods. That's the way to do it in C++.

class ContactListener : public b2ContactListener
{
public:
    ContactListener();
    ~ContactListener();

    void BeginContact(b2Contact *contact) {...}
    void EndContact(b2Contact *contact) {...}
    void PreSolve (b2Contact *contact, const b2Manifold *oldManifold) {...}
    void PostSolve (b2Contact *contact, const b2ContactImpulse *impulse) {...}
};

然后,只需通过这个类来`b2World

Then just pass this class to `b2World'

这篇关于碰撞检测使用的Box2D(Android版)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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