diff --git a/native/cocos/2d/CCActionCatmullRom.cpp b/native/cocos/2d/CCActionCatmullRom.cpp index 1d03ef3df0..60aa227172 100644 --- a/native/cocos/2d/CCActionCatmullRom.cpp +++ b/native/cocos/2d/CCActionCatmullRom.cpp @@ -112,12 +112,12 @@ void PointArray::setControlPoints(vector *controlPoints) _controlPoints = controlPoints; } -void PointArray::addControlPoint(Vec2 controlPoint) +void PointArray::addControlPoint(const Vec2& controlPoint) { _controlPoints->push_back(new Vec2(controlPoint.x, controlPoint.y)); } -void PointArray::insertControlPoint(Vec2 &controlPoint, ssize_t index) +void PointArray::insertControlPoint(const Vec2& controlPoint, ssize_t index) { Vec2 *temp = new (std::nothrow) Vec2(controlPoint.x, controlPoint.y); _controlPoints->insert(_controlPoints->begin() + index, temp); @@ -129,7 +129,7 @@ Vec2 PointArray::getControlPointAtIndex(ssize_t index) return *(_controlPoints->at(index)); } -void PointArray::replaceControlPoint(cocos2d::Vec2 &controlPoint, ssize_t index) +void PointArray::replaceControlPoint(const Vec2& controlPoint, ssize_t index) { Vec2 *temp = _controlPoints->at(index); temp->x = controlPoint.x; @@ -321,7 +321,7 @@ void CardinalSplineTo::update(float time) this->updatePosition(newPos); } -void CardinalSplineTo::updatePosition(cocos2d::Vec2 &newPos) +void CardinalSplineTo::updatePosition(const Vec2& newPos) { _target->setPosition(newPos); _previousPosition = newPos; @@ -359,7 +359,7 @@ CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0) { } -void CardinalSplineBy::updatePosition(cocos2d::Vec2 &newPos) +void CardinalSplineBy::updatePosition(const Vec2& newPos) { Vec2 p = newPos + _startPosition; _target->setPosition(p); diff --git a/native/cocos/2d/CCActionCatmullRom.h b/native/cocos/2d/CCActionCatmullRom.h index d14fff16b9..4c73ec35ed 100644 --- a/native/cocos/2d/CCActionCatmullRom.h +++ b/native/cocos/2d/CCActionCatmullRom.h @@ -88,7 +88,7 @@ public: * @js NA * @param controlPoint A control point. */ - void addControlPoint(Vec2 controlPoint); + void addControlPoint(const Vec2& controlPoint); /** Inserts a controlPoint at index. * @@ -96,7 +96,7 @@ public: * @param controlPoint A control point. * @param index Insert the point to array in index. */ - void insertControlPoint(Vec2 &controlPoint, ssize_t index); + void insertControlPoint(const Vec2& controlPoint, ssize_t index); /** Replaces an existing controlPoint at index. * @@ -104,7 +104,7 @@ public: * @param controlPoint A control point. * @param index Replace the point to array in index. */ - void replaceControlPoint(Vec2 &controlPoint, ssize_t index); + void replaceControlPoint(const Vec2& controlPoint, ssize_t index); /** Get the value of a controlPoint at a given index. * @@ -200,7 +200,7 @@ public: * * @param newPos The new position. */ - virtual void updatePosition(Vec2 &newPos); + virtual void updatePosition(const Vec2& newPos); /** Return a PointArray. * * @return A PointArray. @@ -261,7 +261,7 @@ public: // Overrides virtual void startWithTarget(Node *target) override; - virtual void updatePosition(Vec2 &newPos) override; + virtual void updatePosition(const Vec2& newPos) override; virtual CardinalSplineBy *clone() const override; virtual CardinalSplineBy* reverse() const override; diff --git a/native/cocos/2d/CCActionGrid3D.cpp b/native/cocos/2d/CCActionGrid3D.cpp index 045d486ad5..3c2ad3fe3e 100644 --- a/native/cocos/2d/CCActionGrid3D.cpp +++ b/native/cocos/2d/CCActionGrid3D.cpp @@ -653,7 +653,7 @@ void Waves::update(float time) // implementation of Twirl -Twirl* Twirl::create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude) +Twirl* Twirl::create(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude) { Twirl *action = new (std::nothrow) Twirl(); @@ -672,7 +672,7 @@ Twirl* Twirl::create(float duration, const Size& gridSize, Vec2 position, unsign return action; } -bool Twirl::initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude) +bool Twirl::initWithDuration(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { diff --git a/native/cocos/2d/CCActionGrid3D.h b/native/cocos/2d/CCActionGrid3D.h index c606291ce8..381a945196 100644 --- a/native/cocos/2d/CCActionGrid3D.h +++ b/native/cocos/2d/CCActionGrid3D.h @@ -545,7 +545,7 @@ public: @param amplitude Specify the amplitude of the Twirl action. @return If the creation success, return a pointer of Twirl action; otherwise, return nil. */ - static Twirl* create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude); + static Twirl* create(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude); /** @brief Get the center position of twirl action. @@ -598,7 +598,7 @@ CC_CONSTRUCTOR_ACCESS: @param amplitude Specify the amplitude of the Twirl action. @return If the initialization success, return true; otherwise, return false. */ - bool initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude); + bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude); protected: /* twirl center */ diff --git a/native/cocos/2d/CCDrawingPrimitives.cpp b/native/cocos/2d/CCDrawingPrimitives.cpp index 4c5a3f6e8f..3b8c8dda43 100644 --- a/native/cocos/2d/CCDrawingPrimitives.cpp +++ b/native/cocos/2d/CCDrawingPrimitives.cpp @@ -179,7 +179,7 @@ void drawLine(const Vec2& origin, const Vec2& destination) CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2); } -void drawRect( Vec2 origin, Vec2 destination ) +void drawRect( const Vec2& origin, const Vec2& destination ) { drawLine(Vec2(origin.x, origin.y), Vec2(destination.x, origin.y)); drawLine(Vec2(destination.x, origin.y), Vec2(destination.x, destination.y)); @@ -187,7 +187,7 @@ void drawRect( Vec2 origin, Vec2 destination ) drawLine(Vec2(origin.x, destination.y), Vec2(origin.x, origin.y)); } -void drawSolidRect(Vec2 origin, Vec2 destination, Color4F color) +void drawSolidRect(const Vec2& origin, const Vec2& destination, const Color4F& color) { Vec2 vertices[] = { origin, diff --git a/native/cocos/2d/CCDrawingPrimitives.h b/native/cocos/2d/CCDrawingPrimitives.h index d744b32fc3..03046353dd 100644 --- a/native/cocos/2d/CCDrawingPrimitives.h +++ b/native/cocos/2d/CCDrawingPrimitives.h @@ -120,7 +120,7 @@ namespace DrawPrimitives * @param origin The rectangle origin. * @param destination The rectangle destination. */ - CC_DEPRECATED_ATTRIBUTE void CC_DLL drawRect(Vec2 origin, Vec2 destination); + CC_DEPRECATED_ATTRIBUTE void CC_DLL drawRect(const Vec2& origin, const Vec2& destination); /** Draws a solid rectangle given the origin and destination point measured in points. * The origin and the destination can not have the same x and y coordinate. @@ -130,7 +130,7 @@ namespace DrawPrimitives * @param color The rectangle color. * @since 1.1 */ - CC_DEPRECATED_ATTRIBUTE void CC_DLL drawSolidRect(Vec2 origin, Vec2 destination, Color4F color); + CC_DEPRECATED_ATTRIBUTE void CC_DLL drawSolidRect(const Vec2& origin, const Vec2& destination, const Color4F& color); /** Draws a polygon given a pointer to point coordinates and the number of vertices measured in points. * The polygon can be closed or open. diff --git a/native/cocos/2d/CCFastTMXLayer.cpp b/native/cocos/2d/CCFastTMXLayer.cpp index 0ba9c6914a..a58f65d452 100644 --- a/native/cocos/2d/CCFastTMXLayer.cpp +++ b/native/cocos/2d/CCFastTMXLayer.cpp @@ -807,7 +807,7 @@ void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flag } } -void TMXLayer::setupTileSprite(Sprite* sprite, Vec2 pos, int gid) +void TMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, int gid) { sprite->setPosition(getPositionAt(pos)); sprite->setPositionZ((float)getVertexZForPos(pos)); diff --git a/native/cocos/2d/CCFastTMXLayer.h b/native/cocos/2d/CCFastTMXLayer.h index cc86e05260..dbc0ed290a 100644 --- a/native/cocos/2d/CCFastTMXLayer.h +++ b/native/cocos/2d/CCFastTMXLayer.h @@ -257,7 +257,7 @@ public: * @param pos The tile coordinate. * @param gid The tile gid. */ - void setupTileSprite(Sprite* sprite, Vec2 pos, int gid); + void setupTileSprite(Sprite* sprite, const Vec2& pos, int gid); //Unsupported void releaseMap() {} diff --git a/native/cocos/2d/CCParallaxNode.cpp b/native/cocos/2d/CCParallaxNode.cpp index 7744f5f521..b9470d9fc7 100644 --- a/native/cocos/2d/CCParallaxNode.cpp +++ b/native/cocos/2d/CCParallaxNode.cpp @@ -32,7 +32,7 @@ NS_CC_BEGIN class PointObject : public Ref { public: - static PointObject * create(Vec2 ratio, Vec2 offset) + static PointObject * create(const Vec2& ratio, const Vec2& offset) { PointObject *ret = new (std::nothrow) PointObject(); ret->initWithPoint(ratio, offset); @@ -40,7 +40,7 @@ public: return ret; } - bool initWithPoint(Vec2 ratio, Vec2 offset) + bool initWithPoint(const Vec2& ratio, const Vec2& offset) { _ratio = ratio; _offset = offset; diff --git a/native/cocos/2d/CCProgressTimer.cpp b/native/cocos/2d/CCProgressTimer.cpp index 5d6fd77c34..6b668334d4 100644 --- a/native/cocos/2d/CCProgressTimer.cpp +++ b/native/cocos/2d/CCProgressTimer.cpp @@ -167,7 +167,7 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha) return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y); } -Vec2 ProgressTimer::vertexFromAlphaPoint(Vec2 alpha) +Vec2 ProgressTimer::vertexFromAlphaPoint(const Vec2& alpha) { Vec2 ret(0.0f, 0.0f); if (!_sprite) { diff --git a/native/cocos/2d/CCProgressTimer.h b/native/cocos/2d/CCProgressTimer.h index a9197a717a..8c308a97ba 100644 --- a/native/cocos/2d/CCProgressTimer.h +++ b/native/cocos/2d/CCProgressTimer.h @@ -178,7 +178,7 @@ protected: void onDraw(const Mat4 &transform, uint32_t flags); Tex2F textureCoordFromAlphaPoint(Vec2 alpha); - Vec2 vertexFromAlphaPoint(Vec2 alpha); + Vec2 vertexFromAlphaPoint(const Vec2& alpha); void updateProgress(); void updateBar(); void updateRadial(); diff --git a/native/cocos/base/CCConsole.cpp b/native/cocos/base/CCConsole.cpp index 9a3c140dcc..5b6a21c29b 100644 --- a/native/cocos/base/CCConsole.cpp +++ b/native/cocos/base/CCConsole.cpp @@ -107,7 +107,7 @@ static std::vector split(const std::string &s, char delim) { return elems; } //isFloat taken from http://stackoverflow.com/questions/447206/c-isfloat-function -static bool isFloat( std::string myString ) { +static bool isFloat(const std::string& myString ) { std::istringstream iss(myString); float f; iss >> std::noskipws >> f; // noskipws considers leading whitespace invalid diff --git a/native/cocos/editor-support/cocostudio/Armature/CCDatas.cpp b/native/cocos/editor-support/cocostudio/Armature/CCDatas.cpp index 92cb20be2a..3655c01f40 100644 --- a/native/cocos/editor-support/cocostudio/Armature/CCDatas.cpp +++ b/native/cocos/editor-support/cocostudio/Armature/CCDatas.cpp @@ -390,7 +390,7 @@ bool ContourData::init() return true; } -void ContourData::addVertex(Vec2 &vertex) +void ContourData::addVertex(const cocos2d::Vec2& vertex) { vertexList.push_back(vertex); } diff --git a/native/cocos/editor-support/cocostudio/Armature/CCDatas.h b/native/cocos/editor-support/cocostudio/Armature/CCDatas.h index b9105351b6..154482ac3a 100644 --- a/native/cocos/editor-support/cocostudio/Armature/CCDatas.h +++ b/native/cocos/editor-support/cocostudio/Armature/CCDatas.h @@ -503,7 +503,7 @@ public: ~ContourData(); virtual bool init(); - virtual void addVertex(cocos2d::Vec2 &vertex); + virtual void addVertex(const cocos2d::Vec2& vertex); public: std::vector vertexList; //! Save contour vertex info, vertex saved in a Vec2 }; diff --git a/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.cpp b/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.cpp index f8c01329d2..4acbe9aa78 100644 --- a/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.cpp +++ b/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.cpp @@ -29,7 +29,7 @@ using namespace cocos2d; namespace cocostudio { -bool isSpriteContainPoint(Sprite *sprite, Vec2 point, Vec2 &outPoint) +bool isSpriteContainPoint(Sprite *sprite, const Vec2& point, Vec2 &outPoint) { outPoint = sprite->convertToNodeSpace(point); @@ -39,7 +39,7 @@ bool isSpriteContainPoint(Sprite *sprite, Vec2 point, Vec2 &outPoint) return r.containsPoint(outPoint); } -bool isSpriteContainPoint(Sprite *sprite, Vec2 point) +bool isSpriteContainPoint(Sprite *sprite, const Vec2& point) { Vec2 p; return isSpriteContainPoint(sprite, point, p); diff --git a/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.h b/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.h index 5d04fb4fda..bfd2519599 100644 --- a/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.h +++ b/native/cocos/editor-support/cocostudio/Armature/CCUtilMath.h @@ -38,8 +38,8 @@ namespace cocostudio { //! hit test function -bool CC_STUDIO_DLL isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Vec2 point); -bool CC_STUDIO_DLL isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Vec2 point, cocos2d::Vec2 &outPoint); +bool CC_STUDIO_DLL isSpriteContainPoint(cocos2d::Sprite *sprite, const cocos2d::Vec2& point); +bool CC_STUDIO_DLL isSpriteContainPoint(cocos2d::Sprite *sprite, const cocos2d::Vec2& point, cocos2d::Vec2 &outPoint); #define CC_SPRITE_CONTAIN_POINT(sprite, point) isSpriteContainPoint((sprite), (point)) #define CC_SPRITE_CONTAIN_POINT_WITH_RETURN(sprite, point, outPoint) isSpriteContainPoint((sprite), (point), outPoint) diff --git a/native/cocos/network/HttpClient-android.cpp b/native/cocos/network/HttpClient-android.cpp index e2712a008a..74706cf537 100644 --- a/native/cocos/network/HttpClient-android.cpp +++ b/native/cocos/network/HttpClient-android.cpp @@ -399,7 +399,7 @@ public: } private: - void createHttpURLConnection(std::string url) + void createHttpURLConnection(const std::string& url) { JniMethodInfo methodInfo; if (JniHelper::getStaticMethodInfo(methodInfo, diff --git a/native/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/native/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index fe5e8cd662..0e1cbedeec 100644 --- a/native/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/native/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -306,7 +306,7 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName) return nullptr; } -GLViewImpl* GLViewImpl::createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor, bool resizable/* = false*/) +GLViewImpl* GLViewImpl::createWithRect(const std::string& viewName, const Rect& rect, float frameZoomFactor, bool resizable/* = false*/) { auto ret = new (std::nothrow) GLViewImpl; if(ret && ret->initWithRect(viewName, rect, frameZoomFactor, resizable)) { diff --git a/native/cocos/platform/desktop/CCGLViewImpl-desktop.h b/native/cocos/platform/desktop/CCGLViewImpl-desktop.h index 9c269b3d30..09afb87b61 100644 --- a/native/cocos/platform/desktop/CCGLViewImpl-desktop.h +++ b/native/cocos/platform/desktop/CCGLViewImpl-desktop.h @@ -57,7 +57,7 @@ class CC_DLL GLViewImpl : public GLView { public: static GLViewImpl* create(const std::string& viewName); - static GLViewImpl* createWithRect(const std::string& viewName, Rect size, float frameZoomFactor = 1.0f, bool resizable = false); + static GLViewImpl* createWithRect(const std::string& viewName, const Rect& size, float frameZoomFactor = 1.0f, bool resizable = false); static GLViewImpl* createWithFullScreen(const std::string& viewName); static GLViewImpl* createWithFullScreen(const std::string& viewName, const GLFWvidmode &videoMode, GLFWmonitor *monitor); diff --git a/native/cocos/platform/ios/CCGLViewImpl-ios.h b/native/cocos/platform/ios/CCGLViewImpl-ios.h index 544447f13d..6208f23927 100644 --- a/native/cocos/platform/ios/CCGLViewImpl-ios.h +++ b/native/cocos/platform/ios/CCGLViewImpl-ios.h @@ -48,7 +48,7 @@ public: static GLViewImpl* create(const std::string& viewName); /** creates a GLViewImpl with a title name, a rect and the zoom factor */ - static GLViewImpl* createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor = 1.0f); + static GLViewImpl* createWithRect(const std::string& viewName, const Rect& rect, float frameZoomFactor = 1.0f); /** creates a GLViewImpl with a name in fullscreen mode */ static GLViewImpl* createWithFullScreen(const std::string& viewName); @@ -80,7 +80,7 @@ protected: virtual ~GLViewImpl(); bool initWithEAGLView(void* eaGLView); - bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor); + bool initWithRect(const std::string& viewName, const Rect& rect, float frameZoomFactor); bool initWithFullScreen(const std::string& viewName); // the objective-c CCEAGLView instance diff --git a/native/cocos/platform/ios/CCGLViewImpl-ios.mm b/native/cocos/platform/ios/CCGLViewImpl-ios.mm index 54d0b4202b..da34c80782 100644 --- a/native/cocos/platform/ios/CCGLViewImpl-ios.mm +++ b/native/cocos/platform/ios/CCGLViewImpl-ios.mm @@ -60,7 +60,7 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName) return nullptr; } -GLViewImpl* GLViewImpl::createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor) +GLViewImpl* GLViewImpl::createWithRect(const std::string& viewName, const Rect& rect, float frameZoomFactor) { auto ret = new (std::nothrow) GLViewImpl; if(ret && ret->initWithRect(viewName, rect, frameZoomFactor)) { @@ -129,7 +129,7 @@ bool GLViewImpl::initWithEAGLView(void *eaglview) return true; } -bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor) +bool GLViewImpl::initWithRect(const std::string& viewName, const Rect& rect, float frameZoomFactor) { CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); convertAttrs(); diff --git a/native/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp b/native/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp index d14a0384b4..c39a7a66d5 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp +++ b/native/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp @@ -124,7 +124,7 @@ void ControlHuePicker::setEnabled(bool enabled) } } -void ControlHuePicker::updateSliderPosition(Vec2 location) +void ControlHuePicker::updateSliderPosition(const Vec2& location) { // Clamp the position of the icon within the circle @@ -149,7 +149,7 @@ void ControlHuePicker::updateSliderPosition(Vec2 location) sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } -bool ControlHuePicker::checkSliderPosition(Vec2 location) +bool ControlHuePicker::checkSliderPosition(const Vec2& location) { // compute the distance between the current location and the center double distance = sqrt(pow (location.x + 10, 2) + pow(location.y, 2)); diff --git a/native/extensions/GUI/CCControlExtension/CCControlHuePicker.h b/native/extensions/GUI/CCControlExtension/CCControlHuePicker.h index 5c4bbf062c..1b46bcbdda 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlHuePicker.h +++ b/native/extensions/GUI/CCControlExtension/CCControlHuePicker.h @@ -68,8 +68,8 @@ public: virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override; protected: - void updateSliderPosition(Vec2 location); - bool checkSliderPosition(Vec2 location); + void updateSliderPosition(const Vec2& location); + bool checkSliderPosition(const Vec2& location); //maunally put in the setters CC_SYNTHESIZE_READONLY(float, _hue, Hue); diff --git a/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp b/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp index c8e2ec0236..464c7e4ee4 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp +++ b/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp @@ -200,7 +200,7 @@ void ControlPotentiometer::onTouchEnded(Touch *pTouch, Event *pEvent) this->potentiometerEnded(Vec2::ZERO); } -float ControlPotentiometer::distanceBetweenPointAndPoint(Vec2 point1, Vec2 point2) +float ControlPotentiometer::distanceBetweenPointAndPoint(const Vec2& point1, const Vec2& point2) { float dx = point1.x - point2.x; float dy = point1.y - point2.y; @@ -208,10 +208,10 @@ float ControlPotentiometer::distanceBetweenPointAndPoint(Vec2 point1, Vec2 point } float ControlPotentiometer::angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( - Vec2 beginLineA, - Vec2 endLineA, - Vec2 beginLineB, - Vec2 endLineB) + const Vec2& beginLineA, + const Vec2& endLineA, + const Vec2& beginLineB, + const Vec2& endLineB) { float a = endLineA.x - beginLineA.x; float b = endLineA.y - beginLineA.y; @@ -225,13 +225,13 @@ float ControlPotentiometer::angleInDegreesBetweenLineFromPoint_toPoint_toLineFro return (atanA - atanB) * 180 / M_PI; } -void ControlPotentiometer::potentiometerBegan(Vec2 location) +void ControlPotentiometer::potentiometerBegan(const Vec2& location) { setSelected(true); getThumbSprite()->setColor(Color3B::GRAY); } -void ControlPotentiometer::potentiometerMoved(Vec2 location) +void ControlPotentiometer::potentiometerMoved(const Vec2& location) { float angle = this->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( _progressTimer->getPosition(), @@ -254,7 +254,7 @@ void ControlPotentiometer::potentiometerMoved(Vec2 location) _previousLocation = location; } -void ControlPotentiometer::potentiometerEnded(Vec2 location) +void ControlPotentiometer::potentiometerEnded(const Vec2& location) { getThumbSprite()->setColor(Color3B::WHITE); setSelected(false); diff --git a/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.h b/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.h index ba20c4bfbf..302ce5df23 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.h +++ b/native/extensions/GUI/CCControlExtension/CCControlPotentiometer.h @@ -84,18 +84,18 @@ public: virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override; /** Factorize the event dispath into these methods. */ - void potentiometerBegan(Vec2 location); - void potentiometerMoved(Vec2 location); - void potentiometerEnded(Vec2 location); + void potentiometerBegan(const Vec2& location); + void potentiometerMoved(const Vec2& location); + void potentiometerEnded(const Vec2& location); /** Returns the distance between the point1 and point2. */ - float distanceBetweenPointAndPoint(Vec2 point1, Vec2 point2); + float distanceBetweenPointAndPoint(const Vec2& point1, const Vec2& point2); /** Returns the angle in degree between line1 and line2. */ float angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( - Vec2 beginLineA, - Vec2 endLineA, - Vec2 beginLineB, - Vec2 endLineB); + const Vec2& beginLineA, + const Vec2& endLineA, + const Vec2& beginLineB, + const Vec2& endLineB); protected: /** Contains the receiver’s current value. */ diff --git a/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 4daaef8dd5..b10265e778 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -156,7 +156,7 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Vec2 sliderPosition _brightness = fabs((_startPos.y + (float)boxPos - sliderPosition.y)/(float)boxSize); } -bool ControlSaturationBrightnessPicker::checkSliderPosition(Vec2 location) +bool ControlSaturationBrightnessPicker::checkSliderPosition(const Vec2& location) { // Clamp the position of the icon within the circle diff --git a/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h b/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h index 069fa216dc..a9bfea4714 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/native/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -92,7 +92,7 @@ public: protected: void updateSliderPosition(Vec2 location); - bool checkSliderPosition(Vec2 location); + bool checkSliderPosition(const Vec2& location); virtual bool onTouchBegan(Touch* touch, Event* pEvent) override; virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override; diff --git a/native/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/native/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 78db9d3cf8..ee25fdd3c3 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/native/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -294,7 +294,7 @@ void ControlSlider::needsLayout() _progressSprite->setTextureRect(textureRect, _progressSprite->isTextureRectRotated(), textureRect.size); } -void ControlSlider::sliderBegan(Vec2 location) +void ControlSlider::sliderBegan(const Vec2& location) { this->setSelected(true); _thumbSprite->setVisible(false); @@ -302,12 +302,12 @@ void ControlSlider::sliderBegan(Vec2 location) setValue(valueForLocation(location)); } -void ControlSlider::sliderMoved(Vec2 location) +void ControlSlider::sliderMoved(const Vec2& location) { setValue(valueForLocation(location)); } -void ControlSlider::sliderEnded(Vec2 location) +void ControlSlider::sliderEnded(const Vec2& location) { if (this->isSelected()) { @@ -318,7 +318,7 @@ void ControlSlider::sliderEnded(Vec2 location) this->setSelected(false); } -float ControlSlider::valueForLocation(Vec2 location) +float ControlSlider::valueForLocation(const Vec2& location) { float percent = location.x/ _backgroundSprite->getContentSize().width; return MAX(MIN(_minimumValue + percent * (_maximumValue - _minimumValue), _maximumAllowedValue), _minimumAllowedValue); diff --git a/native/extensions/GUI/CCControlExtension/CCControlSlider.h b/native/extensions/GUI/CCControlExtension/CCControlSlider.h index 0c6c6a3703..f0b4d1b7f8 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/native/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -118,16 +118,16 @@ public: virtual void setMinimumValue(float val); protected: - void sliderBegan(Vec2 location); - void sliderMoved(Vec2 location); - void sliderEnded(Vec2 location); + void sliderBegan(const Vec2& location); + void sliderMoved(const Vec2& location); + void sliderEnded(const Vec2& location); virtual bool onTouchBegan(Touch* touch, Event* pEvent) override; virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override; virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override; /** Returns the value for the given location. */ - float valueForLocation(Vec2 location); + float valueForLocation(const Vec2& location); //maunally put in the setters /** Contains the receiver's current value. */ diff --git a/native/extensions/GUI/CCControlExtension/CCControlStepper.cpp b/native/extensions/GUI/CCControlExtension/CCControlStepper.cpp index 26343b852b..78e303639c 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlStepper.cpp +++ b/native/extensions/GUI/CCControlExtension/CCControlStepper.cpp @@ -253,7 +253,7 @@ void ControlStepper::update(float dt) //// ControlStepper Private Methods -void ControlStepper::updateLayoutUsingTouchLocation(Vec2 location) +void ControlStepper::updateLayoutUsingTouchLocation(const Vec2& location) { if (location.x < _minusSprite->getContentSize().width && _value > _minimumValue) diff --git a/native/extensions/GUI/CCControlExtension/CCControlStepper.h b/native/extensions/GUI/CCControlExtension/CCControlStepper.h index 749c465bce..9518830bfc 100644 --- a/native/extensions/GUI/CCControlExtension/CCControlStepper.h +++ b/native/extensions/GUI/CCControlExtension/CCControlStepper.h @@ -83,7 +83,7 @@ public: void update(float dt) override; /** Update the layout of the stepper with the given touch location. */ - void updateLayoutUsingTouchLocation(Vec2 location); + void updateLayoutUsingTouchLocation(const Vec2& location); /** Start the autorepeat increment/decrement. */ void startAutorepeat(); diff --git a/native/extensions/GUI/CCScrollView/CCScrollView.cpp b/native/extensions/GUI/CCScrollView/CCScrollView.cpp index 9e80978867..1136a8565a 100644 --- a/native/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/native/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -232,7 +232,7 @@ void ScrollView::setContentOffset(Vec2 offset, bool animated/* = false*/) } } -void ScrollView::setContentOffsetInDuration(Vec2 offset, float dt) +void ScrollView::setContentOffsetInDuration(const Vec2& offset, float dt) { FiniteTimeAction *scroll, *expire; if (_animatedScrollAction) { diff --git a/native/extensions/GUI/CCScrollView/CCScrollView.h b/native/extensions/GUI/CCScrollView/CCScrollView.h index 68c15f8170..7e2908b040 100644 --- a/native/extensions/GUI/CCScrollView/CCScrollView.h +++ b/native/extensions/GUI/CCScrollView/CCScrollView.h @@ -127,7 +127,7 @@ public: * @param offset The new offset. * @param dt The animation duration. */ - void setContentOffsetInDuration(Vec2 offset, float dt); + void setContentOffsetInDuration(const Vec2& offset, float dt); /** * Halts the movement animation of the inner content started with setContentOffset() or setContentOffsetInDuration()