Projects > cpp > Issues > Bug #3517

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

CC_USE_PHYSICS is actually impossible to turn it off

Bug #3517 [Closed]
walzer@cocos2d-x.org 2013-12-26 15:51 . Updated about 11 years ago

in ccConfig.h,

#ifndef CC_USE_PHYSICS
#define CC_USE_PHYSICS
#endif

in source code, e.g., Scene.cpp

#ifdef CC_USE_PHYSICS
// blabla
#endif

As the result, no matter I define CC_USE_PHYSICS or not, ccConfig.h will define it more me AUTOMATICALLY, then apply in all cpp code.

And the worse:

// in Scene.cpp
#ifdef CC_USE_PHYSICS
void Scene::update(float delta)
{
    Node::update(delta);
    if (nullptr != _physicsWorld)
    {
        _physicsWorld->update(delta);
    }
}
#endif

So if I switch off CC_USE_PHYSICS, then Scene will no has update method.

How these code be reviewed and merged?

walzer@cocos2d-x.org 2013-12-26 15:53
  • Description updated (diff)
dumganhar 2013-12-27 01:58

Yep, I agree with 1),
But for 2) ,you said

So if I switch off CC_USE_PHYSICS, then Scene will no has update method.

Notice that Node::update is a virtual function. We override Scene::update only for physics. That doesn’t mean that Scene has no update method, its parent Node own it.

boyu0 2013-12-27 02:15

James is right.
I think if you want to disable CC_USE_PHYSICS, you can comment CC_USE_PHYSICS definition in ccConfig.h. and I tried to comment that and compiled the code, it’s ok.
Yes, use #if instead of #ifdef is better, thanks.

walzer@cocos2d-x.org 2013-12-28 22:11
  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:a4558e33631773554cfa0530172d688647a8c86c.

Atom PDF

Status:Closed
Start date:2013-12-26
Priority:Normal
Due date:
Assignee:walzer@cocos2d-x.org
% Done:

100%

Category:all
Target version:3.0-beta