diff --git a/cocos/2d/CCAction.h b/cocos/2d/CCAction.h index 2842301b9027..bdf4a26b2162 100644 --- a/cocos/2d/CCAction.h +++ b/cocos/2d/CCAction.h @@ -99,10 +99,11 @@ class CC_DLL Action : public Ref, public Clonable inline int getTag() const { return _tag; } inline void setTag(int tag) { _tag = tag; } -protected: +CC_CONSTRUCTOR_ACCESS: Action(); virtual ~Action(); +protected: Node *_originalTarget; /** The "target". The target will be set with the 'startWithTarget' method. @@ -140,12 +141,13 @@ class CC_DLL FiniteTimeAction : public Action virtual FiniteTimeAction* reverse() const override = 0; virtual FiniteTimeAction* clone() const override = 0; -protected: +CC_CONSTRUCTOR_ACCESS: FiniteTimeAction() : _duration(0) {} virtual ~FiniteTimeAction(){} +protected: //! duration in seconds float _duration; diff --git a/cocos/2d/CCActionGrid.h b/cocos/2d/CCActionGrid.h index 77329cdbc4c5..64f766827f3f 100644 --- a/cocos/2d/CCActionGrid.h +++ b/cocos/2d/CCActionGrid.h @@ -52,12 +52,13 @@ class CC_DLL GridAction : public ActionInterval virtual GridAction* reverse() const override; virtual void startWithTarget(Node *target) override; -protected: +CC_CONSTRUCTOR_ACCESS: GridAction() {} virtual ~GridAction() {} /** initializes the action with size and duration */ bool initWithDuration(float duration, const Size& gridSize); +protected: Size _gridSize; NodeGrid* _gridNodeTarget; @@ -273,10 +274,11 @@ class CC_DLL StopGrid : public ActionInstant virtual StopGrid* clone() const override; virtual StopGrid* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: StopGrid() {} virtual ~StopGrid() {} +protected: NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); diff --git a/cocos/2d/CCActionGrid3D.h b/cocos/2d/CCActionGrid3D.h index 89c187cc58f2..4c9491e3c050 100644 --- a/cocos/2d/CCActionGrid3D.h +++ b/cocos/2d/CCActionGrid3D.h @@ -108,7 +108,7 @@ class CC_DLL FlipY3D : public FlipX3D virtual void update(float time) override; virtual FlipY3D* clone() const override; -protected: +CC_CONSTRUCTOR_ACCESS: FlipY3D() {} virtual ~FlipY3D() {} private: diff --git a/cocos/2d/CCActionInstant.h b/cocos/2d/CCActionInstant.h index c74d6f037803..b8aa440a4bd3 100644 --- a/cocos/2d/CCActionInstant.h +++ b/cocos/2d/CCActionInstant.h @@ -74,7 +74,7 @@ class CC_DLL Show : public ActionInstant virtual ActionInstant* reverse() const override; virtual Show* clone() const override; -protected: +CC_CONSTRUCTOR_ACCESS: Show(){} virtual ~Show(){} @@ -98,7 +98,7 @@ class CC_DLL Hide : public ActionInstant virtual ActionInstant* reverse() const override; virtual Hide* clone() const override; -protected: +CC_CONSTRUCTOR_ACCESS: Hide(){} virtual ~Hide(){} @@ -121,7 +121,7 @@ class CC_DLL ToggleVisibility : public ActionInstant virtual ToggleVisibility* reverse() const override; virtual ToggleVisibility* clone() const override; -protected: +CC_CONSTRUCTOR_ACCESS: ToggleVisibility(){} virtual ~ToggleVisibility(){} @@ -402,13 +402,14 @@ class CC_DLL __CCCallFuncND : public CallFunc virtual __CCCallFuncND* clone() const override; virtual void execute() override; -protected: +CC_CONSTRUCTOR_ACCESS: __CCCallFuncND() {} virtual ~__CCCallFuncND() {} /** initializes the action with the callback and the data to pass as an argument */ bool initWithTarget(Ref* target, SEL_CallFuncND selector, void* d); +protected: SEL_CallFuncND _callFuncND; void* _data; @@ -441,7 +442,7 @@ class CC_DLL __CCCallFuncO : public CallFunc Ref* getObject() const; void setObject(Ref* obj); -protected: +CC_CONSTRUCTOR_ACCESS: __CCCallFuncO(); virtual ~__CCCallFuncO(); /** initializes the action with the callback @@ -450,7 +451,7 @@ class CC_DLL __CCCallFuncO : public CallFunc */ bool initWithTarget(Ref* target, SEL_CallFuncO selector, Ref* object); - +protected: /** object to be passed as argument */ Ref* _object; SEL_CallFuncO _callFuncO; diff --git a/cocos/2d/CCActionTiledGrid.h b/cocos/2d/CCActionTiledGrid.h index 6f3e846353e2..844e814b703a 100644 --- a/cocos/2d/CCActionTiledGrid.h +++ b/cocos/2d/CCActionTiledGrid.h @@ -142,7 +142,7 @@ class CC_DLL FadeOutTRTiles : public TiledGrid3DAction virtual void update(float time) override; virtual FadeOutTRTiles* clone() const override; -protected: +CC_CONSTRUCTOR_ACCESS: FadeOutTRTiles() {} virtual ~FadeOutTRTiles() {} @@ -163,7 +163,7 @@ class CC_DLL FadeOutBLTiles : public FadeOutTRTiles virtual float testFunc(const Size& pos, float time) override; virtual FadeOutBLTiles* clone() const override; -protected: +CC_CONSTRUCTOR_ACCESS: FadeOutBLTiles() {} virtual ~FadeOutBLTiles() {} @@ -186,7 +186,7 @@ class CC_DLL FadeOutUpTiles : public FadeOutTRTiles virtual FadeOutUpTiles* clone() const override; virtual float testFunc(const Size& pos, float time) override; -protected: +CC_CONSTRUCTOR_ACCESS: FadeOutUpTiles() {} virtual ~FadeOutUpTiles() {} @@ -207,7 +207,7 @@ class CC_DLL FadeOutDownTiles : public FadeOutUpTiles virtual FadeOutDownTiles* clone() const override; virtual float testFunc(const Size& pos, float time) override; -protected: +CC_CONSTRUCTOR_ACCESS: FadeOutDownTiles() {} virtual ~FadeOutDownTiles() {} diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index a81daf8e6b0e..de4173527ceb 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -275,6 +275,18 @@ class CC_DLL Label : public SpriteBatchNode, public LabelProtocol CC_DEPRECATED_ATTRIBUTE int getCommonLineHeight() const { return getLineHeight();} +CC_CONSTRUCTOR_ACCESS: + /** + * @js NA + */ + Label(FontAtlas *atlas = nullptr, TextHAlignment hAlignment = TextHAlignment::LEFT, + TextVAlignment vAlignment = TextVAlignment::TOP,bool useDistanceField = false,bool useA8Shader = false); + /** + * @js NA + * @lua NA + */ + virtual ~Label(); + protected: void onDraw(const Mat4& transform, bool transformUpdated); @@ -294,17 +306,6 @@ class CC_DLL Label : public SpriteBatchNode, public LabelProtocol STRING_TEXTURE }; - /** - * @js NA - */ - Label(FontAtlas *atlas = nullptr, TextHAlignment hAlignment = TextHAlignment::LEFT, - TextVAlignment vAlignment = TextVAlignment::TOP,bool useDistanceField = false,bool useA8Shader = false); - /** - * @js NA - * @lua NA - */ - virtual ~Label(); - virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false); bool recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex); diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index 2c373fe76e2a..b0e26d3ffbf9 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -87,7 +87,7 @@ class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; #endif -protected: +CC_CONSTRUCTOR_ACCESS: LabelAtlas() :_string("") {} @@ -96,6 +96,8 @@ class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol { _string.clear(); } + +protected: virtual void updateColor() override; #if CC_LABELATLAS_DEBUG_DRAW diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index b6f985aa72b6..46d40c3df538 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -228,7 +228,7 @@ class CC_DLL __LayerRGBA : public Layer, public __RGBAProtocol virtual void setOpacityModifyRGB(bool bValue) override { return Layer::setOpacityModifyRGB(bValue); } virtual bool isOpacityModifyRGB() const override { return Layer::isOpacityModifyRGB(); } -protected: +CC_CONSTRUCTOR_ACCESS: __LayerRGBA(); virtual ~__LayerRGBA() {} diff --git a/cocos/2d/CCNodeGrid.h b/cocos/2d/CCNodeGrid.h index 12266b1a4149..de1fdfa2d97f 100644 --- a/cocos/2d/CCNodeGrid.h +++ b/cocos/2d/CCNodeGrid.h @@ -56,10 +56,11 @@ class NodeGrid : public Node // overrides virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; -protected: +CC_CONSTRUCTOR_ACCESS: NodeGrid(); virtual ~NodeGrid(); - + +protected: void onGridBeginDraw(); void onGridEndDraw(); diff --git a/cocos/2d/CCParallaxNode.h b/cocos/2d/CCParallaxNode.h index df584f2f637b..cc1f12e14680 100644 --- a/cocos/2d/CCParallaxNode.h +++ b/cocos/2d/CCParallaxNode.h @@ -70,7 +70,7 @@ class CC_DLL ParallaxNode : public Node virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; -protected: +CC_CONSTRUCTOR_ACCESS: /** Adds a child to the container with a z-order, a parallax ratio and a position offset It returns self, so you can chain several addChilds. @since v0.8 @@ -83,6 +83,7 @@ class CC_DLL ParallaxNode : public Node */ virtual ~ParallaxNode(); +protected: Vec2 absolutePosition(); Vec2 _lastPosition; diff --git a/cocos/Android.mk b/cocos/Android.mk index 763a55cd169f..47d9e8bf5f82 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -188,7 +188,7 @@ physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/. \ $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/base + $(LOCAL_PATH)/base \ $(LOCAL_PATH)/../external/tinyxml2 \ $(LOCAL_PATH)/../external/unzip \ $(LOCAL_PATH)/../external/chipmunk/include/chipmunk \ diff --git a/cocos/base/CCEvent.h b/cocos/base/CCEvent.h index 4bc129c0529d..98480961b969 100644 --- a/cocos/base/CCEvent.h +++ b/cocos/base/CCEvent.h @@ -55,7 +55,7 @@ class Event : public Ref CUSTOM }; -protected: +CC_CONSTRUCTOR_ACCESS: /** Constructor */ Event(Type type); public: diff --git a/cocos/base/CCEventListener.h b/cocos/base/CCEventListener.h index d890c6938d43..a771f70443bb 100644 --- a/cocos/base/CCEventListener.h +++ b/cocos/base/CCEventListener.h @@ -63,7 +63,7 @@ class EventListener : public Ref typedef std::string ListenerID; -protected: +CC_CONSTRUCTOR_ACCESS: /** Constructor */ EventListener(); diff --git a/cocos/base/CCEventListenerAcceleration.h b/cocos/base/CCEventListenerAcceleration.h index 78e145c87ae9..b58736632fb4 100644 --- a/cocos/base/CCEventListenerAcceleration.h +++ b/cocos/base/CCEventListenerAcceleration.h @@ -41,10 +41,13 @@ class EventListenerAcceleration : public EventListener /// Overrides virtual EventListenerAcceleration* clone() override; virtual bool checkAvailable() override; -private: + +CC_CONSTRUCTOR_ACCESS: EventListenerAcceleration(); bool init(const std::function& callback); + +private: std::function onAccelerationEvent; friend class LuaEventListenerAcceleration; diff --git a/cocos/base/CCEventListenerFocus.h b/cocos/base/CCEventListenerFocus.h index dec59f774a6d..3ebd6ceb6d2d 100644 --- a/cocos/base/CCEventListenerFocus.h +++ b/cocos/base/CCEventListenerFocus.h @@ -51,10 +51,10 @@ class EventListenerFocus : public EventListener public: std::function onFocusChanged; -private: +CC_CONSTRUCTOR_ACCESS: EventListenerFocus(); bool init(); - +private: friend class EventDispatcher; }; diff --git a/cocos/base/CCEventListenerKeyboard.h b/cocos/base/CCEventListenerKeyboard.h index 5f14abc2e9c0..1aa8a10f855a 100644 --- a/cocos/base/CCEventListenerKeyboard.h +++ b/cocos/base/CCEventListenerKeyboard.h @@ -46,7 +46,7 @@ class EventListenerKeyboard : public EventListener std::function onKeyPressed; std::function onKeyReleased; -private: +CC_CONSTRUCTOR_ACCESS: EventListenerKeyboard(); bool init(); }; diff --git a/cocos/base/CCEventListenerMouse.h b/cocos/base/CCEventListenerMouse.h index 22708e137bf5..57b98997dc84 100644 --- a/cocos/base/CCEventListenerMouse.h +++ b/cocos/base/CCEventListenerMouse.h @@ -49,7 +49,7 @@ class EventListenerMouse : public EventListener std::function onMouseMove; std::function onMouseScroll; -private: +CC_CONSTRUCTOR_ACCESS: EventListenerMouse(); bool init(); }; diff --git a/cocos/base/CCEventListenerTouch.h b/cocos/base/CCEventListenerTouch.h index c2fbace749cd..9525333d6b1e 100644 --- a/cocos/base/CCEventListenerTouch.h +++ b/cocos/base/CCEventListenerTouch.h @@ -56,10 +56,10 @@ class EventListenerTouchOneByOne : public EventListener std::function onTouchEnded; std::function onTouchCancelled; -private: +CC_CONSTRUCTOR_ACCESS: EventListenerTouchOneByOne(); bool init(); - +private: std::vector _claimedTouches; bool _needSwallow; @@ -85,7 +85,7 @@ class EventListenerTouchAllAtOnce : public EventListener std::function&, Event*)> onTouchesEnded; std::function&, Event*)> onTouchesCancelled; -private: +CC_CONSTRUCTOR_ACCESS: EventListenerTouchAllAtOnce(); bool init(); private: diff --git a/cocos/editor-support/cocostudio/CCInputDelegate.h b/cocos/editor-support/cocostudio/CCInputDelegate.h index 89ef95b6c217..4d20fd53c2ea 100644 --- a/cocos/editor-support/cocostudio/CCInputDelegate.h +++ b/cocos/editor-support/cocostudio/CCInputDelegate.h @@ -43,7 +43,7 @@ namespace cocostudio { */ class InputDelegate { -protected: +CC_CONSTRUCTOR_ACCESS: /** * @js ctor */ diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.h b/cocos/editor-support/cocostudio/CCSSceneReader.h index 7d982858b28c..fbaef5b02f9a 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.h +++ b/cocos/editor-support/cocostudio/CCSSceneReader.h @@ -65,9 +65,12 @@ class SceneReader void setTarget(const std::function& selector); cocos2d::Node* getNodeByTag(int nTag); inline AttachComponentType getAttachComponentType(){return _attachComponent;} -private: + +CC_CONSTRUCTOR_ACCESS: SceneReader(void); virtual ~SceneReader(void); + +private: std::string getComponentClassName(const std::string& name); cocos2d::Component* createComponent(const std::string classname); diff --git a/cocos/platform/desktop/CCGLView.h b/cocos/platform/desktop/CCGLView.h index b49a2f49d923..b8c56028c6c4 100644 --- a/cocos/platform/desktop/CCGLView.h +++ b/cocos/platform/desktop/CCGLView.h @@ -80,10 +80,11 @@ class CC_DLL GLView : public GLViewProtocol, public Ref /** Get retina factor */ int getRetinaFactor() const { return _retinaFactor; } -protected: +CC_CONSTRUCTOR_ACCESS: GLView(); virtual ~GLView(); - + +protected: bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor); bool initWithFullScreen(const std::string& viewName); bool initWithFullscreen(const std::string& viewname, const GLFWvidmode &videoMode, GLFWmonitor *monitor); diff --git a/extensions/assets-manager/CCEventAssetsManager.h b/extensions/assets-manager/CCEventAssetsManager.h index 6d3980d94a2f..4cdd646d9a80 100644 --- a/extensions/assets-manager/CCEventAssetsManager.h +++ b/extensions/assets-manager/CCEventAssetsManager.h @@ -71,7 +71,7 @@ class EventAssetsManager : public cocos2d::EventCustom inline float getPercentByFile() const { return _percentByFile; }; -protected: +CC_CONSTRUCTOR_ACCESS: /** Constructor */ EventAssetsManager(const std::string& eventName, cocos2d::extension::AssetsManager *manager, const EventCode &code, float percent = 0, float percentByFile = 0, const std::string& assetId = "", const std::string& message = "", int curle_code = 0, int curlm_code = 0);