【已解决】cocos2d-x v2.2.1 编译 CocoStudio DemoGame

cocos2d-x v2.2.1 编译 CocoStudio DemoGame

PhysicalWorld.cpp

bullet->setB2Body(body);
bullet->setPTMRatio(PT_RATIO);

编译时候报错。。

PhysicalWorld.obj : error LNK2019: unresolved external symbol “public: void __thiscall cocos2d::extension::CCPhysicsSprite::setPTMRatio(float)” (?setPTMRatio@CCPhysicsSprite@extension@cocos2d@@QAEXM@Z) referenced in function “private: void __thiscall PhysicalWorld::createBullet(class cocos2d::CCPoint,class cocos2d::CCActionInterval *)” (?createBullet@PhysicalWorld@@AAEXVCCPoint@cocos2d@@PAVCCActionInterval@3@@Z)
PhysicalWorld.obj : error LNK2019: unresolved external symbol “public: void __thiscall cocos2d::extension::CCPhysicsSprite::setB2Body(class b2Body *)” (?setB2Body@CCPhysicsSprite@extension@cocos2d@@QAEXPAVb2Body@@@Z) referenced in function “private: void __thiscall PhysicalWorld::createBullet(class cocos2d::CCPoint,class cocos2d::CCActionInterval *)” (?createBullet@PhysicalWorld@@AAEXVCCPoint@cocos2d@@PAVCCActionInterval@3@@Z)

这个问题怎么解决呢?

http://www.cocoachina.com/bbs/read.php?tid=163573

你要切换物理引擎

这个在例子目录下面有个readme的word,使用box2d引擎
a. for Windos ------ Visual Studio 2012
DemoGame—> properties ----->project configuration—> C++ ---->preprocessor---->preprocessor definitions—> change CC_ENABLE_CHIPMUNK_INTEGRATION=1 to CC_ENABLE_BOX2D_INTEGRATION=1
then do the same thing to project libExtension
!!!需要注意的是,是DemoGame和libExtension两个工程都需要这样操作
!!!另外一点是要在DemoGame和libExtension两个工程的lib库加上libBox2d.lib,本人碰到的是libExtension工程里面没有加,报了很多链接错误。当然你也可以看一下链接错误是哪一个库导致的,检查一下这个库有没有包含进来