Merge pull request #15113 from zilongshanren/improve-node-api-docs

improve the api doc for node.
This commit is contained in:
xiaofeng11 2016-02-25 13:56:23 +08:00
commit c3eeb7c6b9
1 changed files with 109 additions and 10 deletions

View File

@ -1629,7 +1629,7 @@ public:
*/ */
Vec2 convertTouchToNodeSpaceAR(Touch * touch) const; Vec2 convertTouchToNodeSpaceAR(Touch * touch) const;
/** /**
* Sets an additional transform matrix to the node. * Sets an additional transform matrix to the node.
* *
* In order to remove it, call it again with the argument `nullptr`. * In order to remove it, call it again with the argument `nullptr`.
@ -1684,34 +1684,133 @@ public:
/// @} end of component functions /// @} end of component functions
// overrides // overrides
/**
* Return the node's opacity.
* @return A GLubyte value.
*/
virtual GLubyte getOpacity() const; virtual GLubyte getOpacity() const;
/**
* Return the node's display opacity.
* The difference between opacity and displayedOpacity is:
* The displayedOpacity is what's the final rendering opacity of node.
* @return A GLubyte value.
*/
virtual GLubyte getDisplayedOpacity() const; virtual GLubyte getDisplayedOpacity() const;
/**
* Change node opacity.
* @param opacity A GLubyte opacity value.
*/
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);
/**
* Update the displayed opacity of node with it's parent opacity;
* @param parentOpacity The opacity of parent node.
*/
virtual void updateDisplayedOpacity(GLubyte parentOpacity); virtual void updateDisplayedOpacity(GLubyte parentOpacity);
/**
* Whether cascadeOpacity is enabled or not.
* @return A boolean value.
*/
virtual bool isCascadeOpacityEnabled() const; virtual bool isCascadeOpacityEnabled() const;
/**
* Change node's cascadeOpacity property.
* @param cascadeOpacityEnabled True to enable cascadeOpacity, false otherwise.
*/
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
/**
* Query node's color value.
* @return A Color3B color value.
*/
virtual const Color3B& getColor() const; virtual const Color3B& getColor() const;
/**
* Query node's displayed color.
* @return A Color3B color value.
*/
virtual const Color3B& getDisplayedColor() const; virtual const Color3B& getDisplayedColor() const;
/**
* Change the color of node.
* @param color A Color3B color value.
*/
virtual void setColor(const Color3B& color); virtual void setColor(const Color3B& color);
/**
* Update node's displayed color with its parent color.
* @param parentColor A Color3B color value.
*/
virtual void updateDisplayedColor(const Color3B& parentColor); virtual void updateDisplayedColor(const Color3B& parentColor);
/**
* Query whether cascadeColor is enabled or not.
* @return Whether cascadeColor is enabled or not.
*/
virtual bool isCascadeColorEnabled() const; virtual bool isCascadeColorEnabled() const;
/**
* If you want node's color affect the children node's color, then set it to true.
* Otherwise, set it to false.
* @param cascadeColorEnabled A boolean value.
*/
virtual void setCascadeColorEnabled(bool cascadeColorEnabled); virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
/**
* If you want the opacity affect the color property, then set to true.
* @param value A boolean value.
*/
virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);} virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);}
/**
* If node opacity will modify the RGB color value, then you should override this method and return true.
* @return A boolean value, true indicates that opacity will modify color; false otherwise.
*/
virtual bool isOpacityModifyRGB() const { return false; }; virtual bool isOpacityModifyRGB() const { return false; };
/**
* Set the callback of event onEnter.
* @param callback A std::function<void()> callback.
*/
void setOnEnterCallback(const std::function<void()>& callback) { _onEnterCallback = callback; } void setOnEnterCallback(const std::function<void()>& callback) { _onEnterCallback = callback; }
/**
* Get the callback of event onEnter.
* @return A std:function<void()> callback.
*/
const std::function<void()>& getOnEnterCallback() const { return _onEnterCallback; } const std::function<void()>& getOnEnterCallback() const { return _onEnterCallback; }
/**
* Set the callback of event onExit.
* @param callback A std::function<void()> callback.
*/
void setOnExitCallback(const std::function<void()>& callback) { _onExitCallback = callback; } void setOnExitCallback(const std::function<void()>& callback) { _onExitCallback = callback; }
/**
* Get the callback of event onExit.
* @return A std::function<void()>.
*/
const std::function<void()>& getOnExitCallback() const { return _onExitCallback; } const std::function<void()>& getOnExitCallback() const { return _onExitCallback; }
/**
* Set the callback of event EnterTransitionDidFinish.
* @param callback A std::function<void()> callback.
*/
void setonEnterTransitionDidFinishCallback(const std::function<void()>& callback) { _onEnterTransitionDidFinishCallback = callback; } void setonEnterTransitionDidFinishCallback(const std::function<void()>& callback) { _onEnterTransitionDidFinishCallback = callback; }
/**
* Get the callback of event EnterTransitionDidFinish.
* @return std::function<void()>
*/
const std::function<void()>& getonEnterTransitionDidFinishCallback() const { return _onEnterTransitionDidFinishCallback; } const std::function<void()>& getonEnterTransitionDidFinishCallback() const { return _onEnterTransitionDidFinishCallback; }
/**
* Set the callback of event ExitTransitionDidStart.
* @param callback A std::function<void()> callback.
*/
void setonExitTransitionDidStartCallback(const std::function<void()>& callback) { _onExitTransitionDidStartCallback = callback; } void setonExitTransitionDidStartCallback(const std::function<void()>& callback) { _onExitTransitionDidStartCallback = callback; }
/**
* Get the callback of event ExitTransitionDidStart.
* @return std::function<void()>
*/
const std::function<void()>& getonExitTransitionDidStartCallback() const { return _onExitTransitionDidStartCallback; } const std::function<void()>& getonExitTransitionDidStartCallback() const { return _onExitTransitionDidStartCallback; }
/** get & set camera mask, the node is visible by the camera whose camera flag & node's camera mask is true */ /**
* get & set camera mask, the node is visible by the camera whose camera flag & node's camera mask is true
*/
unsigned short getCameraMask() const { return _cameraMask; } unsigned short getCameraMask() const { return _cameraMask; }
/**
* Modify the camera mask for current node.
* If applyChildren is true, then it will modify the camera mask of its children recursively.
* @param mask A unsigned short bit for mask.
* @param applyChildren A boolean value to determine whether the mask bit should apply to its children or not.
*/
virtual void setCameraMask(unsigned short mask, bool applyChildren = true); virtual void setCameraMask(unsigned short mask, bool applyChildren = true);
CC_CONSTRUCTOR_ACCESS: CC_CONSTRUCTOR_ACCESS:
@ -1841,11 +1940,11 @@ protected:
ComponentContainer *_componentContainer; ///< Dictionary of components ComponentContainer *_componentContainer; ///< Dictionary of components
// opacity controls // opacity controls
GLubyte _displayedOpacity; GLubyte _displayedOpacity;
GLubyte _realOpacity; GLubyte _realOpacity;
Color3B _displayedColor; Color3B _displayedColor;
Color3B _realColor; Color3B _realColor;
bool _cascadeColorEnabled; bool _cascadeColorEnabled;
bool _cascadeOpacityEnabled; bool _cascadeOpacityEnabled;
static int s_globalOrderOfArrival; static int s_globalOrderOfArrival;