issue #2373: Adding missing overload const getter functions.

This commit is contained in:
James Chen 2013-07-05 15:06:38 +08:00
parent d2746bbe90
commit ec902c3550
15 changed files with 48 additions and 47 deletions

View File

@ -152,7 +152,7 @@ void AtlasNode::draw(void)
// AtlasNode - RGBA protocol // AtlasNode - RGBA protocol
const ccColor3B& AtlasNode::getColor() const ccColor3B& AtlasNode::getColor() const
{ {
if(_isOpacityModifyRGB) if(_isOpacityModifyRGB)
{ {
@ -191,7 +191,7 @@ void AtlasNode::setOpacityModifyRGB(bool bValue)
this->setColor(oldColor); this->setColor(oldColor);
} }
bool AtlasNode::isOpacityModifyRGB() bool AtlasNode::isOpacityModifyRGB() const
{ {
return _isOpacityModifyRGB; return _isOpacityModifyRGB;
} }

View File

@ -107,9 +107,9 @@ public:
/** sets a new texture. it will be retained*/ /** sets a new texture. it will be retained*/
virtual void setTexture(Texture2D *texture); virtual void setTexture(Texture2D *texture);
virtual bool isOpacityModifyRGB(); virtual bool isOpacityModifyRGB() const;
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
virtual const ccColor3B& getColor(void); virtual const ccColor3B& getColor(void) const;
virtual void setColor(const ccColor3B& color); virtual void setColor(const ccColor3B& color);
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);

View File

@ -135,7 +135,7 @@ public:
virtual void onExit(); virtual void onExit();
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} 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 bool isEnabled() { return _enabled; }
virtual void setEnabled(bool value) { _enabled = value; }; virtual void setEnabled(bool value) { _enabled = value; };

View File

@ -154,7 +154,7 @@ void ProgressTimer::setOpacityModifyRGB(bool bValue)
CC_UNUSED_PARAM(bValue); CC_UNUSED_PARAM(bValue);
} }
bool ProgressTimer::isOpacityModifyRGB(void) bool ProgressTimer::isOpacityModifyRGB(void) const
{ {
return false; return false;
} }
@ -225,7 +225,7 @@ void ProgressTimer::updateProgress(void)
} }
} }
void ProgressTimer::setAnchorPoint(Point anchorPoint) void ProgressTimer::setAnchorPoint(const Point& anchorPoint)
{ {
Node::setAnchorPoint(anchorPoint); Node::setAnchorPoint(anchorPoint);
} }

View File

@ -80,10 +80,10 @@ public:
void setReverseProgress(bool reverse); void setReverseProgress(bool reverse);
virtual void draw(void); virtual void draw(void);
void setAnchorPoint(Point anchorPoint); void setAnchorPoint(const Point& anchorPoint);
virtual void setOpacityModifyRGB(bool bValue); virtual void setOpacityModifyRGB(bool bValue);
virtual bool isOpacityModifyRGB(void); virtual bool isOpacityModifyRGB(void) const;
inline bool isReverseDirection() { return _reverseDirection; }; inline bool isReverseDirection() { return _reverseDirection; };
inline void setReverseDirection(bool value) { _reverseDirection = value; }; inline void setReverseDirection(bool value) { _reverseDirection = value; };

View File

@ -248,7 +248,7 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB)
} }
} }
bool Control::isOpacityModifyRGB() bool Control::isOpacityModifyRGB() const
{ {
return _isOpacityModifyRGB; return _isOpacityModifyRGB;
} }

View File

@ -114,7 +114,7 @@ public:
*/ */
virtual void needsLayout(); virtual void needsLayout();
virtual bool isOpacityModifyRGB(); virtual bool isOpacityModifyRGB() const;
virtual void setOpacityModifyRGB(bool bOpacityModifyRGB); virtual void setOpacityModifyRGB(bool bOpacityModifyRGB);
protected: protected:

View File

@ -724,7 +724,7 @@ void ControlButton::setOpacity(GLubyte opacity)
} }
} }
GLubyte ControlButton::getOpacity() GLubyte ControlButton::getOpacity() const
{ {
return _realOpacity; return _realOpacity;
} }
@ -741,7 +741,7 @@ void ControlButton::setColor(const ccColor3B & color)
} }
} }
const ccColor3B& ControlButton::getColor() const ccColor3B& ControlButton::getColor() const
{ {
return _realColor; return _realColor;
} }

View File

@ -91,9 +91,9 @@ protected:
CC_PROPERTY(Point, _labelAnchorPoint, LabelAnchorPoint); CC_PROPERTY(Point, _labelAnchorPoint, LabelAnchorPoint);
/* Override setter to affect a background sprite too */ /* Override setter to affect a background sprite too */
virtual GLubyte getOpacity(void); virtual GLubyte getOpacity(void) const;
virtual void setOpacity(GLubyte var); virtual void setOpacity(GLubyte var);
virtual const ccColor3B& getColor(void); virtual const ccColor3B& getColor(void) const;
virtual void setColor(const ccColor3B&); virtual void setColor(const ccColor3B&);
/** Flag to know if the button is currently pushed. */ /** Flag to know if the button is currently pushed. */

View File

