diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp index 2dabe08a75..941cf42b4d 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp @@ -17,9 +17,12 @@ Box2DTestLayer::Box2DTestLayer() , world(NULL) { #if CC_ENABLE_BOX2D_INTEGRATION - setTouchEnabled( true ); - setAccelerometerEnabled( true ); - + auto dispatcher = Director::getInstance()->getEventDispatcher(); + + auto touchListener = EventListenerTouchAllAtOnce::create(); + touchListener->onTouchesEnded = CC_CALLBACK_2(Box2DTestLayer::onTouchesEnded, this); + dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + // init physics this->initPhysics(); // create reset button diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h index 24d0b43c65..167e2f6fb5 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h @@ -23,7 +23,6 @@ public: void update(float dt); void onTouchesEnded(const std::vector& touches, Event* event); - //CREATE_NODE(Box2DTestLayer); #if CC_ENABLE_BOX2D_INTEGRATION protected: kmMat4 _modelViewMV; diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 3faf685bf1..8c0c94afec 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -85,15 +85,16 @@ void ChipmunkTestLayer::toggleDebugCallback(Object* sender) ChipmunkTestLayer::~ChipmunkTestLayer() { +#if CC_ENABLE_CHIPMUNK_INTEGRATION // manually Free rogue shapes for( int i=0;i<4;i++) { cpShapeFree( _walls[i] ); } cpSpaceFree( _space ); - - Device::setAccelerometerEnabled(false); + Device::setAccelerometerEnabled(false); +#endif } void ChipmunkTestLayer::initPhysics() diff --git a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp index 31c4beaef9..5df463d27d 100644 --- a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp @@ -1,8 +1,9 @@ -// enable log -#define COCOS2D_DEBUG 1 #include "TextureCacheTest.h" +// enable log +#define COCOS2D_DEBUG 1 + USING_NS_CC; TextureCacheTest::TextureCacheTest() diff --git a/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp b/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp index ae440e66db..27a5a8fa1a 100644 --- a/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp +++ b/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp @@ -1,10 +1,10 @@ -// enable log -#define COCOS2D_DEBUG 1 - #include "UserDefaultTest.h" #include "stdio.h" #include "stdlib.h" +// enable log +#define COCOS2D_DEBUG 1 + UserDefaultTest::UserDefaultTest() { auto s = Director::getInstance()->getWinSize(); diff --git a/samples/Cpp/TestCpp/proj.android/jni/Application.mk b/samples/Cpp/TestCpp/proj.android/jni/Application.mk index 47d8add103..1b8a21215f 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/Application.mk +++ b/samples/Cpp/TestCpp/proj.android/jni/Application.mk @@ -2,4 +2,4 @@ APP_STL := gnustl_static # add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] # in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix -fsigned-char +APP_CPPFLAGS := -frtti -DCC_ENABLE_BOX2D_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix -fsigned-char