diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 58e8231b3b..f8125835bc 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -152,7 +152,7 @@ void AtlasNode::draw(void) // AtlasNode - RGBA protocol -const ccColor3B& AtlasNode::getColor() +const ccColor3B& AtlasNode::getColor() const { if(_isOpacityModifyRGB) { @@ -191,7 +191,7 @@ void AtlasNode::setOpacityModifyRGB(bool bValue) this->setColor(oldColor); } -bool AtlasNode::isOpacityModifyRGB() +bool AtlasNode::isOpacityModifyRGB() const { return _isOpacityModifyRGB; } diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index fdb6ba46ef..2dd6b22b69 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -107,9 +107,9 @@ public: /** sets a new texture. it will be retained*/ virtual void setTexture(Texture2D *texture); - virtual bool isOpacityModifyRGB(); + virtual bool isOpacityModifyRGB() const; virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); - virtual const ccColor3B& getColor(void); + virtual const ccColor3B& getColor(void) const; virtual void setColor(const ccColor3B& color); virtual void setOpacity(GLubyte opacity); diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index e6dacb2aa2..d528dd3f8e 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -135,7 +135,7 @@ public: virtual void onExit(); virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool isOpacityModifyRGB(void) { return false;} + virtual bool isOpacityModifyRGB(void) const { return false;} virtual bool isEnabled() { return _enabled; } virtual void setEnabled(bool value) { _enabled = value; }; diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index 60f9339e0a..8dbe478445 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -154,7 +154,7 @@ void ProgressTimer::setOpacityModifyRGB(bool bValue) CC_UNUSED_PARAM(bValue); } -bool ProgressTimer::isOpacityModifyRGB(void) +bool ProgressTimer::isOpacityModifyRGB(void) const { return false; } @@ -225,7 +225,7 @@ void ProgressTimer::updateProgress(void) } } -void ProgressTimer::setAnchorPoint(Point anchorPoint) +void ProgressTimer::setAnchorPoint(const Point& anchorPoint) { Node::setAnchorPoint(anchorPoint); } diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index babc5a2342..0b6eb582d9 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -80,10 +80,10 @@ public: void setReverseProgress(bool reverse); virtual void draw(void); - void setAnchorPoint(Point anchorPoint); + void setAnchorPoint(const Point& anchorPoint); virtual void setOpacityModifyRGB(bool bValue); - virtual bool isOpacityModifyRGB(void); + virtual bool isOpacityModifyRGB(void) const; inline bool isReverseDirection() { return _reverseDirection; }; inline void setReverseDirection(bool value) { _reverseDirection = value; }; diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 432dd66052..4a541c0268 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -248,7 +248,7 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB) } } -bool Control::isOpacityModifyRGB() +bool Control::isOpacityModifyRGB() const { return _isOpacityModifyRGB; } diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index 4b4e6f7084..7b4326fa8a 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -114,7 +114,7 @@ public: */ virtual void needsLayout(); - virtual bool isOpacityModifyRGB(); + virtual bool isOpacityModifyRGB() const; virtual void setOpacityModifyRGB(bool bOpacityModifyRGB); protected: diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index b0a82282e0..9558f90ee3 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -724,7 +724,7 @@ void ControlButton::setOpacity(GLubyte opacity) } } -GLubyte ControlButton::getOpacity() +GLubyte ControlButton::getOpacity() const { return _realOpacity; } @@ -741,7 +741,7 @@ void ControlButton::setColor(const ccColor3B & color) } } -const ccColor3B& ControlButton::getColor() +const ccColor3B& ControlButton::getColor() const { return _realColor; } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 620ec4803a..3acd8daf1b 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -91,9 +91,9 @@ protected: CC_PROPERTY(Point, _labelAnchorPoint, LabelAnchorPoint); /* Override setter to affect a background sprite too */ - virtual GLubyte getOpacity(void); + virtual GLubyte getOpacity(void) const; virtual void setOpacity(GLubyte var); - virtual const ccColor3B& getColor(void); + virtual const ccColor3B& getColor(void) const; virtual void setColor(const ccColor3B&); /** Flag to know if the button is currently pushed. */ diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index f8d18c3edc..517a7386a6 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -719,7 +719,7 @@ void Scale9Sprite::setOpacityModifyRGB(bool var) } } } -bool Scale9Sprite::isOpacityModifyRGB() +bool Scale9Sprite::isOpacityModifyRGB() const { return _opacityModifyRGB; } @@ -806,7 +806,7 @@ void Scale9Sprite::setColor(const ccColor3B& color) } } -const ccColor3B& Scale9Sprite::getColor() +const ccColor3B& Scale9Sprite::getColor() const { return _color; } @@ -827,7 +827,7 @@ void Scale9Sprite::setOpacity(GLubyte opacity) } } -GLubyte Scale9Sprite::getOpacity() +GLubyte Scale9Sprite::getOpacity() const { return _opacity; } diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index de9ef8db50..3002d63985 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -306,11 +306,11 @@ public: /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity); @since v0.8 */ - virtual bool isOpacityModifyRGB(void); + virtual bool isOpacityModifyRGB(void) const; virtual void setOpacity(GLubyte opacity); - virtual GLubyte getOpacity(); + virtual GLubyte getOpacity() const; virtual void setColor(const ccColor3B& color); - virtual const ccColor3B& getColor(); + virtual const ccColor3B& getColor() const; virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets); diff --git a/extensions/physics_nodes/CCPhysicsSprite.cpp b/extensions/physics_nodes/CCPhysicsSprite.cpp index 8f96926e23..f47ad21f04 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.cpp +++ b/extensions/physics_nodes/CCPhysicsSprite.cpp @@ -166,28 +166,29 @@ void PhysicsSprite::setIgnoreBodyRotation(bool bIgnoreBodyRotation) } // Override the setters and getters to always reflect the body's properties. -const Point& PhysicsSprite::getPosition() +const Point& PhysicsSprite::getPosition() const { - updatePosFromPhysics(); - return Node::getPosition(); + return getPosFromPhysics(); } -void PhysicsSprite::getPosition(float* x, float* y) +void PhysicsSprite::getPosition(float* x, float* y) const { - updatePosFromPhysics(); - return Node::getPosition(x, y); + if (x == NULL || y == NULL) { + return; + } + const Point& pos = getPosFromPhysics(); + *x = pos.x; + *y = pos.y; } -float PhysicsSprite::getPositionX() +float PhysicsSprite::getPositionX() const { - updatePosFromPhysics(); - return _position.x; + return getPosFromPhysics().x; } -float PhysicsSprite::getPositionY() +float PhysicsSprite::getPositionY() const { - updatePosFromPhysics(); - return _position.y; + return getPosFromPhysics().y; } // @@ -270,22 +271,22 @@ void PhysicsSprite::setCPBody(cpBody *pBody) // Common to Box2d and Chipmunk // -void PhysicsSprite::updatePosFromPhysics() +const Point& PhysicsSprite::getPosFromPhysics() const { - + static Point s_physicPosion; #if CC_ENABLE_CHIPMUNK_INTEGRATION cpVect cpPos = cpBodyGetPos(_CPBody); - _position = ccp(cpPos.x, cpPos.y); + s_physicPosion = ccp(cpPos.x, cpPos.y); #elif CC_ENABLE_BOX2D_INTEGRATION b2Vec2 pos = _pB2Body->GetPosition(); float x = pos.x * _PTMRatio; float y = pos.y * _PTMRatio; - _position = ccp(x,y); + s_physicPosion = ccp(x,y); #endif - + return s_physicPosion; } void PhysicsSprite::setPosition(const Point &pos) @@ -303,7 +304,7 @@ void PhysicsSprite::setPosition(const Point &pos) } -float PhysicsSprite::getRotation() +float PhysicsSprite::getRotation() const { #if CC_ENABLE_CHIPMUNK_INTEGRATION diff --git a/extensions/physics_nodes/CCPhysicsSprite.h b/extensions/physics_nodes/CCPhysicsSprite.h index b0b2664ed0..7c209e5ea9 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.h +++ b/extensions/physics_nodes/CCPhysicsSprite.h @@ -96,12 +96,12 @@ public: bool isIgnoreBodyRotation() const; void setIgnoreBodyRotation(bool bIgnoreBodyRotation); - virtual const Point& getPosition(); - virtual void getPosition(float* x, float* y); - virtual float getPositionX(); - virtual float getPositionY(); + virtual const Point& getPosition() const; + virtual void getPosition(float* x, float* y) const; + virtual float getPositionX() const; + virtual float getPositionY() const; virtual void setPosition(const Point &position); - virtual float getRotation(); + virtual float getRotation() const; virtual void setRotation(float fRotation); virtual AffineTransform nodeToParentTransform(); @@ -123,7 +123,7 @@ public: void setPTMRatio(float fPTMRatio); protected: - void updatePosFromPhysics(); + const Point& getPosFromPhysics() const; }; NS_CC_EXT_END diff --git a/extensions/spine/CCSkeleton.cpp b/extensions/spine/CCSkeleton.cpp index 124209c246..f2289f1ac4 100644 --- a/extensions/spine/CCSkeleton.cpp +++ b/extensions/spine/CCSkeleton.cpp @@ -284,7 +284,7 @@ void CCSkeleton::setOpacityModifyRGB (bool value) { premultipliedAlpha = value; } -bool CCSkeleton::isOpacityModifyRGB () { +bool CCSkeleton::isOpacityModifyRGB () const { return premultipliedAlpha; } diff --git a/extensions/spine/CCSkeleton.h b/extensions/spine/CCSkeleton.h index 4715e87f3a..e1d739da9b 100644 --- a/extensions/spine/CCSkeleton.h +++ b/extensions/spine/CCSkeleton.h @@ -82,7 +82,7 @@ public: // --- BlendProtocol CC_PROPERTY_PASS_BY_REF(cocos2d::ccBlendFunc, blendFunc, BlendFunc); virtual void setOpacityModifyRGB (bool value); - virtual bool isOpacityModifyRGB (); + virtual bool isOpacityModifyRGB() const; protected: CCSkeleton ();