Skip to content

Commit 0029419

Browse files
committed
refactor CCScene
* use member initializer list * add const to member function
1 parent 2727af8 commit 0029419

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Diff for: cocos/2d/CCScene.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ THE SOFTWARE.
5252
NS_CC_BEGIN
5353

5454
Scene::Scene()
55-
{
55+
: _defaultCamera(Camera::create())
56+
, _cameraOrderDirty(true)
57+
, _event(Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Scene::onProjectionChanged, this, std::placeholders::_1)))
58+
#if CC_USE_PHYSICS
59+
, _physicsWorld(nullptr)
60+
#endif
5661
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
57-
_physics3DWorld = nullptr;
58-
_physics3dDebugCamera = nullptr;
62+
, _physics3DWorld(nullptr)
63+
, _physics3dDebugCamera(nullptr)
5964
#endif
6065
#if CC_USE_NAVMESH
61-
_navMesh = nullptr;
62-
_navMeshDebugCamera = nullptr;
63-
#endif
64-
#if CC_USE_PHYSICS
65-
_physicsWorld = nullptr;
66+
, _navMesh(nullptr)
67+
, _navMeshDebugCamera(nullptr)
6668
#endif
69+
{
6770
_ignoreAnchorPointForPosition = true;
6871
setAnchorPoint(Vec2(0.5f, 0.5f));
6972

70-
_cameraOrderDirty = true;
71-
7273
//create default camera
73-
_defaultCamera = Camera::create();
74+
7475
addChild(_defaultCamera);
7576

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

7979
Camera::_visitingCamera = nullptr;

Diff for: cocos/2d/CCScene.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class CC_DLL Scene : public Node
180180
* @return The 3d physics world of the scene.
181181
* @js NA
182182
*/
183-
Physics3DWorld* getPhysics3DWorld() { return _physics3DWorld; }
183+
Physics3DWorld* getPhysics3DWorld() const { return _physics3DWorld; }
184184

185185
/**
186186
* Set Physics3D debug draw camera.

0 commit comments

Comments
 (0)