diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index f9a37c78ef..58e8231b3b 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -208,12 +208,12 @@ void AtlasNode::setIgnoreContentScaleFactor(bool bIgnoreContentScaleFactor) // AtlasNode - CocosNodeTexture protocol -ccBlendFunc AtlasNode::getBlendFunc() +const ccBlendFunc& AtlasNode::getBlendFunc() const { return _blendFunc; } -void AtlasNode::setBlendFunc(ccBlendFunc blendFunc) +void AtlasNode::setBlendFunc(const ccBlendFunc &blendFunc) { _blendFunc = blendFunc; } diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index 6ad782767d..fdb6ba46ef 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -69,7 +69,7 @@ protected: // protocol variables bool _isOpacityModifyRGB; - CC_PROPERTY(ccBlendFunc, _blendFunc, BlendFunc); + CC_PROPERTY_PASS_BY_REF(ccBlendFunc, _blendFunc, BlendFunc); // quads to draw CC_PROPERTY(unsigned int, _quadsToDraw, QuadsToDraw); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 0673a5fee6..8909684e13 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -149,7 +149,7 @@ bool Node::init() return true; } -float Node::getSkewX() +float Node::getSkewX() const { return _skewX; } @@ -160,7 +160,7 @@ void Node::setSkewX(float newSkewX) _transformDirty = _inverseDirty = true; } -float Node::getSkewY() +float Node::getSkewY() const { return _skewY; } @@ -173,7 +173,7 @@ void Node::setSkewY(float newSkewY) } /// zOrder getter -int Node::getZOrder() +int Node::getZOrder() const { return _ZOrder; } @@ -195,7 +195,7 @@ void Node::setZOrder(int z) } /// vertexZ getter -float Node::getVertexZ() +float Node::getVertexZ() const { return _vertexZ; } @@ -209,7 +209,7 @@ void Node::setVertexZ(float var) /// rotation getter -float Node::getRotation() +float Node::getRotation() const { CCAssert(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return"); return _rotationX; @@ -222,7 +222,7 @@ void Node::setRotation(float newRotation) _transformDirty = _inverseDirty = true; } -float Node::getRotationX() +float Node::getRotationX() const { return _rotationX; } @@ -233,7 +233,7 @@ void Node::setRotationX(float fRotationX) _transformDirty = _inverseDirty = true; } -float Node::getRotationY() +float Node::getRotationY() const { return _rotationY; } @@ -245,7 +245,7 @@ void Node::setRotationY(float fRotationY) } /// scale getter -float Node::getScale(void) +float Node::getScale(void) const { CCAssert( _scaleX == _scaleY, "CCNode#scale. ScaleX != ScaleY. Don't know which one to return"); return _scaleX; @@ -259,7 +259,7 @@ void Node::setScale(float scale) } /// scaleX getter -float Node::getScaleX() +float Node::getScaleX() const { return _scaleX; } @@ -272,7 +272,7 @@ void Node::setScaleX(float newScaleX) } /// scaleY getter -float Node::getScaleY() +float Node::getScaleY() const { return _scaleY; } @@ -285,7 +285,7 @@ void Node::setScaleY(float newScaleY) } /// position getter -const Point& Node::getPosition() +const Point& Node::getPosition() const { return _position; } @@ -297,7 +297,7 @@ void Node::setPosition(const Point& newPosition) _transformDirty = _inverseDirty = true; } -void Node::getPosition(float* x, float* y) +void Node::getPosition(float* x, float* y) const { *x = _position.x; *y = _position.y; @@ -308,12 +308,12 @@ void Node::setPosition(float x, float y) setPosition(ccp(x, y)); } -float Node::getPositionX(void) +float Node::getPositionX(void) const { return _position.x; } -float Node::getPositionY(void) +float Node::getPositionY(void) const { return _position.y; } @@ -367,7 +367,7 @@ void Node::setGrid(GridBase* pGrid) /// isVisible getter -bool Node::isVisible() +bool Node::isVisible() const { return _visible; } @@ -378,13 +378,13 @@ void Node::setVisible(bool var) _visible = var; } -const Point& Node::getAnchorPointInPoints() +const Point& Node::getAnchorPointInPoints() const { return _anchorPointInPoints; } /// anchorPoint getter -const Point& Node::getAnchorPoint() +const Point& Node::getAnchorPoint() const { return _anchorPoint; } @@ -417,7 +417,7 @@ void Node::setContentSize(const Size & size) } // isRunning getter -bool Node::isRunning() +bool Node::isRunning() const { return _running; } @@ -434,7 +434,7 @@ void Node::setParent(Node * var) } /// isRelativeAnchorPoint getter -bool Node::isIgnoreAnchorPointForPosition() +bool Node::isIgnoreAnchorPointForPosition() const { return _ignoreAnchorPointForPosition; } @@ -472,7 +472,7 @@ void Node::setUserData(void *var) _userData = var; } -unsigned int Node::getOrderOfArrival() +unsigned int Node::getOrderOfArrival() const { return _orderOfArrival; } @@ -492,7 +492,7 @@ Object* Node::getUserObject() return _userObject; } -ccGLServerState Node::getGLServerState() +ccGLServerState Node::getGLServerState() const { return _GLServerState; } @@ -552,7 +552,7 @@ void Node::cleanup() } -const char* Node::description() +const char* Node::description() const { return String::createWithFormat("", _tag)->getCString(); } @@ -1334,12 +1334,12 @@ bool NodeRGBA::init() return false; } -GLubyte NodeRGBA::getOpacity(void) +GLubyte NodeRGBA::getOpacity(void) const { return _realOpacity; } -GLubyte NodeRGBA::getDisplayedOpacity(void) +GLubyte NodeRGBA::getDisplayedOpacity(void) const { return _displayedOpacity; } @@ -1378,7 +1378,7 @@ void NodeRGBA::updateDisplayedOpacity(GLubyte parentOpacity) } } -bool NodeRGBA::isCascadeOpacityEnabled(void) +bool NodeRGBA::isCascadeOpacityEnabled(void) const { return _cascadeOpacityEnabled; } @@ -1388,12 +1388,12 @@ void NodeRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled) _cascadeOpacityEnabled = cascadeOpacityEnabled; } -const ccColor3B& NodeRGBA::getColor(void) +const ccColor3B& NodeRGBA::getColor(void) const { return _realColor; } -const ccColor3B& NodeRGBA::getDisplayedColor() +const ccColor3B& NodeRGBA::getDisplayedColor() const { return _displayedColor; } @@ -1435,7 +1435,7 @@ void NodeRGBA::updateDisplayedColor(const ccColor3B& parentColor) } } -bool NodeRGBA::isCascadeColorEnabled(void) +bool NodeRGBA::isCascadeColorEnabled(void) const { return _cascadeColorEnabled; } diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index c5aed1be45..523c03b4cb 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -156,7 +156,7 @@ public: * Gets the description string. It makes debugging easier. * @return A string terminated with '\0' */ - const char* description(void); + const char* description(void) const; /// @} end of initializers @@ -192,7 +192,7 @@ public: * * @return The Z order. */ - virtual int getZOrder(); + virtual int getZOrder() const; /** @@ -215,7 +215,7 @@ public: * * @return OpenGL Z vertex of this node */ - virtual float getVertexZ(); + virtual float getVertexZ() const; /** @@ -233,7 +233,7 @@ public: * * @return The scale factor on X axis. */ - virtual float getScaleX(); + virtual float getScaleX() const; /** @@ -251,7 +251,7 @@ public: * * @return The scale factor on Y axis. */ - virtual float getScaleY(); + virtual float getScaleY() const; /** @@ -270,7 +270,7 @@ public: * * @return The scale factor of the node. */ - virtual float getScale(); + virtual float getScale() const; /** @@ -294,7 +294,7 @@ public: * * @return The position (x,y) of the node in OpenGL coordinates */ - virtual const Point& getPosition(); + virtual const Point& getPosition() const; /** * Sets position in a more efficient way. * @@ -317,15 +317,15 @@ public: * * @see setPosition(float, float) */ - virtual void getPosition(float* x, float* y); + virtual void getPosition(float* x, float* y) const; /** * Gets/Sets x or y coordinate individually for position. * These methods are used in Lua and Javascript Bindings */ virtual void setPositionX(float x); - virtual float getPositionX(void); + virtual float getPositionX(void) const; virtual void setPositionY(float y); - virtual float getPositionY(void); + virtual float getPositionY(void) const; /** @@ -345,7 +345,7 @@ public: * * @return The X skew angle of the node in degrees. */ - virtual float getSkewX(); + virtual float getSkewX() const; /** @@ -365,7 +365,7 @@ public: * * @return The Y skew angle of the node in degrees. */ - virtual float getSkewY(); + virtual float getSkewY() const; /** @@ -387,7 +387,7 @@ public: * * @return The anchor point of node. */ - virtual const Point& getAnchorPoint(); + virtual const Point& getAnchorPoint() const; /** * Returns the anchorPoint in absolute pixels. * @@ -396,7 +396,7 @@ public: * * @return The anchor point in absolute pixels. */ - virtual const Point& getAnchorPointInPoints(); + virtual const Point& getAnchorPointInPoints() const; /** @@ -433,7 +433,7 @@ public: * * @return true if the node is visible, false if the node is hidden. */ - virtual bool isVisible(); + virtual bool isVisible() const; /** @@ -452,7 +452,7 @@ public: * * @return The rotation of the node in degrees. */ - virtual float getRotation(); + virtual float getRotation() const; /** @@ -471,7 +471,7 @@ public: * * @return The X rotation in degrees. */ - virtual float getRotationX(); + virtual float getRotationX() const; /** @@ -490,7 +490,7 @@ public: * * @return The Y rotation in degrees. */ - virtual float getRotationY(); + virtual float getRotationY() const; /** @@ -511,7 +511,7 @@ public: * * @return The arrival order. */ - virtual unsigned int getOrderOfArrival(); + virtual unsigned int getOrderOfArrival() const; /** @@ -525,7 +525,7 @@ public: * * @return The state of OpenGL server side. */ - virtual ccGLServerState getGLServerState(); + virtual ccGLServerState getGLServerState() const; /** @@ -545,7 +545,7 @@ public: * * @return true if the anchor point will be (0,0) when you position this node. */ - virtual bool isIgnoreAnchorPointForPosition(); + virtual bool isIgnoreAnchorPointForPosition() const; /// @} end of Setters & Getters for Graphic Peroperties @@ -855,7 +855,7 @@ public: * * @return Whether or not the node is running. */ - virtual bool isRunning(); + virtual bool isRunning() const; /// @{ @@ -896,7 +896,7 @@ public: * * @return A number that indicates a lua function. */ - inline int getScriptHandler() { return _scriptHandler; }; + inline int getScriptHandler() const { return _scriptHandler; }; /** * Schedules for lua script. @@ -1428,22 +1428,22 @@ public: virtual bool init(); - virtual GLubyte getOpacity(); - virtual GLubyte getDisplayedOpacity(); + virtual GLubyte getOpacity() const; + virtual GLubyte getDisplayedOpacity() const; virtual void setOpacity(GLubyte opacity); virtual void updateDisplayedOpacity(GLubyte parentOpacity); - virtual bool isCascadeOpacityEnabled(); + virtual bool isCascadeOpacityEnabled() const; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); - virtual const ccColor3B& getColor(void); - virtual const ccColor3B& getDisplayedColor(); + virtual const ccColor3B& getColor(void) const; + virtual const ccColor3B& getDisplayedColor() const; virtual void setColor(const ccColor3B& color); virtual void updateDisplayedColor(const ccColor3B& parentColor); - virtual bool isCascadeColorEnabled(); + virtual bool isCascadeColorEnabled() const; virtual void setCascadeColorEnabled(bool cascadeColorEnabled); virtual void setOpacityModifyRGB(bool bValue) {}; - virtual bool isOpacityModifyRGB() { return false; }; + virtual bool isOpacityModifyRGB() const { return false; }; protected: GLubyte _displayedOpacity; diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp index 14df80350f..07630577de 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ b/cocos2dx/draw_nodes/CCDrawNode.cpp @@ -430,7 +430,7 @@ void DrawNode::clear() _dirty = true; } -ccBlendFunc DrawNode::getBlendFunc() const +const ccBlendFunc& DrawNode::getBlendFunc() const { return _blendFunc; } diff --git a/cocos2dx/draw_nodes/CCDrawNode.h b/cocos2dx/draw_nodes/CCDrawNode.h index c144b68124..52c4d66f3a 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.h +++ b/cocos2dx/draw_nodes/CCDrawNode.h @@ -74,7 +74,7 @@ public: /** Clear the geometry in the node's buffer. */ void clear(); - ccBlendFunc getBlendFunc() const; + const ccBlendFunc& getBlendFunc() const; void setBlendFunc(const ccBlendFunc &blendFunc); DrawNode(); diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h index 4e0ac2c58d..737f7e3afb 100644 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -50,21 +50,21 @@ public: * * @return The ccColor3B contains R,G,B bytes. */ - virtual const ccColor3B& getColor(void) = 0; + virtual const ccColor3B& getColor(void) const = 0; /** * Returns the displayed color. * * @return The ccColor3B contains R,G,B bytes. */ - virtual const ccColor3B& getDisplayedColor(void) = 0; + virtual const ccColor3B& getDisplayedColor(void) const = 0; /** * Returns the displayed opacity. * * @return The opacity of sprite, from 0 ~ 255 */ - virtual GLubyte getDisplayedOpacity(void) = 0; + virtual GLubyte getDisplayedOpacity(void) const = 0; /** * Returns the opacity. * @@ -73,7 +73,7 @@ public: * * @return The opacity of sprite, from 0 ~ 255 */ - virtual GLubyte getOpacity(void) = 0; + virtual GLubyte getOpacity(void) const = 0; /** * Changes the opacity. @@ -100,12 +100,12 @@ public: * * @return Returns opacity modify flag. */ - virtual bool isOpacityModifyRGB(void) = 0; + virtual bool isOpacityModifyRGB(void) const = 0; /** * whether or not color should be propagated to its children. */ - virtual bool isCascadeColorEnabled(void) = 0; + virtual bool isCascadeColorEnabled(void) const = 0; virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0; /** @@ -116,7 +116,7 @@ public: /** * whether or not opacity should be propagated to its children. */ - virtual bool isCascadeOpacityEnabled(void) = 0; + virtual bool isCascadeOpacityEnabled(void) const = 0; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0; /** @@ -140,14 +140,14 @@ public: * e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}. * */ - virtual void setBlendFunc(ccBlendFunc blendFunc) = 0; + virtual void setBlendFunc(const ccBlendFunc &blendFunc) = 0; /** * Returns the blending function that is currently being used. * * @return A ccBlendFunc structure with source and destination factor which specified pixel arithmetic. */ - virtual ccBlendFunc getBlendFunc(void) = 0; + virtual const ccBlendFunc &getBlendFunc(void) const = 0; }; /** @@ -195,7 +195,7 @@ public: * * @return The string that is currently being used in this label */ - virtual const char* getString(void) = 0; + virtual const char* getString(void) const = 0; }; /** diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index e92951c50a..7b29d098c7 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -205,7 +205,7 @@ void LabelAtlas::setString(const char *label) _quadsToDraw = len; } -const char* LabelAtlas::getString(void) +const char* LabelAtlas::getString(void) const { return _string.c_str(); } diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index 5af5dfbb3a..5ecb528158 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -81,7 +81,7 @@ public: // super methods virtual void updateAtlasValues(); virtual void setString(const char *label); - virtual const char* getString(void); + virtual const char* getString(void) const; #if CC_LABELATLAS_DEBUG_DRAW virtual void draw(); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index e6180fcad2..593497320e 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -777,7 +777,7 @@ void LabelBMFont::setString(unsigned short *newString, bool needUpdateLabel) } } -const char* LabelBMFont::getString(void) +const char* LabelBMFont::getString(void) const { return _initialStringUTF8.c_str(); } @@ -788,12 +788,12 @@ void LabelBMFont::setCString(const char *label) } //LabelBMFont - RGBAProtocol protocol -const ccColor3B& LabelBMFont::getColor() +const ccColor3B& LabelBMFont::getColor() const { return _realColor; } -const ccColor3B& LabelBMFont::getDisplayedColor() +const ccColor3B& LabelBMFont::getDisplayedColor() const { return _displayedColor; } @@ -813,12 +813,12 @@ void LabelBMFont::setColor(const ccColor3B& color) } } -GLubyte LabelBMFont::getOpacity(void) +GLubyte LabelBMFont::getOpacity(void) const { return _realOpacity; } -GLubyte LabelBMFont::getDisplayedOpacity(void) +GLubyte LabelBMFont::getDisplayedOpacity(void) const { return _displayedOpacity; } @@ -859,7 +859,7 @@ void LabelBMFont::setOpacityModifyRGB(bool var) } } } -bool LabelBMFont::isOpacityModifyRGB() +bool LabelBMFont::isOpacityModifyRGB() const { return _isOpacityModifyRGB; } @@ -890,7 +890,7 @@ void LabelBMFont::updateDisplayedColor(const ccColor3B& parentColor) } } -bool LabelBMFont::isCascadeColorEnabled() +bool LabelBMFont::isCascadeColorEnabled() const { return false; } @@ -900,7 +900,7 @@ void LabelBMFont::setCascadeColorEnabled(bool cascadeColorEnabled) _cascadeColorEnabled = cascadeColorEnabled; } -bool LabelBMFont::isCascadeOpacityEnabled() +bool LabelBMFont::isCascadeOpacityEnabled() const { return false; } diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 22dd0f0e9b..3dec945f56 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -214,7 +214,7 @@ public: virtual void setString(const char *newString); virtual void setString(const char *newString, bool needUpdateLabel); - virtual const char* getString(void); + virtual const char* getString(void) const; virtual void setCString(const char *label); virtual void setAnchorPoint(const Point& var); virtual void updateLabel(); @@ -226,18 +226,19 @@ public: virtual void setScaleY(float scaleY); // RGBAProtocol - virtual bool isOpacityModifyRGB(); - virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); virtual GLubyte getOpacity(); - virtual GLubyte getDisplayedOpacity(); + virtual bool isOpacityModifyRGB() const; + virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); + virtual GLubyte getOpacity() const; + virtual GLubyte getDisplayedOpacity() const; virtual void setOpacity(GLubyte opacity); virtual void updateDisplayedOpacity(GLubyte parentOpacity); - virtual bool isCascadeOpacityEnabled(); + virtual bool isCascadeOpacityEnabled() const; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); - virtual const ccColor3B& getColor(void); - virtual const ccColor3B& getDisplayedColor(); + virtual const ccColor3B& getColor(void) const; + virtual const ccColor3B& getDisplayedColor() const; virtual void setColor(const ccColor3B& color); virtual void updateDisplayedColor(const ccColor3B& parentColor); - virtual bool isCascadeColorEnabled(); + virtual bool isCascadeColorEnabled() const; virtual void setCascadeColorEnabled(bool cascadeColorEnabled); void setFntFile(const char* fntFile); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 1028cfa044..25746cb793 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -183,7 +183,7 @@ void LabelTTF::setString(const char *string) } } -const char* LabelTTF::getString(void) +const char* LabelTTF::getString(void) const { return _string.c_str(); } @@ -193,7 +193,7 @@ const char* LabelTTF::description() return String::createWithFormat("", _fontName->c_str(), _fontSize)->getCString(); } -TextAlignment LabelTTF::getHorizontalAlignment() +TextAlignment LabelTTF::getHorizontalAlignment() const { return _alignment; } @@ -212,7 +212,7 @@ void LabelTTF::setHorizontalAlignment(TextAlignment alignment) } } -VerticalTextAlignment LabelTTF::getVerticalAlignment() +VerticalTextAlignment LabelTTF::getVerticalAlignment() const { return _vAlignment; } @@ -231,7 +231,7 @@ void LabelTTF::setVerticalAlignment(VerticalTextAlignment verticalAlignment) } } -Size LabelTTF::getDimensions() +const Size& LabelTTF::getDimensions() const { return _dimensions; } @@ -250,7 +250,7 @@ void LabelTTF::setDimensions(const Size &dim) } } -float LabelTTF::getFontSize() +float LabelTTF::getFontSize() const { return _fontSize; } @@ -269,7 +269,7 @@ void LabelTTF::setFontSize(float fontSize) } } -const char* LabelTTF::getFontName() +const char* LabelTTF::getFontName() const { return _fontName->c_str(); } diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 51110199f8..d28ec826bf 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -134,21 +134,21 @@ public: * @warning Changing the string is as expensive as creating a new LabelTTF. To obtain better performance use LabelAtlas */ virtual void setString(const char *label); - virtual const char* getString(void); + virtual const char* getString(void) const; - TextAlignment getHorizontalAlignment(); + TextAlignment getHorizontalAlignment() const; void setHorizontalAlignment(TextAlignment alignment); - VerticalTextAlignment getVerticalAlignment(); + VerticalTextAlignment getVerticalAlignment() const; void setVerticalAlignment(VerticalTextAlignment verticalAlignment); - Size getDimensions(); + const Size& getDimensions() const; void setDimensions(const Size &dim); - float getFontSize(); + float getFontSize() const; void setFontSize(float fontSize); - const char* getFontName(); + const char* getFontName() const; void setFontName(const char *fontName); private: diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 72d717af0e..1343a0ae3b 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -151,7 +151,7 @@ int Layer::excuteScriptTouchHandler(int nEventType, Set *pTouches) } /// isTouchEnabled getter -bool Layer::isTouchEnabled() +bool Layer::isTouchEnabled() const { return _touchEnabled; } @@ -204,18 +204,18 @@ void Layer::setTouchPriority(int priority) } } -int Layer::getTouchPriority() +int Layer::getTouchPriority() const { return _touchPriority; } -int Layer::getTouchMode() +int Layer::getTouchMode() const { return _touchMode; } /// isAccelerometerEnabled getter -bool Layer::isAccelerometerEnabled() +bool Layer::isAccelerometerEnabled() const { return _accelerometerEnabled; } @@ -276,7 +276,7 @@ void Layer::unregisterScriptAccelerateHandler(void) } /// isKeyboardEnabled getter -bool Layer::isKeyboardEnabled() +bool Layer::isKeyboardEnabled() const { return _keyboardEnabled; } @@ -302,7 +302,7 @@ void Layer::setKeyboardEnabled(bool enabled) } /// isKeypadEnabled getter -bool Layer::isKeypadEnabled() +bool Layer::isKeypadEnabled() const { return _keypadEnabled; } @@ -545,12 +545,12 @@ bool LayerRGBA::init() } } -GLubyte LayerRGBA::getOpacity() +GLubyte LayerRGBA::getOpacity() const { return _realOpacity; } -GLubyte LayerRGBA::getDisplayedOpacity() +GLubyte LayerRGBA::getDisplayedOpacity() const { return _displayedOpacity; } @@ -572,12 +572,12 @@ void LayerRGBA::setOpacity(GLubyte opacity) } } -const ccColor3B& LayerRGBA::getColor() +const ccColor3B& LayerRGBA::getColor() const { return _realColor; } -const ccColor3B& LayerRGBA::getDisplayedColor() +const ccColor3B& LayerRGBA::getDisplayedColor() const { return _displayedColor; } @@ -637,7 +637,7 @@ void LayerRGBA::updateDisplayedColor(const ccColor3B& parentColor) } } -bool LayerRGBA::isCascadeOpacityEnabled() +bool LayerRGBA::isCascadeOpacityEnabled() const { return _cascadeOpacityEnabled; } @@ -647,7 +647,7 @@ void LayerRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled) _cascadeOpacityEnabled = cascadeOpacityEnabled; } -bool LayerRGBA::isCascadeColorEnabled() +bool LayerRGBA::isCascadeColorEnabled() const { return _cascadeColorEnabled; } @@ -671,12 +671,12 @@ LayerColor::~LayerColor() } /// blendFunc getter -ccBlendFunc LayerColor::getBlendFunc() +const ccBlendFunc &LayerColor::getBlendFunc() const { return _blendFunc; } /// blendFunc setter -void LayerColor::setBlendFunc(ccBlendFunc var) +void LayerColor::setBlendFunc(const ccBlendFunc &var) { _blendFunc = var; } @@ -959,7 +959,7 @@ void LayerGradient::updateColor() _squareColors[3].a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)); } -const ccColor3B& LayerGradient::getStartColor() +const ccColor3B& LayerGradient::getStartColor() const { return _realColor; } @@ -975,7 +975,7 @@ void LayerGradient::setEndColor(const ccColor3B& color) updateColor(); } -const ccColor3B& LayerGradient::getEndColor() +const ccColor3B& LayerGradient::getEndColor() const { return _endColor; } @@ -1008,7 +1008,7 @@ void LayerGradient::setVector(const Point& var) updateColor(); } -const Point& LayerGradient::getVector() +const Point& LayerGradient::getVector() const { return _alongVector; } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 9b5a17a375..bf3ddf6992 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -112,21 +112,21 @@ public: Only the touches of this node will be affected. This "method" is not propagated to it's children. @since v0.8.1 */ - virtual bool isTouchEnabled(); + virtual bool isTouchEnabled() const; virtual void setTouchEnabled(bool value); virtual void setTouchMode(ccTouchesMode mode); - virtual int getTouchMode(); + virtual int getTouchMode() const; /** priority of the touch events. Default is 0 */ virtual void setTouchPriority(int priority); - virtual int getTouchPriority(); + virtual int getTouchPriority() const; /** whether or not it will receive Accelerometer events You can enable / disable accelerometer events with this property. @since v0.8.1 */ - virtual bool isAccelerometerEnabled(); + virtual bool isAccelerometerEnabled() const; virtual void setAccelerometerEnabled(bool value); virtual void setAccelerometerInterval(double interval); @@ -135,12 +135,12 @@ public: it's new in cocos2d-x */ - virtual bool isKeyboardEnabled(); + virtual bool isKeyboardEnabled() const; virtual void setKeyboardEnabled(bool value); virtual void keyPressed(int keyCode) {}; virtual void keyReleased(int keyCode) {}; - virtual bool isKeypadEnabled(); + virtual bool isKeypadEnabled() const; virtual void setKeypadEnabled(bool value); /** Register keypad events handler */ @@ -151,9 +151,9 @@ public: virtual void keyBackClicked(void); virtual void keyMenuClicked(void); - inline TouchScriptHandlerEntry* getScriptTouchHandlerEntry() { return _scriptTouchHandlerEntry; }; - inline ScriptHandlerEntry* getScriptKeypadHandlerEntry() { return _scriptKeypadHandlerEntry; }; - inline ScriptHandlerEntry* getScriptAccelerateHandlerEntry() { return _scriptAccelerateHandlerEntry; }; + inline TouchScriptHandlerEntry* getScriptTouchHandlerEntry() const { return _scriptTouchHandlerEntry; }; + inline ScriptHandlerEntry* getScriptKeypadHandlerEntry() const { return _scriptKeypadHandlerEntry; }; + inline ScriptHandlerEntry* getScriptAccelerateHandlerEntry() const { return _scriptAccelerateHandlerEntry; }; protected: bool _touchEnabled; bool _accelerometerEnabled; @@ -195,22 +195,22 @@ public: virtual bool init(); - virtual GLubyte getOpacity(); - virtual GLubyte getDisplayedOpacity(); + virtual GLubyte getOpacity() const; + virtual GLubyte getDisplayedOpacity() const; virtual void setOpacity(GLubyte opacity); virtual void updateDisplayedOpacity(GLubyte parentOpacity); - virtual bool isCascadeOpacityEnabled(); + virtual bool isCascadeOpacityEnabled() const; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); - virtual const ccColor3B& getColor(); - virtual const ccColor3B& getDisplayedColor(); + virtual const ccColor3B& getColor() const; + virtual const ccColor3B& getDisplayedColor() const; virtual void setColor(const ccColor3B& color); virtual void updateDisplayedColor(const ccColor3B& parentColor); - virtual bool isCascadeColorEnabled(); + virtual bool isCascadeColorEnabled() const; virtual void setCascadeColorEnabled(bool cascadeColorEnabled); virtual void setOpacityModifyRGB(bool bValue) {} - virtual bool isOpacityModifyRGB() { return false; } + virtual bool isOpacityModifyRGB() const { return false; } protected: GLubyte _displayedOpacity, _realOpacity; ccColor3B _displayedColor, _realColor; @@ -266,10 +266,10 @@ public: void changeWidthAndHeight(GLfloat w ,GLfloat h); /** BlendFunction. Conforms to BlendProtocol protocol */ - CC_PROPERTY(ccBlendFunc, _blendFunc, BlendFunc) + CC_PROPERTY_PASS_BY_REF(ccBlendFunc, _blendFunc, BlendFunc) virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool isOpacityModifyRGB(void) { return false;} + virtual bool isOpacityModifyRGB(void) const { return false;} virtual void setColor(const ccColor3B &color); virtual void setOpacity(GLubyte opacity); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 2b0086452b..520afc2d1c 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -179,7 +179,7 @@ void MenuItem::setCallback(const ccMenuCallback& callback) //CCMenuItemLabel // -const ccColor3B& MenuItemLabel::getDisabledColor() +const ccColor3B& MenuItemLabel::getDisabledColor() const { return _disabledColor; } diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 0ee045c9c1..ed12218db7 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -169,12 +169,12 @@ void MotionStreak::setTexture(Texture2D *texture) } } -void MotionStreak::setBlendFunc(ccBlendFunc blendFunc) +void MotionStreak::setBlendFunc(const ccBlendFunc &blendFunc) { _blendFunc = blendFunc; } -ccBlendFunc MotionStreak::getBlendFunc(void) +const ccBlendFunc& MotionStreak::getBlendFunc(void) const { return _blendFunc; } diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 47d5591fd3..2edc81f210 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -76,8 +76,8 @@ public: /* Implement interfaces */ virtual Texture2D* getTexture(void); virtual void setTexture(Texture2D *texture); - virtual void setBlendFunc(ccBlendFunc blendFunc); - virtual ccBlendFunc getBlendFunc(void); + virtual void setBlendFunc(const ccBlendFunc &blendFunc); + virtual const ccBlendFunc& getBlendFunc(void) const; virtual GLubyte getOpacity(void); virtual void setOpacity(GLubyte opacity); virtual void setOpacityModifyRGB(bool bValue); diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 6cd741e4fb..3b00d43ec2 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -509,12 +509,12 @@ Texture2D* ParticleBatchNode::getTexture(void) return _textureAtlas->getTexture(); } -void ParticleBatchNode::setBlendFunc(ccBlendFunc blendFunc) +void ParticleBatchNode::setBlendFunc(const ccBlendFunc &blendFunc) { _blendFunc = blendFunc; } // returns the blending function used for the texture -ccBlendFunc ParticleBatchNode::getBlendFunc(void) +const ccBlendFunc& ParticleBatchNode::getBlendFunc(void) const { return _blendFunc; } diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index 830da42224..db1f28b205 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -102,9 +102,9 @@ public: virtual Texture2D* getTexture(void); // sets a new texture. it will be retained virtual void setTexture(Texture2D *texture); - virtual void setBlendFunc(ccBlendFunc blendFunc); + virtual void setBlendFunc(const ccBlendFunc &blendFunc); // returns the blending function used for the texture - virtual ccBlendFunc getBlendFunc(void); + virtual const ccBlendFunc& getBlendFunc(void) const; void visit(); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index ae41871de4..bbd3071739 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -1046,7 +1046,7 @@ void ParticleSystem::setDuration(float var) _duration = var; } -const Point& ParticleSystem::getSourcePosition() +const Point& ParticleSystem::getSourcePosition() const { return _sourcePosition; } @@ -1056,7 +1056,7 @@ void ParticleSystem::setSourcePosition(const Point& var) _sourcePosition = var; } -const Point& ParticleSystem::getPosVar() +const Point& ParticleSystem::getPosVar() const { return _posVar; } @@ -1146,7 +1146,7 @@ void ParticleSystem::setEndSizeVar(float var) _endSizeVar = var; } -const ccColor4F& ParticleSystem::getStartColor() +const ccColor4F& ParticleSystem::getStartColor() const { return _startColor; } @@ -1156,7 +1156,7 @@ void ParticleSystem::setStartColor(const ccColor4F& var) _startColor = var; } -const ccColor4F& ParticleSystem::getStartColorVar() +const ccColor4F& ParticleSystem::getStartColorVar() const { return _startColorVar; } @@ -1166,7 +1166,7 @@ void ParticleSystem::setStartColorVar(const ccColor4F& var) _startColorVar = var; } -const ccColor4F& ParticleSystem::getEndColor() +const ccColor4F& ParticleSystem::getEndColor() const { return _endColor; } @@ -1176,7 +1176,7 @@ void ParticleSystem::setEndColor(const ccColor4F& var) _endColor = var; } -const ccColor4F& ParticleSystem::getEndColorVar() +const ccColor4F& ParticleSystem::getEndColorVar() const { return _endColorVar; } @@ -1246,12 +1246,12 @@ void ParticleSystem::setTotalParticles(unsigned int var) _totalParticles = var; } -ccBlendFunc ParticleSystem::getBlendFunc() +const ccBlendFunc& ParticleSystem::getBlendFunc() const { return _blendFunc; } -void ParticleSystem::setBlendFunc(ccBlendFunc blendFunc) +void ParticleSystem::setBlendFunc(const ccBlendFunc &blendFunc) { if( _blendFunc.src != blendFunc.src || _blendFunc.dst != blendFunc.dst ) { _blendFunc = blendFunc; diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index b552822ad4..9de5c1ccd7 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -327,7 +327,7 @@ public: /** conforms to CocosNodeTexture protocol */ CC_PROPERTY(Texture2D*, _texture, Texture) /** conforms to CocosNodeTexture protocol */ - CC_PROPERTY(ccBlendFunc, _blendFunc, BlendFunc) + CC_PROPERTY_PASS_BY_REF(ccBlendFunc, _blendFunc, BlendFunc) /** does the alpha value modify color */ CC_PROPERTY(bool, _opacityModifyRGB, OpacityModifyRGB) diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index 0504c7dd75..59ac1ba07b 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -143,7 +143,7 @@ public: virtual void set##funName(varType var); #define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)\ protected: varType varName;\ -public: virtual const varType& get##funName(void);\ +public: virtual const varType& get##funName(void) const;\ public: virtual void set##funName(const varType& var); /** CC_SYNTHESIZE_READONLY is used to declare a protected variable. diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index fcdde05bb6..858ef6fd74 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -877,7 +877,7 @@ void Sprite::setFlipX(bool bFlipX) } } -bool Sprite::isFlipX(void) +bool Sprite::isFlipX(void) const { return _flipX; } @@ -891,7 +891,7 @@ void Sprite::setFlipY(bool bFlipY) } } -bool Sprite::isFlipY(void) +bool Sprite::isFlipY(void) const { return _flipY; } @@ -959,7 +959,7 @@ void Sprite::setOpacityModifyRGB(bool modify) } } -bool Sprite::isOpacityModifyRGB(void) +bool Sprite::isOpacityModifyRGB(void) const { return _opacityModifyRGB; } @@ -1011,7 +1011,7 @@ void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int fra setDisplayFrame(frame->getSpriteFrame()); } -bool Sprite::isFrameDisplayed(SpriteFrame *pFrame) +bool Sprite::isFrameDisplayed(SpriteFrame *pFrame) const { Rect r = pFrame->getRect(); diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 0ff15fb80b..ba4d98d180 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -263,8 +263,8 @@ public: /// @name Functions inherited from TextureProtocol virtual void setTexture(Texture2D *texture); virtual Texture2D* getTexture(void); - inline void setBlendFunc(ccBlendFunc blendFunc) { _blendFunc = blendFunc; } - inline ccBlendFunc getBlendFunc(void) { return _blendFunc; } + inline void setBlendFunc(const ccBlendFunc &blendFunc) { _blendFunc = blendFunc; } + inline const ccBlendFunc& getBlendFunc(void) const { return _blendFunc; } /// @} /// @{ @@ -298,7 +298,7 @@ public: virtual void updateDisplayedColor(const ccColor3B& parentColor); virtual void setOpacity(GLubyte opacity); virtual void setOpacityModifyRGB(bool modify); - virtual bool isOpacityModifyRGB(void); + virtual bool isOpacityModifyRGB(void) const; virtual void updateDisplayedOpacity(GLubyte parentOpacity); /// @} @@ -372,7 +372,7 @@ public: /** * Returns whether or not a SpriteFrame is being displayed */ - virtual bool isFrameDisplayed(SpriteFrame *pFrame); + virtual bool isFrameDisplayed(SpriteFrame *pFrame) const; /** * Returns the current displayed frame. @@ -400,7 +400,7 @@ public: * * @return true if the sprite needs to be updated in the Atlas, false otherwise. */ - inline virtual bool isDirty(void) { return _dirty; } + inline virtual bool isDirty(void) const { return _dirty; } /** * Makes the Sprite to be updated in the Atlas. @@ -415,12 +415,12 @@ public: /** * Returns whether or not the texture rectangle is rotated. */ - inline bool isTextureRectRotated(void) { return _rectRotated; } + inline bool isTextureRectRotated(void) const { return _rectRotated; } /** * Returns the index used on the TextureAtlas. */ - inline unsigned int getAtlasIndex(void) { return _atlasIndex; } + inline unsigned int getAtlasIndex(void) const { return _atlasIndex; } /** * Sets the index used on the TextureAtlas. @@ -446,7 +446,7 @@ public: /** * Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex. */ - inline const Point& getOffsetPosition(void) { return _offsetPosition; } + inline const Point& getOffsetPosition(void) const { return _offsetPosition; } /** @@ -459,7 +459,7 @@ public: * * @return true if the sprite is flipped horizaontally, false otherwise. */ - bool isFlipX(void); + bool isFlipX(void) const; /** * Sets whether the sprite should be flipped horizontally or not. * @@ -477,7 +477,7 @@ public: * * @return true if the sprite is flipped vertically, flase otherwise. */ - bool isFlipY(void); + bool isFlipY(void) const; /** * Sets whether the sprite should be flipped vertically or not. * diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 379b974394..cee4eac731 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -673,12 +673,12 @@ void SpriteBatchNode::updateBlendFunc(void) } // CocosNodeTexture protocol -void SpriteBatchNode::setBlendFunc(ccBlendFunc blendFunc) +void SpriteBatchNode::setBlendFunc(const ccBlendFunc &blendFunc) { _blendFunc = blendFunc; } -ccBlendFunc SpriteBatchNode::getBlendFunc(void) +const ccBlendFunc& SpriteBatchNode::getBlendFunc(void) const { return _blendFunc; } diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index b0544850d5..a1219f46f8 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -131,8 +131,8 @@ public: // TextureProtocol virtual Texture2D* getTexture(void); virtual void setTexture(Texture2D *texture); - virtual void setBlendFunc(ccBlendFunc blendFunc); - virtual ccBlendFunc getBlendFunc(void); + virtual void setBlendFunc(const ccBlendFunc &blendFunc); + virtual const ccBlendFunc& getBlendFunc(void) const; virtual void visit(void); virtual void addChild(Node * child); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 33a514b0c8..1ded4301e2 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -64,7 +64,7 @@ public: inline void setRotated(bool bRotated) { _rotated = bRotated; } /** get rect of the frame */ - inline const Rect& getRect(void) { return _rect; } + inline const Rect& getRect(void) const { return _rect; } /** set rect of the frame */ void setRect(const Rect& rect); diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.cpp b/cocos2dx/text_input_node/CCTextFieldTTF.cpp index 71d87f0479..8666f7d77d 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.cpp +++ b/cocos2dx/text_input_node/CCTextFieldTTF.cpp @@ -326,7 +326,7 @@ void TextFieldTTF::setString(const char *text) _charCount = _calcCharCount(_inputText->c_str()); } -const char* TextFieldTTF::getString(void) +const char* TextFieldTTF::getString(void) const { return _inputText->c_str(); } diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.h b/cocos2dx/text_input_node/CCTextFieldTTF.h index e55b14fa45..15eb9e0bdf 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.h +++ b/cocos2dx/text_input_node/CCTextFieldTTF.h @@ -133,7 +133,7 @@ public: // input text property public: virtual void setString(const char *text); - virtual const char* getString(void); + virtual const char* getString(void) const; protected: std::string * _inputText; diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index c5494df2ca..4857896b73 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -169,7 +169,7 @@ void* Texture2D::keepData(void *data, unsigned int length) return data; } -bool Texture2D::hasPremultipliedAlpha() +bool Texture2D::hasPremultipliedAlpha() const { return _hasPremultipliedAlpha; } @@ -264,7 +264,7 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat, } -const char* Texture2D::description(void) +const char* Texture2D::description(void) const { return String::createWithFormat("", _name, _pixelsWide, _pixelsHigh, _maxS, _maxT)->getCString(); } @@ -771,22 +771,22 @@ void Texture2D::generateMipmap() _hasMipmaps = true; } -bool Texture2D::hasMipmaps() +bool Texture2D::hasMipmaps() const { return _hasMipmaps; } -void Texture2D::setTexParameters(ccTexParams *texParams) +void Texture2D::setTexParameters(const ccTexParams &texParams) { - CCAssert( (_pixelsWide == ccNextPOT(_pixelsWide) || texParams->wrapS == GL_CLAMP_TO_EDGE) && - (_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams->wrapT == GL_CLAMP_TO_EDGE), + CCAssert( (_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) && + (_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE), "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); ccGLBindTexture2D( _name ); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams->minFilter ); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams->magFilter ); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texParams->wrapS ); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texParams->wrapT ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams.minFilter ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams.magFilter ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texParams.wrapS ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texParams.wrapT ); #if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::setTexParameters(this, texParams); @@ -809,7 +809,7 @@ void Texture2D::setAliasTexParameters() glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); #if CC_ENABLE_CACHE_TEXTURE_DATA ccTexParams texParams = {(GLuint)(_hasMipmaps?GL_NEAREST_MIPMAP_NEAREST:GL_NEAREST),GL_NEAREST,GL_NONE,GL_NONE}; - VolatileTexture::setTexParameters(this, &texParams); + VolatileTexture::setTexParameters(this, texParams); #endif } @@ -829,11 +829,11 @@ void Texture2D::setAntiAliasTexParameters() glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); #if CC_ENABLE_CACHE_TEXTURE_DATA ccTexParams texParams = {(GLuint)(_hasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR),GL_LINEAR,GL_NONE,GL_NONE}; - VolatileTexture::setTexParameters(this, &texParams); + VolatileTexture::setTexParameters(this, texParams); #endif } -const char* Texture2D::stringForFormat() +const char* Texture2D::stringForFormat() const { switch (_pixelFormat) { @@ -891,7 +891,7 @@ Texture2DPixelFormat Texture2D::defaultAlphaPixelFormat() return g_defaultAlphaPixelFormat; } -unsigned int Texture2D::bitsPerPixelForFormat(Texture2DPixelFormat format) +unsigned int Texture2D::bitsPerPixelForFormat(Texture2DPixelFormat format) const { unsigned int ret=0; @@ -936,7 +936,7 @@ unsigned int Texture2D::bitsPerPixelForFormat(Texture2DPixelFormat format) return ret; } -unsigned int Texture2D::bitsPerPixelForFormat() +unsigned int Texture2D::bitsPerPixelForFormat() const { return this->bitsPerPixelForFormat(_pixelFormat); } diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index dfba014624..3c246d9ee4 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -105,7 +105,7 @@ public: Texture2D(); virtual ~Texture2D(); - const char* description(void); + const char* description(void) const; /** These functions are needed to create mutable textures */ void releaseData(void *data); @@ -151,7 +151,7 @@ public: @since v0.8 */ - void setTexParameters(ccTexParams* texParams); + void setTexParameters(const ccTexParams& texParams); /** sets antialias texture parameters: - GL_TEXTURE_MIN_FILTER = GL_LINEAR @@ -183,17 +183,17 @@ public: /** returns the pixel format. @since v2.0 */ - const char* stringForFormat(); + const char* stringForFormat() const; /** returns the bits-per-pixel of the in-memory OpenGL texture @since v1.0 */ - unsigned int bitsPerPixelForFormat(); + unsigned int bitsPerPixelForFormat() const; /** Helper functions that returns bits per pixels for a given format. @since v2.0 */ - unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format); + unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format) const; /** sets the default pixel format for UIImagescontains alpha channel. If the UIImage contains alpha channel, then the options are: @@ -231,9 +231,9 @@ public: /** content size */ const Size& getContentSizeInPixels(); - - bool hasPremultipliedAlpha(); - bool hasMipmaps(); + + bool hasPremultipliedAlpha() const; + bool hasMipmaps() const; private: bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh); diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 8176f7d3c3..0315b09dc5 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -746,18 +746,18 @@ void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Si vt->_text = text; } -void VolatileTexture::setTexParameters(Texture2D *t, ccTexParams *texParams) +void VolatileTexture::setTexParameters(Texture2D *t, const ccTexParams &texParams) { VolatileTexture *vt = findVolotileTexture(t); - if (texParams->minFilter != GL_NONE) - vt->_texParams.minFilter = texParams->minFilter; - if (texParams->magFilter != GL_NONE) - vt->_texParams.magFilter = texParams->magFilter; - if (texParams->wrapS != GL_NONE) - vt->_texParams.wrapS = texParams->wrapS; - if (texParams->wrapT != GL_NONE) - vt->_texParams.wrapT = texParams->wrapT; + if (texParams.minFilter != GL_NONE) + vt->_texParams.minFilter = texParams.minFilter; + if (texParams.magFilter != GL_NONE) + vt->_texParams.magFilter = texParams.magFilter; + if (texParams.wrapS != GL_NONE) + vt->_texParams.wrapS = texParams.wrapS; + if (texParams.wrapT != GL_NONE) + vt->_texParams.wrapT = texParams.wrapT; } void VolatileTexture::removeTexture(Texture2D *t) @@ -851,7 +851,7 @@ void VolatileTexture::reloadAllTextures() default: break; } - vt->texture->setTexParameters(&vt->_texParams); + vt->texture->setTexParameters(vt->_texParams); } isReloading = false; diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 307ca8c442..1838d79057 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -218,7 +218,7 @@ public: static void addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize); static void addImage(Texture2D *tt, Image *image); - static void setTexParameters(Texture2D *t, ccTexParams *texParams); + static void setTexParameters(Texture2D *t, const ccTexParams &texParams); static void removeTexture(Texture2D *t); static void reloadAllTextures(); diff --git a/extensions/CCArmature/CCArmature.h b/extensions/CCArmature/CCArmature.h index daa305c100..71ebcc7006 100644 --- a/extensions/CCArmature/CCArmature.h +++ b/extensions/CCArmature/CCArmature.h @@ -120,8 +120,8 @@ public: */ virtual void updateOffsetPoint(); - inline void setBlendFunc(ccBlendFunc blendFunc) { _blendFunc = blendFunc; } - inline ccBlendFunc getBlendFunc(void) { return _blendFunc; } + inline void setBlendFunc(const ccBlendFunc& blendFunc) { _blendFunc = blendFunc; } + inline const ccBlendFunc& getBlendFunc(void) const { return _blendFunc; } protected: diff --git a/extensions/CCArmature/display/CCSkin.cpp b/extensions/CCArmature/display/CCSkin.cpp index 6900a36109..725841e2a0 100644 --- a/extensions/CCArmature/display/CCSkin.cpp +++ b/extensions/CCArmature/display/CCSkin.cpp @@ -74,7 +74,7 @@ void Skin::setSkinData(const BaseData &var) _skinTransform = nodeToParentTransform(); } -const BaseData &Skin::getSkinData() +const BaseData &Skin::getSkinData() const { return _skinData; } diff --git a/extensions/spine/CCSkeleton.cpp b/extensions/spine/CCSkeleton.cpp index 1a632d77fa..124209c246 100644 --- a/extensions/spine/CCSkeleton.cpp +++ b/extensions/spine/CCSkeleton.cpp @@ -271,11 +271,12 @@ bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName // --- BlendProtocol -ccBlendFunc CCSkeleton::getBlendFunc () { +const ccBlendFunc& CCSkeleton::getBlendFunc() const +{ return blendFunc; } -void CCSkeleton::setBlendFunc (ccBlendFunc blendFunc) { +void CCSkeleton::setBlendFunc( const ccBlendFunc &blendFunc) { this->blendFunc = blendFunc; } diff --git a/extensions/spine/CCSkeleton.h b/extensions/spine/CCSkeleton.h index af6fc24bc7..4715e87f3a 100644 --- a/extensions/spine/CCSkeleton.h +++ b/extensions/spine/CCSkeleton.h @@ -80,7 +80,7 @@ public: bool setAttachment (const char* slotName, const char* attachmentName); // --- BlendProtocol - CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc); + CC_PROPERTY_PASS_BY_REF(cocos2d::ccBlendFunc, blendFunc, BlendFunc); virtual void setOpacityModifyRGB (bool value); virtual bool isOpacityModifyRGB (); diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 9520260432..08469804d0 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -261,7 +261,7 @@ void TextureMipMap::onEnter() Texture2D *texture0 = TextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas.png"); texture0->generateMipmap(); ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - texture0->setTexParameters(&texParams); + texture0->setTexParameters(texParams); Texture2D *texture1 = TextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png"); @@ -317,7 +317,7 @@ void TexturePVRMipMap::onEnter() // support mipmap filtering ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - imgMipMap->getTexture()->setTexParameters(&texParams); + imgMipMap->getTexture()->setTexParameters(texParams); } Sprite *img = Sprite::create("Images/logo-nomipmap.pvr"); @@ -363,7 +363,7 @@ void TexturePVRMipMap2::onEnter() // support mipmap filtering ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - imgMipMap->getTexture()->setTexParameters(&texParams); + imgMipMap->getTexture()->setTexParameters(texParams); Sprite *img = Sprite::create("Images/test_image.png"); img->setPosition(ccp( s.width/2.0f+100, s.height/2.0f)); @@ -1545,7 +1545,7 @@ void TextureGlClamp::onEnter() addChild(sprite, -1, kTagSprite1); sprite->setPosition(ccp(size.width/2,size.height/2)); ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE}; - sprite->getTexture()->setTexParameters(¶ms); + sprite->getTexture()->setTexParameters(params); auto rotate = RotateBy::create(4, 360); sprite->runAction(rotate); @@ -1582,7 +1582,7 @@ void TextureGlRepeat::onEnter() addChild(sprite, -1, kTagSprite1); sprite->setPosition(ccp(size.width/2,size.height/2)); ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT}; - sprite->getTexture()->setTexParameters(¶ms); + sprite->getTexture()->setTexParameters(params); auto rotate = RotateBy::create(4, 360); sprite->runAction(rotate);