From c527d7476bc1045f29a3ea5ba19805cb3715ff47 Mon Sep 17 00:00:00 2001 From: cpascal Date: Fri, 19 Sep 2014 01:35:01 +0900 Subject: [PATCH 1/3] Fixed compile error when I turned off physics definitions. Fixed the following compile error. cocos2d\extensions\physics-nodes\ccphysicssprite.cpp(305): error C4716: 'cocos2d::extension::PhysicsSprite::getRotation' : must return a value and more.. Conditions: CC_USE_PHYSICS = 0 CC_ENABLE_CHIPMUNK_INTEGRATION = 0 CC_ENABLE_BOX2D_INTEGRATION = 0 --- extensions/physics-nodes/CCPhysicsSprite.cpp | 4 ++++ extensions/physics-nodes/CCPhysicsSprite.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index e5b631fa33..2b6afdcba5 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -22,6 +22,8 @@ #include "CCPhysicsSprite.h" +#if CC_USE_PHYSICS + #if (CC_ENABLE_CHIPMUNK_INTEGRATION && CC_ENABLE_BOX2D_INTEGRATION) #error "Either Chipmunk or Box2d should be enabled, but not both at the same time" #endif @@ -408,3 +410,5 @@ void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t fla } NS_CC_EXT_END + +#endif // CC_USE_PHYSICS diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index 33f48a20b0..34e15c2a0b 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -23,6 +23,9 @@ #ifndef __PHYSICSNODES_CCPHYSICSSPRITE_H__ #define __PHYSICSNODES_CCPHYSICSSPRITE_H__ +#include "base/ccConfig.h" +#if CC_USE_PHYSICS + #include "2d/CCSprite.h" #include "extensions/ExtensionMacros.h" #include "extensions/ExtensionExport.h" @@ -135,4 +138,6 @@ protected: NS_CC_EXT_END +#endif // CC_USE_PHYSICS + #endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__ From 07f5568ae81b1c4b70ea1b8f74132bfee291fb97 Mon Sep 17 00:00:00 2001 From: cpascal Date: Mon, 22 Sep 2014 14:19:08 +0900 Subject: [PATCH 2/3] Using CC_ENABLE_CHIPMUNK_INTEGRATION and CC_ENABLE_BOX2D_INTEGRATION instead of CC_USE_PHYSICS --- extensions/physics-nodes/CCPhysicsSprite.cpp | 6 ++++-- extensions/physics-nodes/CCPhysicsSprite.h | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index 2b6afdcba5..1a4d69c88b 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -22,7 +22,7 @@ #include "CCPhysicsSprite.h" -#if CC_USE_PHYSICS +#if (!CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION) #if (CC_ENABLE_CHIPMUNK_INTEGRATION && CC_ENABLE_BOX2D_INTEGRATION) #error "Either Chipmunk or Box2d should be enabled, but not both at the same time" @@ -302,6 +302,8 @@ float PhysicsSprite::getRotation() const return (_ignoreBodyRotation ? Sprite::getRotation() : CC_RADIANS_TO_DEGREES(_pB2Body->GetAngle())); +#else + return 0.0f; #endif } @@ -411,4 +413,4 @@ void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t fla NS_CC_EXT_END -#endif // CC_USE_PHYSICS +#endif // !CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index 34e15c2a0b..a42dfcb6e5 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -23,13 +23,12 @@ #ifndef __PHYSICSNODES_CCPHYSICSSPRITE_H__ #define __PHYSICSNODES_CCPHYSICSSPRITE_H__ -#include "base/ccConfig.h" -#if CC_USE_PHYSICS - #include "2d/CCSprite.h" #include "extensions/ExtensionMacros.h" #include "extensions/ExtensionExport.h" +#if (!CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION) + struct cpBody; class b2Body; @@ -138,6 +137,6 @@ protected: NS_CC_EXT_END -#endif // CC_USE_PHYSICS +#endif // !CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION #endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__ From fe075891417ba0a86f51c4a53913c69878112d50 Mon Sep 17 00:00:00 2001 From: cpascal Date: Mon, 22 Sep 2014 14:25:47 +0900 Subject: [PATCH 3/3] Fixed my mistakes - preprocessor. --- extensions/physics-nodes/CCPhysicsSprite.cpp | 4 ++-- extensions/physics-nodes/CCPhysicsSprite.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index 1a4d69c88b..96011e2d4d 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -22,7 +22,7 @@ #include "CCPhysicsSprite.h" -#if (!CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION) +#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION) #if (CC_ENABLE_CHIPMUNK_INTEGRATION && CC_ENABLE_BOX2D_INTEGRATION) #error "Either Chipmunk or Box2d should be enabled, but not both at the same time" @@ -413,4 +413,4 @@ void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t fla NS_CC_EXT_END -#endif // !CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION +#endif // CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index a42dfcb6e5..7d68e7ca1a 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -27,7 +27,7 @@ #include "extensions/ExtensionMacros.h" #include "extensions/ExtensionExport.h" -#if (!CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION) +#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION) struct cpBody; class b2Body; @@ -137,6 +137,6 @@ protected: NS_CC_EXT_END -#endif // !CC_ENABLE_CHIPMUNK_INTEGRATION && !CC_ENABLE_BOX2D_INTEGRATION +#endif // CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION #endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__