我正在尝试让 Box2D 与我的 Cocos2d-x 项目一起运行。我正在添加碰撞检测,但出现链接器错误 Undefined symbols for architecture i386: "CContactListener::CContactListener()",引用自:HelloWorldScene.o 中的 HelloWorld::init()
我已经尝试了几件事并研究了几天,但无法弄清楚。任何帮助都会很棒。这是一些代码片段
HelloWorldScene.h
CContactListener *_contactListener; //Variable declared and #include "ContactListener.h" is present at the top
HelloWorldScene.cpp
_contactListener = new CContactListener(); //This line gets the error
_world->SetContactListener(_contactListener);
联系人监听器.h
class CContactListener : public b2ContactListener {
public:
CContactListener();
~CContactListener();
std::vector<ContactData>_contacts;
virtual void BeginContact(b2Contact* contact);
virtual void EndContact(b2Contact* contact);
virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
};
联系人监听器.cpp
#include "ContactListener.h"
CContactListener::CContactListener(): _contacts()
{
}
CContactListener::~CContactListener()
{
}
//...other functions