@ -719,7 +719,7 @@ void Scale9Sprite::setOpacityModifyRGB(bool var)
} }
} }
} }
bool Scale9Sprite::isOpacityModifyRGB() bool Scale9Sprite::isOpacityModifyRGB() const
{ {
return _opacityModifyRGB; return _opacityModifyRGB;
} }
@ -806,7 +806,7 @@ void Scale9Sprite::setColor(const ccColor3B& color)
} }
} }
const ccColor3B& Scale9Sprite::getColor() const ccColor3B& Scale9Sprite::getColor() const
{ {
return _color; return _color;
} }
@ -827,7 +827,7 @@ void Scale9Sprite::setOpacity(GLubyte opacity)
} }
} }
GLubyte Scale9Sprite::getOpacity() GLubyte Scale9Sprite::getOpacity() const
{ {
return _opacity; return _opacity;
} }

View File

@ -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); /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
@since v0.8 @since v0.8
*/ */
virtual bool isOpacityModifyRGB(void); virtual bool isOpacityModifyRGB(void) const;
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);
virtual GLubyte getOpacity(); virtual GLubyte getOpacity() const;
virtual void setColor(const ccColor3B& color); 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); virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets);

View File

@ -166,28 +166,29 @@ void PhysicsSprite::setIgnoreBodyRotation(bool bIgnoreBodyRotation)
} }
// Override the setters and getters to always reflect the body's properties. // Override the setters and getters to always reflect the body's properties.
const Point& PhysicsSprite::getPosition() const Point& PhysicsSprite::getPosition() const
{ {
updatePosFromPhysics(); return getPosFromPhysics();
return Node::getPosition();
} }
void PhysicsSprite::getPosition(float* x, float* y) void PhysicsSprite::getPosition(float* x, float* y) const
{ {
updatePosFromPhysics(); if (x == NULL || y == NULL) {
return Node::getPosition(x, y); return;
}
const Point& pos = getPosFromPhysics();
*x = pos.x;
*y = pos.y;
} }
float PhysicsSprite::getPositionX() float PhysicsSprite::getPositionX() const
{ {
updatePosFromPhysics(); return getPosFromPhysics().x;
return _position.x;
} }
float PhysicsSprite::getPositionY() float PhysicsSprite::getPositionY() const
{ {
updatePosFromPhysics(); return getPosFromPhysics().y;
return _position.y;
} }
// //
@ -270,22 +271,22 @@ void PhysicsSprite::setCPBody(cpBody *pBody)
// Common to Box2d and Chipmunk // Common to Box2d and Chipmunk
// //
void PhysicsSprite::updatePosFromPhysics() const Point& PhysicsSprite::getPosFromPhysics() const
{ {
static Point s_physicPosion;
#if CC_ENABLE_CHIPMUNK_INTEGRATION #if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect cpPos = cpBodyGetPos(_CPBody); cpVect cpPos = cpBodyGetPos(_CPBody);
_position = ccp(cpPos.x, cpPos.y); s_physicPosion = ccp(cpPos.x, cpPos.y);
#elif CC_ENABLE_BOX2D_INTEGRATION #elif CC_ENABLE_BOX2D_INTEGRATION
b2Vec2 pos = _pB2Body->GetPosition(); b2Vec2 pos = _pB2Body->GetPosition();
float x = pos.x * _PTMRatio; float x = pos.x * _PTMRatio;
float y = pos.y * _PTMRatio; float y = pos.y * _PTMRatio;
_position = ccp(x,y); s_physicPosion = ccp(x,y);
#endif #endif
return s_physicPosion;
} }
void PhysicsSprite::setPosition(const Point &pos) 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 #if CC_ENABLE_CHIPMUNK_INTEGRATION

View File

@ -96,12 +96,12 @@ public:
bool isIgnoreBodyRotation() const; bool isIgnoreBodyRotation() const;
void setIgnoreBodyRotation(bool bIgnoreBodyRotation); void setIgnoreBodyRotation(bool bIgnoreBodyRotation);
virtual const Point& getPosition(); virtual const Point& getPosition() const;
virtual void getPosition(float* x, float* y); virtual void getPosition(float* x, float* y) const;
virtual float getPositionX(); virtual float getPositionX() const;
virtual float getPositionY(); virtual float getPositionY() const;
virtual void setPosition(const Point &position); virtual void setPosition(const Point &position);
virtual float getRotation(); virtual float getRotation() const;
virtual void setRotation(float fRotation); virtual void setRotation(float fRotation);
virtual AffineTransform nodeToParentTransform(); virtual AffineTransform nodeToParentTransform();
@ -123,7 +123,7 @@ public:
void setPTMRatio(float fPTMRatio); void setPTMRatio(float fPTMRatio);
protected: protected:
void updatePosFromPhysics(); const Point& getPosFromPhysics() const;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -284,7 +284,7 @@ void CCSkeleton::setOpacityModifyRGB (bool value) {
premultipliedAlpha = value; premultipliedAlpha = value;
} }
bool CCSkeleton::isOpacityModifyRGB () { bool CCSkeleton::isOpacityModifyRGB () const {
return premultipliedAlpha; return premultipliedAlpha;
} }

View File

@ -82,7 +82,7 @@ public:
// --- BlendProtocol // --- BlendProtocol
CC_PROPERTY_PASS_BY_REF(cocos2d::ccBlendFunc, blendFunc, BlendFunc); CC_PROPERTY_PASS_BY_REF(cocos2d::ccBlendFunc, blendFunc, BlendFunc);
virtual void setOpacityModifyRGB (bool value); virtual void setOpacityModifyRGB (bool value);
virtual bool isOpacityModifyRGB (); virtual bool isOpacityModifyRGB() const;
protected: protected:
CCSkeleton (); CCSkeleton ();