Adds const to getters

Many getters in cocos2d are not declared as const.
This patch adds const to many cocos2d properties, specially in CCNode and
subclasses
This commit is contained in:
Ricardo Quesada 2013-07-03 17:22:15 -07:00
parent 065146c533
commit adaa72fbb4
33 changed files with 165 additions and 163 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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("<Node | Tag = %d>", _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;
}

View File

@ -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;

View File

@ -430,7 +430,7 @@ void DrawNode::clear()
_dirty = true;
}
ccBlendFunc DrawNode::getBlendFunc() const
const ccBlendFunc& DrawNode::getBlendFunc() const
{
return _blendFunc;
}

View File

@ -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();

View File

@ -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;
};
/**

View File

@ -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();
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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);

View File

@ -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();
}

View File

@ -134,7 +134,7 @@ 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();
void setHorizontalAlignment(TextAlignment alignment);

View File

@ -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;
}

View File

@ -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);

View File

@ -179,7 +179,7 @@ void MenuItem::setCallback(const ccMenuCallback& callback)
//CCMenuItemLabel
//
const ccColor3B& MenuItemLabel::getDisabledColor()
const ccColor3B& MenuItemLabel::getDisabledColor() const
{
return _disabledColor;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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();

View File

@ -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;

View File

@ -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)

View File

@ -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.

View File

@ -959,7 +959,7 @@ void Sprite::setOpacityModifyRGB(bool modify)
}
}
bool Sprite::isOpacityModifyRGB(void)
bool Sprite::isOpacityModifyRGB(void) const
{
return _opacityModifyRGB;
}

View File

@ -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);
/// @}

View File

@ -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;
}

View File

@ -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);

View File

@ -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();
}

View File

@ -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;

View File

@ -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:

View File

@ -74,7 +74,7 @@ void Skin::setSkinData(const BaseData &var)
_skinTransform = nodeToParentTransform();
}
const BaseData &Skin::getSkinData()
const BaseData &Skin::getSkinData() const
{
return _skinData;
}

View File

@ -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;
}

View File

@ -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 ();