C++ Xcode链接器错误Cocos2d-x Box2D CContactListener构造函数未定义
我正试图让Box2D运行我的Cocos2d-x项目。我正在添加冲突检测,但我得到一个链接器错误 架构i386的未定义符号:“CContactListener::CContactListener()”,引用自HelloWorldScene.o中的:HelloWorld::init() 我已经尝试了好几件事,研究了几天,但都没弄明白。任何帮助都会很好。 这里有一些代码片段 HelloWorld场景C++ Xcode链接器错误Cocos2d-x Box2D CContactListener构造函数未定义,c++,class,constructor,box2d,cocos2d-x,C++,Class,Constructor,Box2d,Cocos2d X,我正试图让Box2D运行我的Cocos2d-x项目。我正在添加冲突检测,但我得到一个链接器错误 架构i386的未定义符号:“CContactListener::CContactListener()”,引用自HelloWorldScene.o中的:HelloWorld::init() 我已经尝试了好几件事,研究了几天,但都没弄明白。任何帮助都会很好。 这里有一些代码片段 HelloWorld场景 CContactListener *_contactListener; //Variable dec
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);
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);
CContactListener.cpp未添加到Xcode中的目标生成中。我只是在.ccp文件的文件检查器中选中了项目的目标框。易修复.< /P>这看起来很奇怪:CContactListener::CcTraceListEnter():在C++中,这个触控(合法)是合法的吗?我只看到它用于非对象类的成员变量(除了将它们设置为nil)。每个实现联系人侦听器的示例都有它,所以我认为它是可以的。
#include "ContactListener.h"
CContactListener::CContactListener(): _contacts()
{
}
CContactListener::~CContactListener()
{
}
//...other functions