Skip to content

Commit

Permalink
refactor CCScene
Browse files Browse the repository at this point in the history
* use member initializer list
* add const to member function
  • Loading branch information
JohnCoconut committed May 27, 2019
1 parent 2727af8 commit 0029419
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions cocos/2d/CCScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ THE SOFTWARE.
NS_CC_BEGIN

Scene::Scene()
{
: _defaultCamera(Camera::create())
, _cameraOrderDirty(true)
, _event(Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Scene::onProjectionChanged, this, std::placeholders::_1)))
#if CC_USE_PHYSICS
, _physicsWorld(nullptr)
#endif
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
_physics3DWorld = nullptr;
_physics3dDebugCamera = nullptr;
, _physics3DWorld(nullptr)
, _physics3dDebugCamera(nullptr)
#endif
#if CC_USE_NAVMESH
_navMesh = nullptr;
_navMeshDebugCamera = nullptr;
#endif
#if CC_USE_PHYSICS
_physicsWorld = nullptr;
, _navMesh(nullptr)
, _navMeshDebugCamera(nullptr)
#endif
{
_ignoreAnchorPointForPosition = true;
setAnchorPoint(Vec2(0.5f, 0.5f));

_cameraOrderDirty = true;

//create default camera
_defaultCamera = Camera::create();

addChild(_defaultCamera);

_event = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Scene::onProjectionChanged, this, std::placeholders::_1));
_event->retain();

Camera::_visitingCamera = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class CC_DLL Scene : public Node
* @return The 3d physics world of the scene.
* @js NA
*/
Physics3DWorld* getPhysics3DWorld() { return _physics3DWorld; }
Physics3DWorld* getPhysics3DWorld() const { return _physics3DWorld; }

/**
* Set Physics3D debug draw camera.
Expand Down

0 comments on commit 0029419

Please sign in to comment.