add Scene::update & addChild into CC_USE_PHYSICS scope, TestCpp compiles and runs successfully when CC_USE_PHYSICS == 0

This commit is contained in:
walzer 2013-12-27 15:49:08 +08:00
parent d7704d574a
commit ece68aafc2
4 changed files with 5 additions and 9 deletions

View File

@ -88,26 +88,22 @@ Scene* Scene::getScene()
return this;
}
#if CC_USE_PHYSICS
void Scene::addChild(Node* child, int zOrder, int tag)
{
Node::addChild(child, zOrder, tag);
#if CC_USE_PHYSICS
addChildToPhysicsWorld(child);
#endif
}
void Scene::update(float delta)
{
Node::update(delta);
#if CC_USE_PHYSICS
if (nullptr != _physicsWorld)
{
_physicsWorld->update(delta);
}
#endif
}
#if CC_USE_PHYSICS
Scene *Scene::createWithPhysics()
{
Scene *ret = new Scene();

View File

@ -57,8 +57,6 @@ public:
virtual Scene *getScene() override;
using Node::addChild;
virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void update(float delta) override;
virtual std::string getDescription() const override;
protected:
@ -74,6 +72,8 @@ private:
#if CC_USE_PHYSICS
public:
virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void update(float delta) override;
inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; }
static Scene *createWithPhysics();
protected:

View File

@ -79,7 +79,7 @@ void PhysicsTestScene::toggleDebug()
#endif
}
#ifndef CC_USE_PHYSICS
#if CC_USE_PHYSICS == 0
void PhysicsDemoDisabled::onEnter()
{
auto label = LabelTTF::create("Should define CC_USE_PHYSICS\n to run this test case",

View File

@ -22,7 +22,7 @@ private:
bool _debugDraw;
};
#ifndef CC_USE_PHYSICS
#if CC_USE_PHYSICS == 0
class PhysicsDemoDisabled : public BaseTest
{
public: