diff --git a/cocos/2d/CCAction.cpp b/cocos/2d/CCAction.cpp index 7d2e8c8220..531f5ec94a 100644 --- a/cocos/2d/CCAction.cpp +++ b/cocos/2d/CCAction.cpp @@ -215,7 +215,7 @@ bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO* _boundaryFullyCovered = false; Size winSize = Director::getInstance()->getWinSize(); - _fullScreenSize = Vector2(winSize.width, winSize.height); + _fullScreenSize = Vec2(winSize.width, winSize.height); _halfScreenSize = _fullScreenSize * 0.5f; if (_boundarySet) @@ -257,9 +257,9 @@ void Follow::step(float dt) if(_boundaryFullyCovered) return; - Vector2 tempPos = _halfScreenSize - _followedNode->getPosition(); + Vec2 tempPos = _halfScreenSize - _followedNode->getPosition(); - _target->setPosition(Vector2(clampf(tempPos.x, _leftBoundary, _rightBoundary), + _target->setPosition(Vec2(clampf(tempPos.x, _leftBoundary, _rightBoundary), clampf(tempPos.y, _bottomBoundary, _topBoundary))); } else diff --git a/cocos/2d/CCAction.h b/cocos/2d/CCAction.h index c315fad3b1..2842301b90 100644 --- a/cocos/2d/CCAction.h +++ b/cocos/2d/CCAction.h @@ -277,8 +277,8 @@ protected: bool _boundaryFullyCovered; // fast access to the screen dimensions - Vector2 _halfScreenSize; - Vector2 _fullScreenSize; + Vec2 _halfScreenSize; + Vec2 _fullScreenSize; // world boundaries float _leftBoundary; diff --git a/cocos/2d/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp index 87d377372c..59657d040d 100644 --- a/cocos/2d/CCActionCamera.cpp +++ b/cocos/2d/CCActionCamera.cpp @@ -60,12 +60,12 @@ ActionCamera * ActionCamera::reverse() const void ActionCamera::restore() { - _center = Vector3(0, 0, 0); - _eye = Vector3(0, 0, FLT_EPSILON); - _up = Vector3(0, 1, 0); + _center = Vec3(0, 0, 0); + _eye = Vec3(0, 0, FLT_EPSILON); + _up = Vec3(0, 1, 0); } -void ActionCamera::setEye(const Vector3& eye) +void ActionCamera::setEye(const Vec3& eye) { _eye = eye; updateTransform(); @@ -73,17 +73,17 @@ void ActionCamera::setEye(const Vector3& eye) void ActionCamera::setEye(float x, float y, float z) { - _eye = Vector3(x, y, z); + _eye = Vec3(x, y, z); updateTransform(); } -void ActionCamera::setCenter(const Vector3& center) +void ActionCamera::setCenter(const Vec3& center) { _center = center; updateTransform(); } -void ActionCamera::setUp(const Vector3& up) +void ActionCamera::setUp(const Vec3& up) { _up = up; updateTransform(); @@ -91,18 +91,18 @@ void ActionCamera::setUp(const Vector3& up) void ActionCamera::updateTransform() { - Matrix lookupMatrix; - Matrix::createLookAt(_eye.x, _eye.y, _eye.z, _center.x, _center.y, _center.z, _up.x, _up.y, _up.z, &lookupMatrix); + Mat4 lookupMatrix; + Mat4::createLookAt(_eye.x, _eye.y, _eye.z, _center.x, _center.y, _center.z, _up.x, _up.y, _up.z, &lookupMatrix); - Vector2 anchorPoint = _target->getAnchorPointInPoints(); + Vec2 anchorPoint = _target->getAnchorPointInPoints(); - bool needsTranslation = !anchorPoint.equals(Vector2::ZERO); + bool needsTranslation = !anchorPoint.equals(Vec2::ZERO); - Matrix mv = Matrix::IDENTITY; + Mat4 mv = Mat4::IDENTITY; if(needsTranslation) { - Matrix t; - Matrix::createTranslation(anchorPoint.x, anchorPoint.y, 0, &t); + Mat4 t; + Mat4::createTranslation(anchorPoint.x, anchorPoint.y, 0, &t); mv = mv * t; } @@ -110,8 +110,8 @@ void ActionCamera::updateTransform() if(needsTranslation) { - Matrix t; - Matrix::createTranslation(-anchorPoint.x, -anchorPoint.y, 0, &t); + Mat4 t; + Mat4::createTranslation(-anchorPoint.x, -anchorPoint.y, 0, &t); mv = mv * t; } diff --git a/cocos/2d/CCActionCamera.h b/cocos/2d/CCActionCamera.h index 68eb8f4e2b..4a32234511 100644 --- a/cocos/2d/CCActionCamera.h +++ b/cocos/2d/CCActionCamera.h @@ -63,27 +63,27 @@ public: virtual ActionCamera *clone() const override; /* sets the Eye value of the Camera */ - void setEye(const Vector3 &eye); + void setEye(const Vec3 &eye); void setEye(float x, float y, float z); /* returns the Eye value of the Camera */ - const Vector3& getEye() const { return _eye; } + const Vec3& getEye() const { return _eye; } /* sets the Center value of the Camera */ - void setCenter(const Vector3 ¢er); + void setCenter(const Vec3 ¢er); /* returns the Center value of the Camera */ - const Vector3& getCenter() const { return _center; } + const Vec3& getCenter() const { return _center; } /* sets the Up value of the Camera */ - void setUp(const Vector3 &up); + void setUp(const Vec3 &up); /* Returns the Up value of the Camera */ - const Vector3& getUp() const { return _up; } + const Vec3& getUp() const { return _up; } protected: void restore(); void updateTransform(); - Vector3 _center; - Vector3 _eye; - Vector3 _up; + Vec3 _center; + Vec3 _eye; + Vec3 _up; }; /** diff --git a/cocos/2d/CCActionCatmullRom.cpp b/cocos/2d/CCActionCatmullRom.cpp index 8a8cccffaf..f916b195c7 100644 --- a/cocos/2d/CCActionCatmullRom.cpp +++ b/cocos/2d/CCActionCatmullRom.cpp @@ -62,18 +62,18 @@ PointArray* PointArray::create(ssize_t capacity) bool PointArray::initWithCapacity(ssize_t capacity) { - _controlPoints = new vector(); + _controlPoints = new vector(); return true; } PointArray* PointArray::clone() const { - vector *newArray = new vector(); - vector::iterator iter; + vector *newArray = new vector(); + vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { - newArray->push_back(new Vector2((*iter)->x, (*iter)->y)); + newArray->push_back(new Vec2((*iter)->x, (*iter)->y)); } PointArray *points = new PointArray(); @@ -88,7 +88,7 @@ PointArray::~PointArray() { CCLOGINFO("deallocing PointArray: %p", this); - vector::iterator iter; + vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { delete *iter; @@ -98,17 +98,17 @@ PointArray::~PointArray() PointArray::PointArray() :_controlPoints(nullptr){} -const std::vector* PointArray::getControlPoints() const +const std::vector* PointArray::getControlPoints() const { return _controlPoints; } -void PointArray::setControlPoints(vector *controlPoints) +void PointArray::setControlPoints(vector *controlPoints) { CCASSERT(controlPoints != nullptr, "control points should not be nullptr"); // delete old points - vector::iterator iter; + vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { delete *iter; @@ -118,35 +118,35 @@ void PointArray::setControlPoints(vector *controlPoints) _controlPoints = controlPoints; } -void PointArray::addControlPoint(Vector2 controlPoint) +void PointArray::addControlPoint(Vec2 controlPoint) { - _controlPoints->push_back(new Vector2(controlPoint.x, controlPoint.y)); + _controlPoints->push_back(new Vec2(controlPoint.x, controlPoint.y)); } -void PointArray::insertControlPoint(Vector2 &controlPoint, ssize_t index) +void PointArray::insertControlPoint(Vec2 &controlPoint, ssize_t index) { - Vector2 *temp = new Vector2(controlPoint.x, controlPoint.y); + Vec2 *temp = new Vec2(controlPoint.x, controlPoint.y); _controlPoints->insert(_controlPoints->begin() + index, temp); } -Vector2 PointArray::getControlPointAtIndex(ssize_t index) +Vec2 PointArray::getControlPointAtIndex(ssize_t index) { index = MIN(static_cast(_controlPoints->size())-1, MAX(index, 0)); return *(_controlPoints->at(index)); } -void PointArray::replaceControlPoint(cocos2d::Vector2 &controlPoint, ssize_t index) +void PointArray::replaceControlPoint(cocos2d::Vec2 &controlPoint, ssize_t index) { - Vector2 *temp = _controlPoints->at(index); + Vec2 *temp = _controlPoints->at(index); temp->x = controlPoint.x; temp->y = controlPoint.y; } void PointArray::removeControlPointAtIndex(ssize_t index) { - vector::iterator iter = _controlPoints->begin() + index; - Vector2* removedPoint = *iter; + vector::iterator iter = _controlPoints->begin() + index; + Vec2* removedPoint = *iter; _controlPoints->erase(iter); delete removedPoint; } @@ -158,13 +158,13 @@ ssize_t PointArray::count() const PointArray* PointArray::reverse() const { - vector *newArray = new vector(); - vector::reverse_iterator iter; - Vector2 *point = nullptr; + vector *newArray = new vector(); + vector::reverse_iterator iter; + Vec2 *point = nullptr; for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter) { point = *iter; - newArray->push_back(new Vector2(point->x, point->y)); + newArray->push_back(new Vec2(point->x, point->y)); } PointArray *config = PointArray::create(0); config->setControlPoints(newArray); @@ -175,8 +175,8 @@ PointArray* PointArray::reverse() const void PointArray::reverseInline() { size_t l = _controlPoints->size(); - Vector2 *p1 = nullptr; - Vector2 *p2 = nullptr; + Vec2 *p1 = nullptr; + Vec2 *p2 = nullptr; float x, y; for (size_t i = 0; i < l/2; ++i) { @@ -195,7 +195,7 @@ void PointArray::reverseInline() } // CatmullRom Spline formula: -Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t) +Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, float t) { float t2 = t * t; float t3 = t2 * t; @@ -213,7 +213,7 @@ Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, f float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4); float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4); - return Vector2(x,y); + return Vec2(x,y); } /* Implementation of CardinalSplineTo @@ -274,7 +274,7 @@ void CardinalSplineTo::startWithTarget(cocos2d::Node *target) _deltaT = (float) 1 / (_points->count() - 1); _previousPosition = target->getPosition(); - _accumulatedDiff = Vector2::ZERO; + _accumulatedDiff = Vec2::ZERO; } CardinalSplineTo* CardinalSplineTo::clone() const @@ -307,17 +307,17 @@ void CardinalSplineTo::update(float time) } // Interpolate - Vector2 pp0 = _points->getControlPointAtIndex(p-1); - Vector2 pp1 = _points->getControlPointAtIndex(p+0); - Vector2 pp2 = _points->getControlPointAtIndex(p+1); - Vector2 pp3 = _points->getControlPointAtIndex(p+2); + Vec2 pp0 = _points->getControlPointAtIndex(p-1); + Vec2 pp1 = _points->getControlPointAtIndex(p+0); + Vec2 pp2 = _points->getControlPointAtIndex(p+1); + Vec2 pp3 = _points->getControlPointAtIndex(p+2); - Vector2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt); + Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt); #if CC_ENABLE_STACKABLE_ACTIONS // Support for stacked actions Node *node = _target; - Vector2 diff = node->getPosition() - _previousPosition; + Vec2 diff = node->getPosition() - _previousPosition; if( diff.x !=0 || diff.y != 0 ) { _accumulatedDiff = _accumulatedDiff + diff; newPos = newPos + _accumulatedDiff; @@ -327,7 +327,7 @@ void CardinalSplineTo::update(float time) this->updatePosition(newPos); } -void CardinalSplineTo::updatePosition(cocos2d::Vector2 &newPos) +void CardinalSplineTo::updatePosition(cocos2d::Vec2 &newPos) { _target->setPosition(newPos); _previousPosition = newPos; @@ -365,9 +365,9 @@ CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0) { } -void CardinalSplineBy::updatePosition(cocos2d::Vector2 &newPos) +void CardinalSplineBy::updatePosition(cocos2d::Vec2 &newPos) { - Vector2 p = newPos + _startPosition; + Vec2 p = newPos + _startPosition; _target->setPosition(p); _previousPosition = p; } @@ -379,11 +379,11 @@ CardinalSplineBy* CardinalSplineBy::reverse() const // // convert "absolutes" to "diffs" // - Vector2 p = copyConfig->getControlPointAtIndex(0); + Vec2 p = copyConfig->getControlPointAtIndex(0); for (ssize_t i = 1; i < copyConfig->count(); ++i) { - Vector2 current = copyConfig->getControlPointAtIndex(i); - Vector2 diff = current - p; + Vec2 current = copyConfig->getControlPointAtIndex(i); + Vec2 diff = current - p; copyConfig->replaceControlPoint(diff, i); p = current; @@ -404,9 +404,9 @@ CardinalSplineBy* CardinalSplineBy::reverse() const for (ssize_t i = 1; i < pReverse->count(); ++i) { - Vector2 current = pReverse->getControlPointAtIndex(i); + Vec2 current = pReverse->getControlPointAtIndex(i); current = -current; - Vector2 abs = current + p; + Vec2 abs = current + p; pReverse->replaceControlPoint(abs, i); p = abs; @@ -524,11 +524,11 @@ CatmullRomBy* CatmullRomBy::reverse() const // // convert "absolutes" to "diffs" // - Vector2 p = copyConfig->getControlPointAtIndex(0); + Vec2 p = copyConfig->getControlPointAtIndex(0); for (ssize_t i = 1; i < copyConfig->count(); ++i) { - Vector2 current = copyConfig->getControlPointAtIndex(i); - Vector2 diff = current - p; + Vec2 current = copyConfig->getControlPointAtIndex(i); + Vec2 diff = current - p; copyConfig->replaceControlPoint(diff, i); p = current; @@ -549,9 +549,9 @@ CatmullRomBy* CatmullRomBy::reverse() const for (ssize_t i = 1; i < reverse->count(); ++i) { - Vector2 current = reverse->getControlPointAtIndex(i); + Vec2 current = reverse->getControlPointAtIndex(i); current = -current; - Vector2 abs = current + p; + Vec2 abs = current + p; reverse->replaceControlPoint(abs, i); p = abs; diff --git a/cocos/2d/CCActionCatmullRom.h b/cocos/2d/CCActionCatmullRom.h index ec77670cac..bd19201628 100644 --- a/cocos/2d/CCActionCatmullRom.h +++ b/cocos/2d/CCActionCatmullRom.h @@ -80,22 +80,22 @@ public: /** appends a control point * @js NA */ - void addControlPoint(Vector2 controlPoint); + void addControlPoint(Vec2 controlPoint); /** inserts a controlPoint at index * @js NA */ - void insertControlPoint(Vector2 &controlPoint, ssize_t index); + void insertControlPoint(Vec2 &controlPoint, ssize_t index); /** replaces an existing controlPoint at index * @js NA */ - void replaceControlPoint(Vector2 &controlPoint, ssize_t index); + void replaceControlPoint(Vec2 &controlPoint, ssize_t index); /** get the value of a controlPoint at a given index * @js NA */ - Vector2 getControlPointAtIndex(ssize_t index); + Vec2 getControlPointAtIndex(ssize_t index); /** deletes a control point at a given index * @js NA @@ -124,14 +124,14 @@ public: /** * @js NA */ - const std::vector* getControlPoints() const; + const std::vector* getControlPoints() const; /** * @js NA */ - void setControlPoints(std::vector *controlPoints); + void setControlPoints(std::vector *controlPoints); private: /** Array that contains the control points */ - std::vector *_controlPoints; + std::vector *_controlPoints; }; /** Cardinal Spline path. @@ -164,7 +164,7 @@ public: /** initializes the action with a duration and an array of points */ bool initWithDuration(float duration, PointArray* points, float tension); - virtual void updatePosition(Vector2 &newPos); + virtual void updatePosition(Vec2 &newPos); inline PointArray* getPoints() { return _points; } /** @@ -189,8 +189,8 @@ protected: PointArray *_points; float _deltaT; float _tension; - Vector2 _previousPosition; - Vector2 _accumulatedDiff; + Vec2 _previousPosition; + Vec2 _accumulatedDiff; }; /** Cardinal Spline path. @@ -214,12 +214,12 @@ public: // Overrides virtual void startWithTarget(Node *target) override; - virtual void updatePosition(Vector2 &newPos) override; + virtual void updatePosition(Vec2 &newPos) override; virtual CardinalSplineBy *clone() const override; virtual CardinalSplineBy* reverse() const override; protected: - Vector2 _startPosition; + Vec2 _startPosition; }; /** An action that moves the target with a CatmullRom curve to a destination point. @@ -275,7 +275,7 @@ public: }; /** Returns the Cardinal Spline position for a given set of control points, tension and time */ -extern CC_DLL Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t); +extern CC_DLL Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, float t); // end of actions group /// @} diff --git a/cocos/2d/CCActionGrid.cpp b/cocos/2d/CCActionGrid.cpp index 23d0edc6b8..437cbd6178 100644 --- a/cocos/2d/CCActionGrid.cpp +++ b/cocos/2d/CCActionGrid.cpp @@ -103,19 +103,19 @@ GridBase* Grid3DAction::getGrid() return Grid3D::create(_gridSize); } -Vector3 Grid3DAction::getVertex(const Vector2& position) const +Vec3 Grid3DAction::getVertex(const Vec2& position) const { Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); return g->getVertex(position); } -Vector3 Grid3DAction::getOriginalVertex(const Vector2& position) const +Vec3 Grid3DAction::getOriginalVertex(const Vec2& position) const { Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); return g->getOriginalVertex(position); } -void Grid3DAction::setVertex(const Vector2& position, const Vector3& vertex) +void Grid3DAction::setVertex(const Vec2& position, const Vec3& vertex) { Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); g->setVertex(position, vertex); @@ -128,19 +128,19 @@ GridBase* TiledGrid3DAction::getGrid(void) return TiledGrid3D::create(_gridSize); } -Quad3 TiledGrid3DAction::getTile(const Vector2& pos) const +Quad3 TiledGrid3DAction::getTile(const Vec2& pos) const { TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->getTile(pos); } -Quad3 TiledGrid3DAction::getOriginalTile(const Vector2& pos) const +Quad3 TiledGrid3DAction::getOriginalTile(const Vec2& pos) const { TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->getOriginalTile(pos); } -void TiledGrid3DAction::setTile(const Vector2& pos, const Quad3& coords) +void TiledGrid3DAction::setTile(const Vec2& pos, const Quad3& coords) { TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->setTile(pos, coords); diff --git a/cocos/2d/CCActionGrid.h b/cocos/2d/CCActionGrid.h index d0b9c109e1..3630f1b973 100644 --- a/cocos/2d/CCActionGrid.h +++ b/cocos/2d/CCActionGrid.h @@ -82,31 +82,31 @@ public: * @js NA * @lua NA */ - Vector3 getVertex(const Vector2& position) const; + Vec3 getVertex(const Vec2& position) const; /** @deprecated Use getVertex() instead * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE inline Vector3 vertex(const Vector2& position) { return getVertex(position); } + CC_DEPRECATED_ATTRIBUTE inline Vec3 vertex(const Vec2& position) { return getVertex(position); } /** returns the non-transformed vertex than belongs to certain position in the grid * @js NA * @lua NA */ - Vector3 getOriginalVertex(const Vector2& position) const; + Vec3 getOriginalVertex(const Vec2& position) const; /** @deprecated Use getOriginalVertex() instead * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE inline Vector3 originalVertex(const Vector2& position) { return getOriginalVertex(position); } + CC_DEPRECATED_ATTRIBUTE inline Vec3 originalVertex(const Vec2& position) { return getOriginalVertex(position); } /** sets a new vertex to a certain position of the grid * @js NA * @lua NA */ - void setVertex(const Vector2& position, const Vector3& vertex); + void setVertex(const Vec2& position, const Vec3& vertex); // Overrides virtual Grid3DAction * clone() const override = 0; @@ -126,31 +126,31 @@ public: * @js NA * @lua NA */ - Quad3 getTile(const Vector2& position) const; + Quad3 getTile(const Vec2& position) const; /** @deprecated Use getTile() instead * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vector2& position) { return getTile(position); } + CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& position) { return getTile(position); } /** returns the non-transformed tile that belongs to a certain position of the grid * @js NA * @lua NA */ - Quad3 getOriginalTile(const Vector2& position) const; + Quad3 getOriginalTile(const Vec2& position) const; /** @deprecated Use getOriginalTile() instead * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vector2& position) { return getOriginalTile(position); } + CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& position) { return getOriginalTile(position); } /** sets a new tile to a certain position of the grid * @js NA * @lua NA */ - void setTile(const Vector2& position, const Quad3& coords); + void setTile(const Vec2& position, const Quad3& coords); /** returns the grid */ virtual GridBase* getGrid(); diff --git a/cocos/2d/CCActionGrid3D.cpp b/cocos/2d/CCActionGrid3D.cpp index eab703c837..bed68e66aa 100644 --- a/cocos/2d/CCActionGrid3D.cpp +++ b/cocos/2d/CCActionGrid3D.cpp @@ -79,10 +79,10 @@ void Waves3D::update(float time) { for (j = 0; j < _gridSize.height + 1; ++j) { - Vector3 v = getOriginalVertex(Vector2(i ,j)); + Vec3 v = getOriginalVertex(Vec2(i ,j)); v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate); //CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate)); - setVertex(Vector2(i, j), v); + setVertex(Vec2(i, j), v); } } } @@ -142,32 +142,32 @@ void FlipX3D::update(float time) angle = angle / 2.0f; // x calculates degrees from 0 to 90 float mx = cosf(angle); - Vector3 v0, v1, v, diff; + Vec3 v0, v1, v, diff; - v0 = getOriginalVertex(Vector2(1, 1)); - v1 = getOriginalVertex(Vector2(0, 0)); + v0 = getOriginalVertex(Vec2(1, 1)); + v1 = getOriginalVertex(Vec2(0, 0)); float x0 = v0.x; float x1 = v1.x; float x; - Vector2 a, b, c, d; + Vec2 a, b, c, d; if ( x0 > x1 ) { // Normal Grid - a = Vector2(0,0); - b = Vector2(0,1); - c = Vector2(1,0); - d = Vector2(1,1); + a = Vec2(0,0); + b = Vec2(0,1); + c = Vec2(1,0); + d = Vec2(1,1); x = x0; } else { // Reversed Grid - c = Vector2(0,0); - d = Vector2(0,1); - a = Vector2(1,0); - b = Vector2(1,1); + c = Vec2(0,0); + d = Vec2(0,1); + a = Vec2(1,0); + b = Vec2(1,1); x = x1; } @@ -236,32 +236,32 @@ void FlipY3D::update(float time) angle = angle / 2.0f; // x calculates degrees from 0 to 90 float my = cosf(angle); - Vector3 v0, v1, v, diff; + Vec3 v0, v1, v, diff; - v0 = getOriginalVertex(Vector2(1, 1)); - v1 = getOriginalVertex(Vector2(0, 0)); + v0 = getOriginalVertex(Vec2(1, 1)); + v1 = getOriginalVertex(Vec2(0, 0)); float y0 = v0.y; float y1 = v1.y; float y; - Vector2 a, b, c, d; + Vec2 a, b, c, d; if (y0 > y1) { // Normal Grid - a = Vector2(0,0); - b = Vector2(0,1); - c = Vector2(1,0); - d = Vector2(1,1); + a = Vec2(0,0); + b = Vec2(0,1); + c = Vec2(1,0); + d = Vec2(1,1); y = y0; } else { // Reversed Grid - b = Vector2(0,0); - a = Vector2(0,1); - d = Vector2(1,0); - c = Vector2(1,1); + b = Vec2(0,0); + a = Vec2(0,1); + d = Vec2(1,0); + c = Vec2(1,1); y = y1; } @@ -296,7 +296,7 @@ void FlipY3D::update(float time) // implementation of Lens3D -Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& position, float radius) +Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vec2& position, float radius) { Lens3D *action = new Lens3D(); @@ -315,11 +315,11 @@ Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& posi return action; } -bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius) +bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius) { if (Grid3DAction::initWithDuration(duration, gridSize)) { - _position = Vector2(-1, -1); + _position = Vec2(-1, -1); setPosition(position); _radius = radius; _lensEffect = 0.7f; @@ -341,7 +341,7 @@ Lens3D* Lens3D::clone() const return a; } -void Lens3D::setPosition(const Vector2& pos) +void Lens3D::setPosition(const Vec2& pos) { if( !pos.equals(_position)) { @@ -361,8 +361,8 @@ void Lens3D::update(float time) { for (j = 0; j < _gridSize.height + 1; ++j) { - Vector3 v = getOriginalVertex(Vector2(i, j)); - Vector2 vect = _position - Vector2(v.x, v.y); + Vec3 v = getOriginalVertex(Vec2(i, j)); + Vec2 vect = _position - Vec2(v.x, v.y); float r = vect.getLength(); if (r < _radius) @@ -380,12 +380,12 @@ void Lens3D::update(float time) if (vect.getLength() > 0) { vect.normalize(); - Vector2 new_vect = vect * new_r; + Vec2 new_vect = vect * new_r; v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect; } } - setVertex(Vector2(i, j), v); + setVertex(Vec2(i, j), v); } } @@ -395,7 +395,7 @@ void Lens3D::update(float time) // implementation of Ripple3D -Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude) +Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude) { Ripple3D *action = new Ripple3D(); @@ -414,7 +414,7 @@ Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2& return action; } -bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude) +bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { @@ -430,7 +430,7 @@ bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vect return false; } -void Ripple3D::setPosition(const Vector2& position) +void Ripple3D::setPosition(const Vec2& position) { _position = position; } @@ -453,8 +453,8 @@ void Ripple3D::update(float time) { for (j = 0; j < (_gridSize.height+1); ++j) { - Vector3 v = getOriginalVertex(Vector2(i, j)); - Vector2 vect = _position - Vector2(v.x,v.y); + Vec3 v = getOriginalVertex(Vec2(i, j)); + Vec2 vect = _position - Vec2(v.x,v.y); float r = vect.getLength(); if (r < _radius) @@ -464,7 +464,7 @@ void Ripple3D::update(float time) v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate); } - setVertex(Vector2(i, j), v); + setVertex(Vec2(i, j), v); } } } @@ -521,7 +521,7 @@ void Shaky3D::update(float time) { for (j = 0; j < (_gridSize.height+1); ++j) { - Vector3 v = getOriginalVertex(Vector2(i ,j)); + Vec3 v = getOriginalVertex(Vec2(i ,j)); v.x += (rand() % (_randrange*2)) - _randrange; v.y += (rand() % (_randrange*2)) - _randrange; if (_shakeZ) @@ -529,7 +529,7 @@ void Shaky3D::update(float time) v.z += (rand() % (_randrange*2)) - _randrange; } - setVertex(Vector2(i, j), v); + setVertex(Vec2(i, j), v); } } } @@ -586,10 +586,10 @@ void Liquid::update(float time) { for (j = 1; j < _gridSize.height; ++j) { - Vector3 v = getOriginalVertex(Vector2(i, j)); + Vec3 v = getOriginalVertex(Vec2(i, j)); v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate)); - setVertex(Vector2(i, j), v); + setVertex(Vec2(i, j), v); } } } @@ -648,7 +648,7 @@ void Waves::update(float time) { for (j = 0; j < _gridSize.height + 1; ++j) { - Vector3 v = getOriginalVertex(Vector2(i, j)); + Vec3 v = getOriginalVertex(Vec2(i, j)); if (_vertical) { @@ -660,14 +660,14 @@ void Waves::update(float time) v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); } - setVertex(Vector2(i, j), v); + setVertex(Vec2(i, j), v); } } } // implementation of Twirl -Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude) +Twirl* Twirl::create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude) { Twirl *action = new Twirl(); @@ -686,7 +686,7 @@ Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, uns return action; } -bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude) +bool Twirl::initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { @@ -701,7 +701,7 @@ bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 posit return false; } -void Twirl::setPosition(const Vector2& position) +void Twirl::setPosition(const Vec2& position) { _position = position; } @@ -718,28 +718,28 @@ Twirl *Twirl::clone() const void Twirl::update(float time) { int i, j; - Vector2 c = _position; + Vec2 c = _position; for (i = 0; i < (_gridSize.width+1); ++i) { for (j = 0; j < (_gridSize.height+1); ++j) { - Vector3 v = getOriginalVertex(Vector2(i ,j)); + Vec3 v = getOriginalVertex(Vec2(i ,j)); - Vector2 avg = Vector2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f)); + Vec2 avg = Vec2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f)); float r = avg.getLength(); float amp = 0.1f * _amplitude * _amplitudeRate; float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp; - Vector2 d = Vector2( + Vec2 d = Vec2( sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x), cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x)); v.x = c.x + d.x; v.y = c.y + d.y; - setVertex(Vector2(i ,j), v); + setVertex(Vec2(i ,j), v); } } } diff --git a/cocos/2d/CCActionGrid3D.h b/cocos/2d/CCActionGrid3D.h index 375f4fd0b8..89c187cc58 100644 --- a/cocos/2d/CCActionGrid3D.h +++ b/cocos/2d/CCActionGrid3D.h @@ -120,7 +120,7 @@ class CC_DLL Lens3D : public Grid3DAction { public: /** creates the action with center position, radius, a grid size and duration */ - static Lens3D* create(float duration, const Size& gridSize, const Vector2& position, float radius); + static Lens3D* create(float duration, const Size& gridSize, const Vec2& position, float radius); /** Get lens center position */ inline float getLensEffect() const { return _lensEffect; } @@ -129,8 +129,8 @@ public: /** Set whether lens is concave */ inline void setConcave(bool concave) { _concave = concave; } - inline const Vector2& getPosition() const { return _position; } - void setPosition(const Vector2& position); + inline const Vec2& getPosition() const { return _position; } + void setPosition(const Vec2& position); // Overrides virtual Lens3D* clone() const override; @@ -141,11 +141,11 @@ CC_CONSTRUCTOR_ACCESS: virtual ~Lens3D() {} /** initializes the action with center position, radius, a grid size and duration */ - bool initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius); + bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius); protected: /* lens center position */ - Vector2 _position; + Vec2 _position; float _radius; /** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */ float _lensEffect; @@ -163,12 +163,12 @@ class CC_DLL Ripple3D : public Grid3DAction { public: /** creates the action with radius, number of waves, amplitude, a grid size and duration */ - static Ripple3D* create(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude); + static Ripple3D* create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude); /** get center position */ - inline const Vector2& getPosition() const { return _position; } + inline const Vec2& getPosition() const { return _position; } /** set center position */ - void setPosition(const Vector2& position); + void setPosition(const Vec2& position); inline float getAmplitude() const { return _amplitude; } inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; } @@ -185,11 +185,11 @@ CC_CONSTRUCTOR_ACCESS: virtual ~Ripple3D() {} /** initializes the action with radius, number of waves, amplitude, a grid size and duration */ - bool initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude); + bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude); protected: /* center position */ - Vector2 _position; + Vec2 _position; float _radius; unsigned int _waves; float _amplitude; @@ -298,12 +298,12 @@ class CC_DLL Twirl : public Grid3DAction { public: /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ - static Twirl* create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude); + static Twirl* create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude); /** get twirl center */ - inline const Vector2& getPosition() const { return _position; } + inline const Vec2& getPosition() const { return _position; } /** set twirl center */ - void setPosition(const Vector2& position); + void setPosition(const Vec2& position); inline float getAmplitude() const { return _amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; } @@ -321,11 +321,11 @@ CC_CONSTRUCTOR_ACCESS: virtual ~Twirl() {} /** initializes the action with center position, number of twirls, amplitude, a grid size and duration */ - bool initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude); + bool initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude); protected: /* twirl center */ - Vector2 _position; + Vec2 _position; unsigned int _twirls; float _amplitude; float _amplitudeRate; diff --git a/cocos/2d/CCActionInstant.cpp b/cocos/2d/CCActionInstant.cpp index 0db73cf380..6a2a5e4a0b 100644 --- a/cocos/2d/CCActionInstant.cpp +++ b/cocos/2d/CCActionInstant.cpp @@ -278,7 +278,7 @@ FlipY * FlipY::clone() const // Place // -Place* Place::create(const Vector2& pos) +Place* Place::create(const Vec2& pos) { Place *ret = new Place(); @@ -291,7 +291,7 @@ Place* Place::create(const Vector2& pos) return nullptr; } -bool Place::initWithPosition(const Vector2& pos) { +bool Place::initWithPosition(const Vec2& pos) { _position = pos; return true; } diff --git a/cocos/2d/CCActionInstant.h b/cocos/2d/CCActionInstant.h index 1de17f283d..c74d6f0378 100644 --- a/cocos/2d/CCActionInstant.h +++ b/cocos/2d/CCActionInstant.h @@ -228,7 +228,7 @@ class CC_DLL Place : public ActionInstant // public: /** creates a Place action with a position */ - static Place * create(const Vector2& pos); + static Place * create(const Vec2& pos); // // Overrides @@ -242,10 +242,10 @@ CC_CONSTRUCTOR_ACCESS: virtual ~Place(){} /** Initializes a Place action with a position */ - bool initWithPosition(const Vector2& pos); + bool initWithPosition(const Vec2& pos); protected: - Vector2 _position; + Vec2 _position; private: CC_DISALLOW_COPY_AND_ASSIGN(Place); diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 3bade7d8de..b51b5afc92 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -859,7 +859,7 @@ RotateBy* RotateBy::create(float duration, float deltaAngleX, float deltaAngleY) return rotateBy; } -RotateBy* RotateBy::create(float duration, const Vector3& deltaAngle3D) +RotateBy* RotateBy::create(float duration, const Vec3& deltaAngle3D) { RotateBy *rotateBy = new RotateBy(); rotateBy->initWithDuration(duration, deltaAngle3D); @@ -896,7 +896,7 @@ bool RotateBy::initWithDuration(float duration, float deltaAngleX, float deltaAn return false; } -bool RotateBy::initWithDuration(float duration, const Vector3& deltaAngle3D) +bool RotateBy::initWithDuration(float duration, const Vec3& deltaAngle3D) { if (ActionInterval::initWithDuration(duration)) { @@ -942,7 +942,7 @@ void RotateBy::update(float time) { if(_is3D) { - Vector3 v; + Vec3 v; v.x = _startAngle3D.x + _angle3D.x * time; v.y = _startAngle3D.y + _angle3D.y * time; v.z = _startAngle3D.z + _angle3D.z * time; @@ -960,7 +960,7 @@ RotateBy* RotateBy::reverse() const { if(_is3D) { - Vector3 v; + Vec3 v; v.x = - _angle3D.x; v.y = - _angle3D.y; v.z = - _angle3D.z; @@ -973,7 +973,7 @@ RotateBy* RotateBy::reverse() const // MoveBy // -MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition) +MoveBy* MoveBy::create(float duration, const Vec2& deltaPosition) { MoveBy *ret = new MoveBy(); ret->initWithDuration(duration, deltaPosition); @@ -982,7 +982,7 @@ MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition) return ret; } -bool MoveBy::initWithDuration(float duration, const Vector2& deltaPosition) +bool MoveBy::initWithDuration(float duration, const Vec2& deltaPosition) { if (ActionInterval::initWithDuration(duration)) { @@ -1010,7 +1010,7 @@ void MoveBy::startWithTarget(Node *target) MoveBy* MoveBy::reverse() const { - return MoveBy::create(_duration, Vector2( -_positionDelta.x, -_positionDelta.y)); + return MoveBy::create(_duration, Vec2( -_positionDelta.x, -_positionDelta.y)); } @@ -1019,10 +1019,10 @@ void MoveBy::update(float t) if (_target) { #if CC_ENABLE_STACKABLE_ACTIONS - Vector2 currentPos = _target->getPosition(); - Vector2 diff = currentPos - _previousPosition; + Vec2 currentPos = _target->getPosition(); + Vec2 diff = currentPos - _previousPosition; _startPosition = _startPosition + diff; - Vector2 newPos = _startPosition + (_positionDelta * t); + Vec2 newPos = _startPosition + (_positionDelta * t); _target->setPosition(newPos); _previousPosition = newPos; #else @@ -1035,7 +1035,7 @@ void MoveBy::update(float t) // MoveTo // -MoveTo* MoveTo::create(float duration, const Vector2& position) +MoveTo* MoveTo::create(float duration, const Vec2& position) { MoveTo *ret = new MoveTo(); ret->initWithDuration(duration, position); @@ -1044,7 +1044,7 @@ MoveTo* MoveTo::create(float duration, const Vector2& position) return ret; } -bool MoveTo::initWithDuration(float duration, const Vector2& position) +bool MoveTo::initWithDuration(float duration, const Vec2& position) { if (ActionInterval::initWithDuration(duration)) { @@ -1252,7 +1252,7 @@ SkewBy* SkewBy::reverse() const // JumpBy // -JumpBy* JumpBy::create(float duration, const Vector2& position, float height, int jumps) +JumpBy* JumpBy::create(float duration, const Vec2& position, float height, int jumps) { JumpBy *jumpBy = new JumpBy(); jumpBy->initWithDuration(duration, position, height, jumps); @@ -1261,7 +1261,7 @@ JumpBy* JumpBy::create(float duration, const Vector2& position, float height, in return jumpBy; } -bool JumpBy::initWithDuration(float duration, const Vector2& position, float height, int jumps) +bool JumpBy::initWithDuration(float duration, const Vec2& position, float height, int jumps) { CCASSERT(jumps>=0, "Number of jumps must be >= 0"); @@ -1303,24 +1303,24 @@ void JumpBy::update(float t) float x = _delta.x * t; #if CC_ENABLE_STACKABLE_ACTIONS - Vector2 currentPos = _target->getPosition(); + Vec2 currentPos = _target->getPosition(); - Vector2 diff = currentPos - _previousPos; + Vec2 diff = currentPos - _previousPos; _startPosition = diff + _startPosition; - Vector2 newPos = _startPosition + Vector2(x,y); + Vec2 newPos = _startPosition + Vec2(x,y); _target->setPosition(newPos); _previousPos = newPos; #else - _target->setPosition(_startPosition + Vector2(x,y)); + _target->setPosition(_startPosition + Vec2(x,y)); #endif // !CC_ENABLE_STACKABLE_ACTIONS } } JumpBy* JumpBy::reverse() const { - return JumpBy::create(_duration, Vector2(-_delta.x, -_delta.y), + return JumpBy::create(_duration, Vec2(-_delta.x, -_delta.y), _height, _jumps); } @@ -1328,7 +1328,7 @@ JumpBy* JumpBy::reverse() const // JumpTo // -JumpTo* JumpTo::create(float duration, const Vector2& position, float height, int jumps) +JumpTo* JumpTo::create(float duration, const Vec2& position, float height, int jumps) { JumpTo *jumpTo = new JumpTo(); jumpTo->initWithDuration(duration, position, height, jumps); @@ -1355,7 +1355,7 @@ JumpTo* JumpTo::reverse() const void JumpTo::startWithTarget(Node *target) { JumpBy::startWithTarget(target); - _delta = Vector2(_delta.x - _startPosition.x, _delta.y - _startPosition.y); + _delta = Vec2(_delta.x - _startPosition.x, _delta.y - _startPosition.y); } // Bezier cubic formula: @@ -1427,16 +1427,16 @@ void BezierBy::update(float time) float y = bezierat(ya, yb, yc, yd, time); #if CC_ENABLE_STACKABLE_ACTIONS - Vector2 currentPos = _target->getPosition(); - Vector2 diff = currentPos - _previousPosition; + Vec2 currentPos = _target->getPosition(); + Vec2 diff = currentPos - _previousPosition; _startPosition = _startPosition + diff; - Vector2 newPos = _startPosition + Vector2(x,y); + Vec2 newPos = _startPosition + Vec2(x,y); _target->setPosition(newPos); _previousPosition = newPos; #else - _target->setPosition( _startPosition + Vector2(x,y)); + _target->setPosition( _startPosition + Vec2(x,y)); #endif // !CC_ENABLE_STACKABLE_ACTIONS } } diff --git a/cocos/2d/CCActionInterval.h b/cocos/2d/CCActionInterval.h index cc0f22f4ec..564c24c4d5 100644 --- a/cocos/2d/CCActionInterval.h +++ b/cocos/2d/CCActionInterval.h @@ -370,7 +370,7 @@ public: /** creates the action */ static RotateBy* create(float duration, float deltaAngle); static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y); - static RotateBy* create(float duration, const Vector3& deltaAngle3D); + static RotateBy* create(float duration, const Vec3& deltaAngle3D); // // Override @@ -387,7 +387,7 @@ CC_CONSTRUCTOR_ACCESS: /** initializes the action */ bool initWithDuration(float duration, float deltaAngle); bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y); - bool initWithDuration(float duration, const Vector3& deltaAngle3D); + bool initWithDuration(float duration, const Vec3& deltaAngle3D); protected: float _angleZ_X; @@ -396,8 +396,8 @@ protected: float _startAngleZ_Y; bool _is3D; - Vector3 _angle3D; - Vector3 _startAngle3D; + Vec3 _angle3D; + Vec3 _startAngle3D; private: CC_DISALLOW_COPY_AND_ASSIGN(RotateBy); @@ -413,7 +413,7 @@ class CC_DLL MoveBy : public ActionInterval { public: /** creates the action */ - static MoveBy* create(float duration, const Vector2& deltaPosition); + static MoveBy* create(float duration, const Vec2& deltaPosition); // // Overrides @@ -428,12 +428,12 @@ CC_CONSTRUCTOR_ACCESS: virtual ~MoveBy() {} /** initializes the action */ - bool initWithDuration(float duration, const Vector2& deltaPosition); + bool initWithDuration(float duration, const Vec2& deltaPosition); protected: - Vector2 _positionDelta; - Vector2 _startPosition; - Vector2 _previousPosition; + Vec2 _positionDelta; + Vec2 _startPosition; + Vec2 _previousPosition; private: CC_DISALLOW_COPY_AND_ASSIGN(MoveBy); @@ -448,7 +448,7 @@ class CC_DLL MoveTo : public MoveBy { public: /** creates the action */ - static MoveTo* create(float duration, const Vector2& position); + static MoveTo* create(float duration, const Vec2& position); // // Overrides @@ -461,10 +461,10 @@ CC_CONSTRUCTOR_ACCESS: virtual ~MoveTo() {} /** initializes the action */ - bool initWithDuration(float duration, const Vector2& position); + bool initWithDuration(float duration, const Vec2& position); protected: - Vector2 _endPosition; + Vec2 _endPosition; private: CC_DISALLOW_COPY_AND_ASSIGN(MoveTo); @@ -539,7 +539,7 @@ class CC_DLL JumpBy : public ActionInterval { public: /** creates the action */ - static JumpBy* create(float duration, const Vector2& position, float height, int jumps); + static JumpBy* create(float duration, const Vec2& position, float height, int jumps); // // Overrides @@ -554,14 +554,14 @@ CC_CONSTRUCTOR_ACCESS: virtual ~JumpBy() {} /** initializes the action */ - bool initWithDuration(float duration, const Vector2& position, float height, int jumps); + bool initWithDuration(float duration, const Vec2& position, float height, int jumps); protected: - Vector2 _startPosition; - Vector2 _delta; + Vec2 _startPosition; + Vec2 _delta; float _height; int _jumps; - Vector2 _previousPos; + Vec2 _previousPos; private: CC_DISALLOW_COPY_AND_ASSIGN(JumpBy); @@ -573,7 +573,7 @@ class CC_DLL JumpTo : public JumpBy { public: /** creates the action */ - static JumpTo* create(float duration, const Vector2& position, float height, int jumps); + static JumpTo* create(float duration, const Vec2& position, float height, int jumps); // // Override @@ -592,11 +592,11 @@ private: */ typedef struct _ccBezierConfig { //! end position of the bezier - Vector2 endPosition; + Vec2 endPosition; //! Bezier control point 1 - Vector2 controlPoint_1; + Vec2 controlPoint_1; //! Bezier control point 2 - Vector2 controlPoint_2; + Vec2 controlPoint_2; } ccBezierConfig; /** @brief An action that moves the target with a cubic Bezier curve by a certain distance. @@ -630,8 +630,8 @@ CC_CONSTRUCTOR_ACCESS: protected: ccBezierConfig _config; - Vector2 _startPosition; - Vector2 _previousPosition; + Vec2 _startPosition; + Vec2 _previousPosition; private: CC_DISALLOW_COPY_AND_ASSIGN(BezierBy); diff --git a/cocos/2d/CCActionPageTurn3D.cpp b/cocos/2d/CCActionPageTurn3D.cpp index 82dc9d0f38..5843efcf68 100644 --- a/cocos/2d/CCActionPageTurn3D.cpp +++ b/cocos/2d/CCActionPageTurn3D.cpp @@ -76,7 +76,7 @@ void PageTurn3D::update(float time) for (int j = 0; j <= _gridSize.height; ++j) { // Get original vertex - Vector3 p = getOriginalVertex(Vector2(i ,j)); + Vec3 p = getOriginalVertex(Vec2(i ,j)); float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay))); float r = R * sinTheta; @@ -111,7 +111,7 @@ void PageTurn3D::update(float time) } // Set new coords - setVertex(Vector2(i, j), p); + setVertex(Vec2(i, j), p); } } diff --git a/cocos/2d/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp index 910e17a870..a50cf8eba5 100644 --- a/cocos/2d/CCActionTiledGrid.cpp +++ b/cocos/2d/CCActionTiledGrid.cpp @@ -34,8 +34,8 @@ NS_CC_BEGIN struct Tile { - Vector2 position; - Vector2 startPosition; + Vec2 position; + Vec2 startPosition; Size delta; }; @@ -91,7 +91,7 @@ void ShakyTiles3D::update(float time) { for (j = 0; j < _gridSize.height; ++j) { - Quad3 coords = getOriginalTile(Vector2(i, j)); + Quad3 coords = getOriginalTile(Vec2(i, j)); // X coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; @@ -113,7 +113,7 @@ void ShakyTiles3D::update(float time) coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; } - setTile(Vector2(i, j), coords); + setTile(Vec2(i, j), coords); } } } @@ -173,7 +173,7 @@ void ShatteredTiles3D::update(float time) { for (j = 0; j < _gridSize.height; ++j) { - Quad3 coords = getOriginalTile(Vector2(i ,j)); + Quad3 coords = getOriginalTile(Vec2(i ,j)); // X coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; @@ -195,7 +195,7 @@ void ShatteredTiles3D::update(float time) coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; } - setTile(Vector2(i, j), coords); + setTile(Vec2(i, j), coords); } } @@ -267,7 +267,7 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len) Size ShuffleTiles::getDelta(const Size& pos) const { - Vector2 pos2; + Vec2 pos2; unsigned int idx = pos.width * _gridSize.height + pos.height; @@ -277,11 +277,11 @@ Size ShuffleTiles::getDelta(const Size& pos) const return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height)); } -void ShuffleTiles::placeTile(const Vector2& pos, Tile *t) +void ShuffleTiles::placeTile(const Vec2& pos, Tile *t) { Quad3 coords = getOriginalTile(pos); - Vector2 step = _gridNodeTarget->getGrid()->getStep(); + Vec2 step = _gridNodeTarget->getGrid()->getStep(); coords.bl.x += (int)(t->position.x * step.x); coords.bl.y += (int)(t->position.y * step.y); @@ -329,8 +329,8 @@ void ShuffleTiles::startWithTarget(Node *target) { for (j = 0; j < _gridSize.height; ++j) { - tileArray->position = Vector2((float)i, (float)j); - tileArray->startPosition = Vector2((float)i, (float)j); + tileArray->position = Vec2((float)i, (float)j); + tileArray->startPosition = Vec2((float)i, (float)j); tileArray->delta = getDelta(Size(i, j)); ++tileArray; } @@ -347,8 +347,8 @@ void ShuffleTiles::update(float time) { for (j = 0; j < _gridSize.height; ++j) { - tileArray->position = Vector2((float)tileArray->delta.width, (float)tileArray->delta.height) * time; - placeTile(Vector2(i, j), tileArray); + tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time; + placeTile(Vec2(i, j), tileArray); ++tileArray; } } @@ -386,7 +386,7 @@ FadeOutTRTiles* FadeOutTRTiles::clone() const float FadeOutTRTiles::testFunc(const Size& pos, float time) { - Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * time; + Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time; if ((n.x + n.y) == 0.0f) { return 1.0f; @@ -395,22 +395,22 @@ float FadeOutTRTiles::testFunc(const Size& pos, float time) return powf((pos.width + pos.height) / (n.x + n.y), 6); } -void FadeOutTRTiles::turnOnTile(const Vector2& pos) +void FadeOutTRTiles::turnOnTile(const Vec2& pos) { setTile(pos, getOriginalTile(pos)); } -void FadeOutTRTiles::turnOffTile(const Vector2& pos) +void FadeOutTRTiles::turnOffTile(const Vec2& pos) { Quad3 coords; memset(&coords, 0, sizeof(Quad3)); setTile(pos, coords); } -void FadeOutTRTiles::transformTile(const Vector2& pos, float distance) +void FadeOutTRTiles::transformTile(const Vec2& pos, float distance) { Quad3 coords = getOriginalTile(pos); - Vector2 step = _gridNodeTarget->getGrid()->getStep(); + Vec2 step = _gridNodeTarget->getGrid()->getStep(); coords.bl.x += (step.x / 2) * (1.0f - distance); coords.bl.y += (step.y / 2) * (1.0f - distance); @@ -438,15 +438,15 @@ void FadeOutTRTiles::update(float time) float distance = testFunc(Size(i, j), time); if ( distance == 0 ) { - turnOffTile(Vector2(i, j)); + turnOffTile(Vec2(i, j)); } else if (distance < 1) { - transformTile(Vector2(i, j), distance); + transformTile(Vec2(i, j), distance); } else { - turnOnTile(Vector2(i, j)); + turnOnTile(Vec2(i, j)); } } } @@ -484,7 +484,7 @@ FadeOutBLTiles* FadeOutBLTiles::clone() const float FadeOutBLTiles::testFunc(const Size& pos, float time) { - Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); + Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); if ((pos.width + pos.height) == 0) { return 1.0f; @@ -525,7 +525,7 @@ FadeOutUpTiles* FadeOutUpTiles::clone() const float FadeOutUpTiles::testFunc(const Size& pos, float time) { - Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * time; + Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time; if (n.y == 0.0f) { return 1.0f; @@ -534,10 +534,10 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time) return powf(pos.height / n.y, 6); } -void FadeOutUpTiles::transformTile(const Vector2& pos, float distance) +void FadeOutUpTiles::transformTile(const Vec2& pos, float distance) { Quad3 coords = getOriginalTile(pos); - Vector2 step = _gridNodeTarget->getGrid()->getStep(); + Vec2 step = _gridNodeTarget->getGrid()->getStep(); coords.bl.y += (step.y / 2) * (1.0f - distance); coords.br.y += (step.y / 2) * (1.0f - distance); @@ -579,7 +579,7 @@ FadeOutDownTiles* FadeOutDownTiles::clone() const float FadeOutDownTiles::testFunc(const Size& pos, float time) { - Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); + Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); if (pos.height == 0) { return 1.0f; @@ -662,12 +662,12 @@ void TurnOffTiles::shuffle(unsigned int *array, unsigned int len) } } -void TurnOffTiles::turnOnTile(const Vector2& pos) +void TurnOffTiles::turnOnTile(const Vec2& pos) { setTile(pos, getOriginalTile(pos)); } -void TurnOffTiles::turnOffTile(const Vector2& pos) +void TurnOffTiles::turnOffTile(const Vec2& pos) { Quad3 coords; @@ -706,7 +706,7 @@ void TurnOffTiles::update(float time) for( i = 0; i < _tilesCount; i++ ) { t = _tilesOrder[i]; - Vector2 tilePos = Vector2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height ); + Vec2 tilePos = Vec2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height ); if ( i < l ) { @@ -771,7 +771,7 @@ void WavesTiles3D::update(float time) { for( j = 0; j < _gridSize.height; j++ ) { - Quad3 coords = getOriginalTile(Vector2(i, j)); + Quad3 coords = getOriginalTile(Vec2(i, j)); coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 + (coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate ); @@ -779,7 +779,7 @@ void WavesTiles3D::update(float time) coords.tl.z = coords.bl.z; coords.tr.z = coords.bl.z; - setTile(Vector2(i, j), coords); + setTile(Vec2(i, j), coords); } } } @@ -839,7 +839,7 @@ void JumpTiles3D::update(float time) { for( j = 0; j < _gridSize.height; j++ ) { - Quad3 coords = getOriginalTile(Vector2(i, j)); + Quad3 coords = getOriginalTile(Vec2(i, j)); if ( ((i+j) % 2) == 0 ) { @@ -856,7 +856,7 @@ void JumpTiles3D::update(float time) coords.tr.z += sinz2; } - setTile(Vector2(i, j), coords); + setTile(Vec2(i, j), coords); } } } @@ -910,7 +910,7 @@ void SplitRows::update(float time) for (j = 0; j < _gridSize.height; ++j) { - Quad3 coords = getOriginalTile(Vector2(0, j)); + Quad3 coords = getOriginalTile(Vec2(0, j)); float direction = 1; if ( (j % 2 ) == 0 ) @@ -923,7 +923,7 @@ void SplitRows::update(float time) coords.tl.x += direction * _winSize.width * time; coords.tr.x += direction * _winSize.width * time; - setTile(Vector2(0, j), coords); + setTile(Vec2(0, j), coords); } } @@ -975,7 +975,7 @@ void SplitCols::update(float time) for (i = 0; i < _gridSize.width; ++i) { - Quad3 coords = getOriginalTile(Vector2(i, 0)); + Quad3 coords = getOriginalTile(Vec2(i, 0)); float direction = 1; if ( (i % 2 ) == 0 ) @@ -988,7 +988,7 @@ void SplitCols::update(float time) coords.tl.y += direction * _winSize.height * time; coords.tr.y += direction * _winSize.height * time; - setTile(Vector2(i, 0), coords); + setTile(Vec2(i, 0), coords); } } diff --git a/cocos/2d/CCActionTiledGrid.h b/cocos/2d/CCActionTiledGrid.h index c7887d6c1a..9f0b497c95 100644 --- a/cocos/2d/CCActionTiledGrid.h +++ b/cocos/2d/CCActionTiledGrid.h @@ -100,7 +100,7 @@ public: void shuffle(unsigned int *array, unsigned int len); Size getDelta(const Size& pos) const; - void placeTile(const Vector2& pos, Tile *t); + void placeTile(const Vec2& pos, Tile *t); // Overrides virtual void startWithTarget(Node *target) override; @@ -134,9 +134,9 @@ public: static FadeOutTRTiles* create(float duration, const Size& gridSize); virtual float testFunc(const Size& pos, float time); - void turnOnTile(const Vector2& pos); - void turnOffTile(const Vector2& pos); - virtual void transformTile(const Vector2& pos, float distance); + void turnOnTile(const Vec2& pos); + void turnOffTile(const Vec2& pos); + virtual void transformTile(const Vec2& pos, float distance); // Overrides virtual void update(float time) override; @@ -180,7 +180,7 @@ public: /** creates the action with the grid size and the duration */ static FadeOutUpTiles* create(float duration, const Size& gridSize); - virtual void transformTile(const Vector2& pos, float distance); + virtual void transformTile(const Vec2& pos, float distance); // Overrides virtual FadeOutUpTiles* clone() const override; @@ -227,8 +227,8 @@ public: static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed); void shuffle(unsigned int *array, unsigned int len); - void turnOnTile(const Vector2& pos); - void turnOffTile(const Vector2& pos); + void turnOnTile(const Vec2& pos); + void turnOffTile(const Vec2& pos); // Overrides virtual TurnOffTiles* clone() const override; diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 3403bf51e8..8c1ac25ebf 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -133,7 +133,7 @@ void AtlasNode::updateAtlasValues() } // AtlasNode - draw -void AtlasNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _quadCommand.init( _globalZOrder, diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index f5273cb72a..cdcda77bc6 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -69,7 +69,7 @@ public: // Overrides - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; virtual bool isOpacityModifyRGB() const override; diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index f82fa5231d..41d3c971d8 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -196,14 +196,14 @@ void ClippingNode::drawFullScreenQuadClearStencil() director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - DrawPrimitives::drawSolidRect(Vector2(-1,-1), Vector2(1,1), Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Vec2(-1,-1), Vec2(1,1), Color4F(1, 1, 1, 1)); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if(!_visible) return; @@ -214,7 +214,7 @@ void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -382,7 +382,7 @@ void ClippingNode::onBeforeVisit() glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); // draw a fullscreen solid rectangle to clear the stencil buffer - //ccDrawSolidRect(Vector2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); + //ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); drawFullScreenQuadClearStencil(); /////////////////////////////////// diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index a8d603e709..3ca5ab911c 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -95,7 +95,7 @@ public: * @lua NA */ virtual void onExit() override; - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; CC_CONSTRUCTOR_ACCESS: ClippingNode(); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 666cf80d35..108c2eb7cc 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -34,67 +34,67 @@ NS_CC_BEGIN -// Vector2 == CGPoint in 32-bits, but not in 64-bits (OS X) +// Vec2 == CGPoint in 32-bits, but not in 64-bits (OS X) // that's why the "v2f" functions are needed -static Vector2 v2fzero(0.0f,0.0f); +static Vec2 v2fzero(0.0f,0.0f); -static inline Vector2 v2f(float x, float y) +static inline Vec2 v2f(float x, float y) { - Vector2 ret(x, y); + Vec2 ret(x, y); return ret; } -static inline Vector2 v2fadd(const Vector2 &v0, const Vector2 &v1) +static inline Vec2 v2fadd(const Vec2 &v0, const Vec2 &v1) { return v2f(v0.x+v1.x, v0.y+v1.y); } -static inline Vector2 v2fsub(const Vector2 &v0, const Vector2 &v1) +static inline Vec2 v2fsub(const Vec2 &v0, const Vec2 &v1) { return v2f(v0.x-v1.x, v0.y-v1.y); } -static inline Vector2 v2fmult(const Vector2 &v, float s) +static inline Vec2 v2fmult(const Vec2 &v, float s) { return v2f(v.x * s, v.y * s); } -static inline Vector2 v2fperp(const Vector2 &p0) +static inline Vec2 v2fperp(const Vec2 &p0) { return v2f(-p0.y, p0.x); } -static inline Vector2 v2fneg(const Vector2 &p0) +static inline Vec2 v2fneg(const Vec2 &p0) { return v2f(-p0.x, - p0.y); } -static inline float v2fdot(const Vector2 &p0, const Vector2 &p1) +static inline float v2fdot(const Vec2 &p0, const Vec2 &p1) { return p0.x * p1.x + p0.y * p1.y; } -static inline Vector2 v2fforangle(float _a_) +static inline Vec2 v2fforangle(float _a_) { return v2f(cosf(_a_), sinf(_a_)); } -static inline Vector2 v2fnormalize(const Vector2 &p) +static inline Vec2 v2fnormalize(const Vec2 &p) { - Vector2 r = Vector2(p.x, p.y).getNormalized(); + Vec2 r = Vec2(p.x, p.y).getNormalized(); return v2f(r.x, r.y); } -static inline Vector2 __v2f(const Vector2 &v) +static inline Vec2 __v2f(const Vec2 &v) { //#ifdef __LP64__ return v2f(v.x, v.y); // #else -// return * ((Vector2*) &v); +// return * ((Vec2*) &v); // #endif } -static inline Tex2F __t(const Vector2 &v) +static inline Tex2F __t(const Vec2 &v) { return *(Tex2F*)&v; } @@ -205,14 +205,14 @@ bool DrawNode::init() return true; } -void DrawNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void DrawNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void DrawNode::onDraw(const Matrix &transform, bool transformUpdated) +void DrawNode::onDraw(const Mat4 &transform, bool transformUpdated) { auto glProgram = getGLProgram(); glProgram->use(); @@ -252,15 +252,15 @@ void DrawNode::onDraw(const Matrix &transform, bool transformUpdated) CHECK_GL_ERROR_DEBUG(); } -void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color) +void DrawNode::drawDot(const Vec2 &pos, float radius, const Color4F &color) { unsigned int vertex_count = 2*3; ensureCapacity(vertex_count); - V2F_C4B_T2F a = {Vector2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) }; - V2F_C4B_T2F b = {Vector2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) }; - V2F_C4B_T2F c = {Vector2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) }; - V2F_C4B_T2F d = {Vector2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) }; + V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) }; + V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) }; + V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) }; + V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) }; V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle triangle0 = {a, b, c}; @@ -273,28 +273,28 @@ void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color) _dirty = true; } -void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color) +void DrawNode::drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color) { unsigned int vertex_count = 6*3; ensureCapacity(vertex_count); - Vector2 a = __v2f(from); - Vector2 b = __v2f(to); + Vec2 a = __v2f(from); + Vec2 b = __v2f(to); - Vector2 n = v2fnormalize(v2fperp(v2fsub(b, a))); - Vector2 t = v2fperp(n); + Vec2 n = v2fnormalize(v2fperp(v2fsub(b, a))); + Vec2 t = v2fperp(n); - Vector2 nw = v2fmult(n, radius); - Vector2 tw = v2fmult(t, radius); - Vector2 v0 = v2fsub(b, v2fadd(nw, tw)); - Vector2 v1 = v2fadd(b, v2fsub(nw, tw)); - Vector2 v2 = v2fsub(b, nw); - Vector2 v3 = v2fadd(b, nw); - Vector2 v4 = v2fsub(a, nw); - Vector2 v5 = v2fadd(a, nw); - Vector2 v6 = v2fsub(a, v2fsub(nw, tw)); - Vector2 v7 = v2fadd(a, v2fadd(nw, tw)); + Vec2 nw = v2fmult(n, radius); + Vec2 tw = v2fmult(t, radius); + Vec2 v0 = v2fsub(b, v2fadd(nw, tw)); + Vec2 v1 = v2fadd(b, v2fsub(nw, tw)); + Vec2 v2 = v2fsub(b, nw); + Vec2 v3 = v2fadd(b, nw); + Vec2 v4 = v2fsub(a, nw); + Vec2 v5 = v2fadd(a, nw); + Vec2 v6 = v2fsub(a, v2fsub(nw, tw)); + Vec2 v7 = v2fadd(a, v2fadd(nw, tw)); V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); @@ -346,24 +346,24 @@ void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius, _dirty = true; } -void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor) +void DrawNode::drawPolygon(Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor) { CCASSERT(count >= 0, "invalid count value"); - struct ExtrudeVerts {Vector2 offset, n;}; + struct ExtrudeVerts {Vec2 offset, n;}; struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count); memset(extrude, 0, sizeof(struct ExtrudeVerts)*count); for (int i = 0; i < count; i++) { - Vector2 v0 = __v2f(verts[(i-1+count)%count]); - Vector2 v1 = __v2f(verts[i]); - Vector2 v2 = __v2f(verts[(i+1)%count]); + Vec2 v0 = __v2f(verts[(i-1+count)%count]); + Vec2 v1 = __v2f(verts[i]); + Vec2 v2 = __v2f(verts[(i+1)%count]); - Vector2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0))); - Vector2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1))); + Vec2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0))); + Vec2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1))); - Vector2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0)); + Vec2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0)); struct ExtrudeVerts tmp = {offset, n2}; extrude[i] = tmp; } @@ -380,9 +380,9 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float inset = (outline == false ? 0.5 : 0.0); for (int i = 0; i < count-2; i++) { - Vector2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset)); - Vector2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset)); - Vector2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset)); + Vec2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset)); + Vec2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset)); + Vec2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset)); V2F_C4B_T2F_Triangle tmp = { {v0, Color4B(fillColor), __t(v2fzero)}, @@ -396,20 +396,20 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, for(int i = 0; i < count; i++) { int j = (i+1)%count; - Vector2 v0 = __v2f(verts[i]); - Vector2 v1 = __v2f(verts[j]); + Vec2 v0 = __v2f(verts[i]); + Vec2 v1 = __v2f(verts[j]); - Vector2 n0 = extrude[i].n; + Vec2 n0 = extrude[i].n; - Vector2 offset0 = extrude[i].offset; - Vector2 offset1 = extrude[j].offset; + Vec2 offset0 = extrude[i].offset; + Vec2 offset1 = extrude[j].offset; if(outline) { - Vector2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth)); - Vector2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth)); - Vector2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth)); - Vector2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth)); + Vec2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth)); + Vec2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth)); + Vec2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth)); + Vec2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth)); V2F_C4B_T2F_Triangle tmp1 = { {inner0, Color4B(borderColor), __t(v2fneg(n0))}, @@ -426,10 +426,10 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, *cursor++ = tmp2; } else { - Vector2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5)); - Vector2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5)); - Vector2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5)); - Vector2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5)); + Vec2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5)); + Vec2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5)); + Vec2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5)); + Vec2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5)); V2F_C4B_T2F_Triangle tmp1 = { {inner0, Color4B(fillColor), __t(v2fzero)}, @@ -454,15 +454,15 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, free(extrude); } -void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color) +void DrawNode::drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color) { unsigned int vertex_count = 2*3; ensureCapacity(vertex_count); Color4B col = Color4B(color); - V2F_C4B_T2F a = {Vector2(p1.x, p1.y), col, Tex2F(0.0, 0.0) }; - V2F_C4B_T2F b = {Vector2(p2.x, p2.y), col, Tex2F(0.0, 0.0) }; - V2F_C4B_T2F c = {Vector2(p3.x, p3.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F a = {Vec2(p1.x, p1.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F b = {Vec2(p2.x, p2.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F c = {Vec2(p3.x, p3.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle triangle = {a, b, c}; @@ -472,23 +472,23 @@ void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 _dirty = true; } -void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color) +void DrawNode::drawCubicBezier(const Vec2& from, const Vec2& control1, const Vec2& control2, const Vec2& to, unsigned int segments, const Color4F &color) { unsigned int vertex_count = (segments + 1) * 3; ensureCapacity(vertex_count); Tex2F texCoord = Tex2F(0.0, 0.0); Color4B col = Color4B(color); - Vector2 vertex; - Vector2 firstVertex = Vector2(from.x, from.y); - Vector2 lastVertex = Vector2(to.x, to.y); + Vec2 vertex; + Vec2 firstVertex = Vec2(from.x, from.y); + Vec2 lastVertex = Vec2(to.x, to.y); float t = 0; for(unsigned int i = segments + 1; i > 0; i--) { float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x; float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y; - vertex = Vector2(x, y); + vertex = Vec2(x, y); V2F_C4B_T2F a = {firstVertex, col, texCoord }; V2F_C4B_T2F b = {lastVertex, col, texCoord }; @@ -503,23 +503,23 @@ void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, con _dirty = true; } -void DrawNode::drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color) +void DrawNode::drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color) { unsigned int vertex_count = (segments + 1) * 3; ensureCapacity(vertex_count); Tex2F texCoord = Tex2F(0.0, 0.0); Color4B col = Color4B(color); - Vector2 vertex; - Vector2 firstVertex = Vector2(from.x, from.y); - Vector2 lastVertex = Vector2(to.x, to.y); + Vec2 vertex; + Vec2 firstVertex = Vec2(from.x, from.y); + Vec2 lastVertex = Vec2(to.x, to.y); float t = 0; for(unsigned int i = segments + 1; i > 0; i--) { float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x; float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y; - vertex = Vector2(x, y); + vertex = Vec2(x, y); V2F_C4B_T2F a = {firstVertex, col, texCoord }; V2F_C4B_T2F b = {lastVertex, col, texCoord }; diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index 38381053b6..264a1ad78a 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -50,10 +50,10 @@ public: static DrawNode* create(); /** draw a dot at a position, with a given radius and color */ - void drawDot(const Vector2 &pos, float radius, const Color4F &color); + void drawDot(const Vec2 &pos, float radius, const Color4F &color); /** draw a segment with a radius and color */ - void drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color); + void drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color); /** draw a polygon with a fill color and line color * @code @@ -62,16 +62,16 @@ public: * In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor) * @endcode */ - void drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); + void drawPolygon(Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); /** draw a triangle with color */ - void drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color); + void drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color); /** draw a cubic bezier curve with color and number of segments */ - void drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color); + void drawCubicBezier(const Vec2& from, const Vec2& control1, const Vec2& control2, const Vec2& to, unsigned int segments, const Color4F &color); /** draw a quadratic bezier curve with color and number of segments */ - void drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color); + void drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color); /** Clear the geometry in the node's buffer. */ void clear(); @@ -89,10 +89,10 @@ public: */ void setBlendFunc(const BlendFunc &blendFunc); - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); // Overrides - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; CC_CONSTRUCTOR_ACCESS: DrawNode(); diff --git a/cocos/2d/CCDrawingPrimitives.cpp b/cocos/2d/CCDrawingPrimitives.cpp index 3af2401d45..1505560c44 100644 --- a/cocos/2d/CCDrawingPrimitives.cpp +++ b/cocos/2d/CCDrawingPrimitives.cpp @@ -123,11 +123,11 @@ void free() s_initialized = false; } -void drawPoint( const Vector2& point ) +void drawPoint( const Vec2& point ) { lazy_init(); - Vector2 p; + Vec2 p; p.x = point.x; p.y = point.y; @@ -150,7 +150,7 @@ void drawPoint( const Vector2& point ) CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,1); } -void drawPoints( const Vector2 *points, unsigned int numberOfPoints ) +void drawPoints( const Vec2 *points, unsigned int numberOfPoints ) { lazy_init(); @@ -161,13 +161,13 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints ) s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize); // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed - Vector2* newPoints = new Vector2[numberOfPoints]; + Vec2* newPoints = new Vec2[numberOfPoints]; // iPhone and 32-bit machines optimization - if( sizeof(Vector2) == sizeof(Vector2) ) + if( sizeof(Vec2) == sizeof(Vec2) ) { #ifdef EMSCRIPTEN - setGLBufferData((void*) points, numberOfPoints * sizeof(Vector2)); + setGLBufferData((void*) points, numberOfPoints * sizeof(Vec2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points); @@ -183,7 +183,7 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints ) #ifdef EMSCRIPTEN // Suspect Emscripten won't be emitting 64-bit code for a while yet, // but want to make sure this continues to work even if they do. - setGLBufferData(newPoints, numberOfPoints * sizeof(Vector2)); + setGLBufferData(newPoints, numberOfPoints * sizeof(Vec2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints); @@ -198,13 +198,13 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints ) } -void drawLine( const Vector2& origin, const Vector2& destination ) +void drawLine( const Vec2& origin, const Vec2& destination ) { lazy_init(); - Vector2 vertices[2] = { - Vector2(origin.x, origin.y), - Vector2(destination.x, destination.y) + Vec2 vertices[2] = { + Vec2(origin.x, origin.y), + Vec2(destination.x, destination.y) }; s_shader->use(); @@ -223,27 +223,27 @@ void drawLine( const Vector2& origin, const Vector2& destination ) CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2); } -void drawRect( Vector2 origin, Vector2 destination ) +void drawRect( Vec2 origin, Vec2 destination ) { - drawLine(Vector2(origin.x, origin.y), Vector2(destination.x, origin.y)); - drawLine(Vector2(destination.x, origin.y), Vector2(destination.x, destination.y)); - drawLine(Vector2(destination.x, destination.y), Vector2(origin.x, destination.y)); - drawLine(Vector2(origin.x, destination.y), Vector2(origin.x, origin.y)); + drawLine(Vec2(origin.x, origin.y), Vec2(destination.x, origin.y)); + drawLine(Vec2(destination.x, origin.y), Vec2(destination.x, destination.y)); + drawLine(Vec2(destination.x, destination.y), Vec2(origin.x, destination.y)); + drawLine(Vec2(origin.x, destination.y), Vec2(origin.x, origin.y)); } -void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color ) +void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color ) { - Vector2 vertices[] = { + Vec2 vertices[] = { origin, - Vector2(destination.x, origin.y), + Vec2(destination.x, origin.y), destination, - Vector2(origin.x, destination.y) + Vec2(origin.x, destination.y) }; drawSolidPoly(vertices, 4, color ); } -void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolygon ) +void drawPoly( const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon ) { lazy_init(); @@ -254,10 +254,10 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); // iPhone and 32-bit machines optimization - if( sizeof(Vector2) == sizeof(Vector2) ) + if( sizeof(Vec2) == sizeof(Vec2) ) { #ifdef EMSCRIPTEN - setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2)); + setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); @@ -272,13 +272,13 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg { // Mac on 64-bit // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed - Vector2* newPoli = new Vector2[numberOfPoints]; + Vec2* newPoli = new Vec2[numberOfPoints]; for( unsigned int i=0; igetControlPointAtIndex(p-1); - Vector2 pp1 = config->getControlPointAtIndex(p+0); - Vector2 pp2 = config->getControlPointAtIndex(p+1); - Vector2 pp3 = config->getControlPointAtIndex(p+2); + Vec2 pp0 = config->getControlPointAtIndex(p-1); + Vec2 pp1 = config->getControlPointAtIndex(p+0); + Vec2 pp2 = config->getControlPointAtIndex(p+1); + Vec2 pp3 = config->getControlPointAtIndex(p+2); - Vector2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); + Vec2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); vertices[i].x = newPos.x; vertices[i].y = newPos.y; } @@ -514,7 +514,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN - setGLBufferData(vertices, (segments + 1) * sizeof(Vector2)); + setGLBufferData(vertices, (segments + 1) * sizeof(Vec2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); @@ -525,11 +525,11 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1); } -void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments) +void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments) { lazy_init(); - Vector2* vertices = new Vector2[segments + 1]; + Vec2* vertices = new Vec2[segments + 1]; float t = 0; for(unsigned int i = 0; i < segments; i++) @@ -548,7 +548,7 @@ void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vecto GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN - setGLBufferData(vertices, (segments + 1) * sizeof(Vector2)); + setGLBufferData(vertices, (segments + 1) * sizeof(Vec2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); diff --git a/cocos/2d/CCDrawingPrimitives.h b/cocos/2d/CCDrawingPrimitives.h index a687302390..2bd69651df 100644 --- a/cocos/2d/CCDrawingPrimitives.h +++ b/cocos/2d/CCDrawingPrimitives.h @@ -63,7 +63,7 @@ THE SOFTWARE. - ccPointSize() - glLineWidth() - @warning These functions draws the Line, Vector2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode + @warning These functions draws the Line, Vec2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode */ @@ -85,52 +85,52 @@ namespace DrawPrimitives void free(); /** draws a point given x and y coordinate measured in points */ - void drawPoint( const Vector2& point ); + void drawPoint( const Vec2& point ); /** draws an array of points. @since v0.7.2 */ - void drawPoints( const Vector2 *points, unsigned int numberOfPoints ); + void drawPoints( const Vec2 *points, unsigned int numberOfPoints ); /** draws a line given the origin and destination point measured in points */ - void drawLine( const Vector2& origin, const Vector2& destination ); + void drawLine( const Vec2& origin, const Vec2& destination ); /** draws a rectangle given the origin and destination point measured in points. */ - void drawRect( Vector2 origin, Vector2 destination ); + void drawRect( Vec2 origin, Vec2 destination ); /** draws a solid rectangle given the origin and destination point measured in points. @since 1.1 */ - void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color ); + void drawSolidRect( Vec2 origin, Vec2 destination, 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 */ - void drawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon ); + void drawPoly( const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon ); /** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color. */ - void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color ); + void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color ); /** draws a circle given the center, radius and number of segments. */ - void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); - void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); + void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); + void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); /** draws a solid circle given the center, radius and number of segments. */ - void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); - void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments); + void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); + void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments); /** draws a quad bezier path @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ - void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments); + void drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments); /** draws a cubic bezier path @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ - void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments); + void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments); /** draws a Catmull Rom path. @warning This function could be pretty slow. Use it only for debugging purposes. diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index 592c39e327..683f825071 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -90,7 +90,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config) return nullptr; } -FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset /* = Vector2::ZERO */) +FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset /* = Vec2::ZERO */) { std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false); auto it = _atlasMap.find(atlasName); diff --git a/cocos/2d/CCFontAtlasCache.h b/cocos/2d/CCFontAtlasCache.h index 8b8964456d..800948ba44 100644 --- a/cocos/2d/CCFontAtlasCache.h +++ b/cocos/2d/CCFontAtlasCache.h @@ -38,7 +38,7 @@ class CC_DLL FontAtlasCache { public: static FontAtlas * getFontAtlasTTF(const TTFConfig & config); - static FontAtlas * getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset = Vector2::ZERO); + static FontAtlas * getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset = Vec2::ZERO); static FontAtlas * getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); static FontAtlas * getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index 714567cad4..6e7a9f7364 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -665,7 +665,7 @@ void BMFontConfiguration::parseKerningEntry(std::string line) HASH_ADD_INT(_kerningDictionary,key, element); } -FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOffset /* = Vector2::ZERO */) +FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffset /* = Vec2::ZERO */) { BMFontConfiguration *newConf = FNTConfigLoadFile(fntFilePath); if (!newConf) @@ -690,7 +690,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOf return tempFont; } -FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset /* = Vector2::ZERO */) +FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset /* = Vec2::ZERO */) :_configuration(theContfig) ,_imageOffset(CC_POINT_PIXELS_TO_POINTS(imageOffset)) { diff --git a/cocos/2d/CCFontFNT.h b/cocos/2d/CCFontFNT.h index fb32fbc4fe..945f81c0ac 100644 --- a/cocos/2d/CCFontFNT.h +++ b/cocos/2d/CCFontFNT.h @@ -37,7 +37,7 @@ class FontFNT : public Font public: - static FontFNT * create(const std::string& fntFilePath, const Vector2& imageOffset = Vector2::ZERO); + static FontFNT * create(const std::string& fntFilePath, const Vec2& imageOffset = Vec2::ZERO); /** Purges the cached data. Removes from memory the cached configurations and the atlas name dictionary. */ @@ -47,7 +47,7 @@ public: protected: - FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset = Vector2::ZERO); + FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO); /** * @js NA * @lua NA @@ -59,7 +59,7 @@ private: int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const; BMFontConfiguration * _configuration; - Vector2 _imageOffset; + Vec2 _imageOffset; }; diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index 96f927363a..dc7b879de9 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -186,8 +186,8 @@ void GridBase::set2DProjection() glViewport(0, 0, (GLsizei)(size.width), (GLsizei)(size.height) ); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - Matrix orthoMatrix; - Matrix::createOrthographicOffCenter(0, size.width, 0, size.height, -1, 1, &orthoMatrix); + Mat4 orthoMatrix; + Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1, 1, &orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -217,7 +217,7 @@ void GridBase::afterDraw(cocos2d::Node *target) // if (target->getCamera()->isDirty()) // { -// Vector2 offset = target->getAnchorPointInPoints(); +// Vec2 offset = target->getAnchorPointInPoints(); // // // // // XXX: Camera should be applied in the AnchorPoint @@ -326,11 +326,11 @@ void Grid3D::blit(void) unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); // position - setGLBufferData(_vertices, numOfPoints * sizeof(Vector3), 0); + setGLBufferData(_vertices, numOfPoints * sizeof(Vec3), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); // texCoords - setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vector2), 1); + setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vec2), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); @@ -361,9 +361,9 @@ void Grid3D::calculateVertexPoints(void) unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); - _vertices = malloc(numOfPoints * sizeof(Vector3)); - _originalVertices = malloc(numOfPoints * sizeof(Vector3)); - _texCoordinates = malloc(numOfPoints * sizeof(Vector2)); + _vertices = malloc(numOfPoints * sizeof(Vec3)); + _originalVertices = malloc(numOfPoints * sizeof(Vec3)); + _texCoordinates = malloc(numOfPoints * sizeof(Vec2)); _indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6); GLfloat *vertArray = (GLfloat*)_vertices; @@ -391,15 +391,15 @@ void Grid3D::calculateVertexPoints(void) memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort)); int l1[4] = {a*3, b*3, c*3, d*3}; - Vector3 e(x1, y1, 0); - Vector3 f(x2, y1, 0); - Vector3 g(x2, y2, 0); - Vector3 h(x1, y2, 0); + Vec3 e(x1, y1, 0); + Vec3 f(x2, y1, 0); + Vec3 g(x2, y2, 0); + Vec3 h(x1, y2, 0); - Vector3 l2[4] = {e, f, g, h}; + Vec3 l2[4] = {e, f, g, h}; int tex1[4] = {a*2, b*2, c*2, d*2}; - Vector2 Tex2F[4] = {Vector2(x1, y1), Vector2(x2, y1), Vector2(x2, y2), Vector2(x1, y2)}; + Vec2 Tex2F[4] = {Vec2(x1, y1), Vec2(x2, y1), Vec2(x2, y2), Vec2(x1, y2)}; for (i = 0; i < 4; ++i) { @@ -420,34 +420,34 @@ void Grid3D::calculateVertexPoints(void) } } - memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3)); + memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3)); } -Vector3 Grid3D::getVertex(const Vector2& pos) const +Vec3 Grid3D::getVertex(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; float *vertArray = (float*)_vertices; - Vector3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); + Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); return vert; } -Vector3 Grid3D::getOriginalVertex(const Vector2& pos) const +Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; float *vertArray = (float*)_originalVertices; - Vector3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); + Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); return vert; } -void Grid3D::setVertex(const Vector2& pos, const Vector3& vertex) +void Grid3D::setVertex(const Vec2& pos, const Vec3& vertex) { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3; @@ -461,7 +461,7 @@ void Grid3D::reuse(void) { if (_reuseGrid > 0) { - memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3)); + memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3)); --_reuseGrid; } } @@ -541,11 +541,11 @@ void TiledGrid3D::blit(void) int numQuads = _gridSize.width * _gridSize.height; // position - setGLBufferData(_vertices, (numQuads*4*sizeof(Vector3)), 0); + setGLBufferData(_vertices, (numQuads*4*sizeof(Vec3)), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); // texCoords - setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vector2)), 1); + setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vec2)), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); @@ -576,9 +576,9 @@ void TiledGrid3D::calculateVertexPoints(void) CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_indices); - _vertices = malloc(numQuads*4*sizeof(Vector3)); - _originalVertices = malloc(numQuads*4*sizeof(Vector3)); - _texCoordinates = malloc(numQuads*4*sizeof(Vector2)); + _vertices = malloc(numQuads*4*sizeof(Vec3)); + _originalVertices = malloc(numQuads*4*sizeof(Vec3)); + _texCoordinates = malloc(numQuads*4*sizeof(Vec2)); _indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort)); GLfloat *vertArray = (GLfloat*)_vertices; @@ -643,7 +643,7 @@ void TiledGrid3D::calculateVertexPoints(void) memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat)); } -void TiledGrid3D::setTile(const Vector2& pos, const Quad3& coords) +void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords) { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; @@ -651,7 +651,7 @@ void TiledGrid3D::setTile(const Vector2& pos, const Quad3& coords) memcpy(&vertArray[idx], &coords, sizeof(Quad3)); } -Quad3 TiledGrid3D::getOriginalTile(const Vector2& pos) const +Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; @@ -663,7 +663,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Vector2& pos) const return ret; } -Quad3 TiledGrid3D::getTile(const Vector2& pos) const +Quad3 TiledGrid3D::getTile(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; diff --git a/cocos/2d/CCGrid.h b/cocos/2d/CCGrid.h index 98d1ee1d1d..9d59f24ce7 100644 --- a/cocos/2d/CCGrid.h +++ b/cocos/2d/CCGrid.h @@ -77,8 +77,8 @@ public: inline void setGridSize(const Size& gridSize) { _gridSize = gridSize; } /** pixels between the grids */ - inline const Vector2& getStep(void) const { return _step; } - inline void setStep(const Vector2& step) { _step = step; } + inline const Vec2& getStep(void) const { return _step; } + inline void setStep(const Vec2& step) { _step = step; } /** is texture flipped */ inline bool isTextureFlipped(void) const { return _isTextureFlipped; } @@ -97,7 +97,7 @@ protected: int _reuseGrid; Size _gridSize; Texture2D *_texture; - Vector2 _step; + Vec2 _step; Grabber *_grabber; bool _isTextureFlipped; GLProgram* _shaderProgram; @@ -131,28 +131,28 @@ public: * @js NA * @lua NA */ - Vector3 getVertex(const Vector2& pos) const; + Vec3 getVertex(const Vec2& pos) const; /** @deprecated Use getVertex() instead * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE Vector3 vertex(const Vector2& pos) const { return getVertex(pos); } + CC_DEPRECATED_ATTRIBUTE Vec3 vertex(const Vec2& pos) const { return getVertex(pos); } /** returns the original (non-transformed) vertex at a given position * @js NA * @lua NA */ - Vector3 getOriginalVertex(const Vector2& pos) const; + Vec3 getOriginalVertex(const Vec2& pos) const; /** @deprecated Use getOriginalVertex() instead * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE Vector3 originalVertex(const Vector2& pos) const { return getOriginalVertex(pos); } + CC_DEPRECATED_ATTRIBUTE Vec3 originalVertex(const Vec2& pos) const { return getOriginalVertex(pos); } /** sets a new vertex at a given position * @js NA * @lua NA */ - void setVertex(const Vector2& pos, const Vector3& vertex); + void setVertex(const Vec2& pos, const Vec3& vertex); // Overrides virtual void blit() override; @@ -194,28 +194,28 @@ public: * @js NA * @lua NA */ - Quad3 getTile(const Vector2& pos) const; + Quad3 getTile(const Vec2& pos) const; /** returns the tile at the given position * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vector2& pos) const { return getTile(pos); } + CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& pos) const { return getTile(pos); } /** returns the original tile (untransformed) at the given position * @js NA * @lua NA */ - Quad3 getOriginalTile(const Vector2& pos) const; + Quad3 getOriginalTile(const Vec2& pos) const; /** returns the original tile (untransformed) at the given position * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vector2& pos) const { return getOriginalTile(pos); } + CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& pos) const { return getOriginalTile(pos); } /** sets a new tile * @js NA * @lua NA */ - void setTile(const Vector2& pos, const Quad3& coords); + void setTile(const Vec2& pos, const Quad3& coords); // Overrides virtual void blit() override; diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index e5a2e5863a..0202070200 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -129,7 +129,7 @@ Label* Label::createWithTTF(const TTFConfig& ttfConfig, const std::string& text, return nullptr; } -Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vector2& imageOffset /* = Vector2::ZERO */) +Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vec2& imageOffset /* = Vec2::ZERO */) { auto ret = new Label(nullptr,alignment); @@ -262,7 +262,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te , _insideBounds(true) , _effectColorF(Color4F::BLACK) { - setAnchorPoint(Vector2::ANCHOR_MIDDLE); + setAnchorPoint(Vec2::ANCHOR_MIDDLE); reset(); #if CC_ENABLE_CACHE_TEXTURE_DATA @@ -395,7 +395,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false * _reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0)); _reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB); _reusedLetter->retain(); - _reusedLetter->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT); + _reusedLetter->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); _reusedLetter->setBatchNode(this); } else @@ -454,7 +454,7 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig) return true; } -bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset /* = Vector2::ZERO */) +bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset /* = Vec2::ZERO */) { FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset); @@ -597,8 +597,8 @@ void Label::alignText() for (auto index = _batchNodes.size(); index < textures.size(); ++index) { auto batchNode = SpriteBatchNode::createWithTexture(textures[index]); - batchNode->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT); - batchNode->setPosition(Vector2::ZERO); + batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); + batchNode->setPosition(Vec2::ZERO); Node::addChild(batchNode,0,Node::INVALID_TAG); _batchNodes.push_back(batchNode); } @@ -680,7 +680,7 @@ void Label::updateQuads() } } -bool Label::recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex) +bool Label::recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex) { if (static_cast(spriteIndex) >= _lettersInfo.size()) { @@ -809,7 +809,7 @@ void Label::setFontScale(float fontScale) Node::setScale(_fontScale); } -void Label::onDraw(const Matrix& transform, bool transformUpdated) +void Label::onDraw(const Mat4& transform, bool transformUpdated) { CC_PROFILER_START("Label - draw"); @@ -877,7 +877,7 @@ void Label::drawShadowWithoutBlur() setColor(oldColor); } -void Label::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Label::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { // Don't do calculate the culling if the transform was not updated _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; @@ -897,7 +897,7 @@ void Label::createSpriteWithFontDefinition() texture->initWithString(_originalUTF8String.c_str(),_fontDefinition); _textSprite = Sprite::createWithTexture(texture); - _textSprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); this->setContentSize(_textSprite->getContentSize()); texture->release(); if (_blendFuncDirty) @@ -1035,7 +1035,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated) { _shadowNode->setBlendFunc(_blendFunc); } - _shadowNode->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _shadowNode->setColor(_shadowColor); _shadowNode->setOpacity(_shadowOpacity * _displayedOpacity); _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); @@ -1049,7 +1049,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated) _textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated); } -void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if (! _visible || _originalUTF8String.empty()) { @@ -1088,7 +1088,7 @@ void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parent _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1161,7 +1161,7 @@ Sprite * Label::getLetter(int letterIndex) sp = Sprite::createWithTexture(_fontAtlas->getTexture(letter.def.textureID),uvRect); sp->setBatchNode(_batchNodes[letter.def.textureID]); - sp->setPosition(Vector2(letter.position.x + uvRect.size.width / 2, + sp->setPosition(Vec2(letter.position.x + uvRect.size.width / 2, letter.position.y - uvRect.size.height / 2)); sp->setOpacity(_realOpacity); diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index f8c7a1ab77..7af8134507 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -104,7 +104,7 @@ public: /* Creates a label with an FNT file,an initial string,horizontal alignment,max line width and the offset of image*/ static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text, const TextHAlignment& alignment = TextHAlignment::LEFT, int maxLineWidth = 0, - const Vector2& imageOffset = Vector2::ZERO); + const Vec2& imageOffset = Vec2::ZERO); static Label * createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); @@ -114,7 +114,7 @@ public: virtual bool setTTFConfig(const TTFConfig& ttfConfig); virtual const TTFConfig& getTTFConfig() const { return _fontConfig;} - virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset = Vector2::ZERO); + virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO); const std::string& getBMFontFilePath() const { return _bmFontPath;} virtual bool setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); @@ -237,8 +237,8 @@ public: virtual Rect getBoundingBox() const override; - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize, const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT, @@ -248,13 +248,13 @@ public: CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; } protected: - void onDraw(const Matrix& transform, bool transformUpdated); + void onDraw(const Mat4& transform, bool transformUpdated); struct LetterInfo { FontLetterDefinition def; - Vector2 position; + Vec2 position; Size contentSize; int atlasIndex; }; @@ -279,7 +279,7 @@ protected: virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false); - bool recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex); + bool recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex); bool recordPlaceholderInfo(int spriteIndex); void setFontScale(float fontScale); @@ -363,7 +363,7 @@ protected: bool _shadowEnabled; Size _shadowOffset; int _shadowBlurRadius; - Matrix _shadowTransform; + Mat4 _shadowTransform; Color3B _shadowColor; float _shadowOpacity; Sprite* _shadowNode; diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index dbdcee017f..ee8b209331 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -249,7 +249,7 @@ void LabelAtlas::updateColor() //CCLabelAtlas - draw #if CC_LABELATLAS_DEBUG_DRAW -void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { AtlasNode::draw(renderer, transform, transformUpdated); @@ -258,7 +258,7 @@ void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transfor renderer->addCommand(&_customDebugDrawCommand); } -void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated) +void LabelAtlas::drawDebugData(const Mat4& transform, bool transformUpdated) { Director* director = Director::getInstance(); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -266,12 +266,12 @@ void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated) auto size = getContentSize(); - Vector2 vertices[4]= + Vec2 vertices[4]= { - Vector2::ZERO, - Vector2(size.width, 0), - Vector2(size.width, size.height), - Vector2(0, size.height) + Vec2::ZERO, + Vec2(size.width, 0), + Vec2(size.width, size.height), + Vec2(0, size.height) }; DrawPrimitives::drawPoly(vertices, 4, true); diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index c2e11ce0f4..1ef43bec2a 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -84,7 +84,7 @@ public: virtual std::string getDescription() const override; #if CC_LABELATLAS_DEBUG_DRAW - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; #endif protected: @@ -100,7 +100,7 @@ protected: #if CC_LABELATLAS_DEBUG_DRAW CustomCommand _customDebugDrawCommand; - void drawDebugData(const Matrix& transform, bool transformUpdated); + void drawDebugData(const Mat4& transform, bool transformUpdated); #endif // string to render diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 283030f9f2..7dfe8b846c 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -65,7 +65,7 @@ LabelBMFont * LabelBMFont::create() } //LabelBMFont - Creation & Init -LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */) +LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */) { LabelBMFont *ret = new LabelBMFont(); if(ret && ret->initWithString(str, fntFile, width, alignment,imageOffset)) @@ -77,7 +77,7 @@ LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntF return nullptr; } -bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */) +bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */) { if (_label->setBMFontFilePath(fntFile,imageOffset)) { @@ -95,9 +95,9 @@ bool LabelBMFont::initWithString(const std::string& str, const std::string& fntF LabelBMFont::LabelBMFont() { _label = Label::create(); - _label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); this->addChild(_label); - this->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + this->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _cascadeOpacityEnabled = true; } @@ -152,7 +152,7 @@ void LabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace ) } // LabelBMFont - FntFile -void LabelBMFont::setFntFile(const std::string& fntFile, const Vector2& imageOffset /* = Vector2::ZERO */) +void LabelBMFont::setFntFile(const std::string& fntFile, const Vec2& imageOffset /* = Vec2::ZERO */) { if (_fntFile.compare(fntFile) != 0) { @@ -207,7 +207,7 @@ Rect LabelBMFont::getBoundingBox() const return _label->getBoundingBox(); } #if CC_LABELBMFONT_DEBUG_DRAW -void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Node::draw(renderer, transform, transformUpdated); @@ -216,7 +216,7 @@ void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transfo renderer->addCommand(&_customDebugDrawCommand); } -void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated) +void LabelBMFont::drawDebugData(const Mat4& transform, bool transformUpdated) { Director* director = Director::getInstance(); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -224,12 +224,12 @@ void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated) auto size = getContentSize(); - Vector2 vertices[4]= + Vec2 vertices[4]= { - Vector2::ZERO, - Vector2(size.width, 0), - Vector2(size.width, size.height), - Vector2(0, size.height) + Vec2::ZERO, + Vec2(size.width, 0), + Vec2(size.width, size.height), + Vec2(0, size.height) }; DrawPrimitives::drawPoly(vertices, 4, true); diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 0a9b7bdf04..5479adf0a3 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -85,14 +85,14 @@ public: virtual ~LabelBMFont(); /** creates a bitmap font atlas with an initial string and the FNT file */ - static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vector2& imageOffset = Vector2::ZERO); + static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vec2& imageOffset = Vec2::ZERO); /** Creates an label. */ static LabelBMFont * create(); /** init a bitmap font atlas with an initial string and the FNT file */ - bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vector2& imageOffset = Vector2::ZERO); + bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vec2& imageOffset = Vec2::ZERO); // super method virtual void setString(const std::string& newString) override; @@ -107,7 +107,7 @@ public: virtual bool isOpacityModifyRGB() const; virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); - void setFntFile(const std::string& fntFile, const Vector2& imageOffset = Vector2::ZERO); + void setFntFile(const std::string& fntFile, const Vec2& imageOffset = Vec2::ZERO); const std::string& getFntFile() const; virtual void setBlendFunc(const BlendFunc &blendFunc) override; @@ -124,13 +124,13 @@ public: virtual std::string getDescription() const override; #if CC_LABELBMFONT_DEBUG_DRAW - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; #endif private: #if CC_LABELBMFONT_DEBUG_DRAW CustomCommand _customDebugDrawCommand; - void drawDebugData(const Matrix& transform, bool transformUpdated); + void drawDebugData(const Mat4& transform, bool transformUpdated); #endif // name of fntFile diff --git a/cocos/2d/CCLabelTTF.cpp b/cocos/2d/CCLabelTTF.cpp index e5ba3b7cb8..adf94e8f3e 100644 --- a/cocos/2d/CCLabelTTF.cpp +++ b/cocos/2d/CCLabelTTF.cpp @@ -39,9 +39,9 @@ NS_CC_BEGIN LabelTTF::LabelTTF() { _renderLabel = Label::create(); - _renderLabel->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _renderLabel->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); this->addChild(_renderLabel); - this->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + this->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _contentDirty = false; _cascadeColorEnabled = true; @@ -262,7 +262,7 @@ void LabelTTF::setFlippedY(bool flippedY) } } -void LabelTTF::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if (_contentDirty) { diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index e5731dc02c..f65992fa99 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -150,7 +150,7 @@ public: * @lua NA */ virtual std::string getDescription() const override; - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; virtual const Size& getContentSize() const override; protected: Label* _renderLabel; diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 9dfd813039..a64ba30140 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -310,7 +310,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel) auto strWhole = theLabel->_currentUTF16String; auto fontAtlas = theLabel->_fontAtlas; FontLetterDefinition tempDefinition; - Vector2 letterPosition; + Vec2 letterPosition; const auto& kernings = theLabel->_horizontalKernings; float clipTop = 0; diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 621012bc2d..de60f31a02 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -65,7 +65,7 @@ Layer::Layer() , _swallowsTouches(true) { _ignoreAnchorPointForPosition = true; - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); } Layer::~Layer() @@ -584,7 +584,7 @@ void LayerColor::updateColor() } } -void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated); @@ -592,15 +592,15 @@ void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transfor for(int i = 0; i < 4; ++i) { - Vector4 pos; + Vec4 pos; pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ; pos.w = 1; _modelViewTransform.transformVector(&pos); - _noMVPVertices[i] = Vector3(pos.x,pos.y,pos.z)/pos.w; + _noMVPVertices[i] = Vec3(pos.x,pos.y,pos.z)/pos.w; } } -void LayerColor::onDraw(const Matrix& transform, bool transformUpdated) +void LayerColor::onDraw(const Mat4& transform, bool transformUpdated) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -610,7 +610,7 @@ void LayerColor::onDraw(const Matrix& transform, bool transformUpdated) // Attributes // #ifdef EMSCRIPTEN - setGLBufferData(_noMVPVertices, 4 * sizeof(Vector3), 0); + setGLBufferData(_noMVPVertices, 4 * sizeof(Vec3), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1); @@ -640,7 +640,7 @@ LayerGradient::LayerGradient() , _endColor(Color4B::BLACK) , _startOpacity(255) , _endOpacity(255) -, _alongVector(Vector2(0, -1)) +, _alongVector(Vec2(0, -1)) , _compressedInterpolation(true) { @@ -662,7 +662,7 @@ LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end) return nullptr; } -LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vector2& v) +LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vec2& v) { LayerGradient * layer = new LayerGradient(); if( layer && layer->initWithColor(start, end, v)) @@ -695,10 +695,10 @@ bool LayerGradient::init() bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end) { - return initWithColor(start, end, Vector2(0, -1)); + return initWithColor(start, end, Vec2(0, -1)); } -bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vector2& v) +bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vec2& v) { _endColor.r = end.r; _endColor.g = end.g; @@ -722,7 +722,7 @@ void LayerGradient::updateColor() return; float c = sqrtf(2.0f); - Vector2 u = Vector2(_alongVector.x / h, _alongVector.y / h); + Vec2 u = Vec2(_alongVector.x / h, _alongVector.y / h); // Compressed Interpolation mode if (_compressedInterpolation) @@ -812,13 +812,13 @@ GLubyte LayerGradient::getEndOpacity() const return _endOpacity; } -void LayerGradient::setVector(const Vector2& var) +void LayerGradient::setVector(const Vec2& var) { _alongVector = var; updateColor(); } -const Vector2& LayerGradient::getVector() const +const Vec2& LayerGradient::getVector() const { return _alongVector; } diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index f6e944b57a..363d2aab8e 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -270,7 +270,7 @@ public: // // Overrides // - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual void setContentSize(const Size & var) override; /** BlendFunction. Conforms to BlendProtocol protocol */ @@ -299,15 +299,15 @@ CC_CONSTRUCTOR_ACCESS: bool initWithColor(const Color4B& color); protected: - void onDraw(const Matrix& transform, bool transformUpdated); + void onDraw(const Mat4& transform, bool transformUpdated); virtual void updateColor() override; BlendFunc _blendFunc; - Vector2 _squareVertices[4]; + Vec2 _squareVertices[4]; Color4F _squareColors[4]; CustomCommand _customCommand; - Vector3 _noMVPVertices[4]; + Vec3 _noMVPVertices[4]; private: CC_DISALLOW_COPY_AND_ASSIGN(LayerColor); @@ -345,7 +345,7 @@ public: static LayerGradient* create(const Color4B& start, const Color4B& end); /** Creates a full-screen Layer with a gradient between start and end in the direction of v. */ - static LayerGradient* create(const Color4B& start, const Color4B& end, const Vector2& v); + static LayerGradient* create(const Color4B& start, const Color4B& end, const Vec2& v); /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors Default: true @@ -376,9 +376,9 @@ public: /** Sets the directional vector that will be used for the gradient. The default value is vertical direction (0,-1). */ - void setVector(const Vector2& alongVector); + void setVector(const Vec2& alongVector); /** Returns the directional vector used for the gradient */ - const Vector2& getVector() const; + const Vec2& getVector() const; virtual std::string getDescription() const override; @@ -397,7 +397,7 @@ CC_CONSTRUCTOR_ACCESS: * @js init * @lua init */ - bool initWithColor(const Color4B& start, const Color4B& end, const Vector2& v); + bool initWithColor(const Color4B& start, const Color4B& end, const Vec2& v); protected: virtual void updateColor() override; @@ -406,7 +406,7 @@ protected: Color3B _endColor; GLubyte _startOpacity; GLubyte _endOpacity; - Vector2 _alongVector; + Vec2 _alongVector; bool _compressedInterpolation; }; diff --git a/cocos/2d/CCMenu.cpp b/cocos/2d/CCMenu.cpp index 91bdcba688..8d2fb39307 100644 --- a/cocos/2d/CCMenu.cpp +++ b/cocos/2d/CCMenu.cpp @@ -138,10 +138,10 @@ bool Menu::initWithArray(const Vector& arrayOfItems) Size s = Director::getInstance()->getWinSize(); this->ignoreAnchorPointForPosition(true); - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); this->setContentSize(s); - setPosition(Vector2(s.width/2, s.height/2)); + setPosition(Vec2(s.width/2, s.height/2)); int z=0; @@ -315,7 +315,7 @@ void Menu::alignItemsVerticallyWithPadding(float padding) float y = height / 2.0f; for(const auto &child : _children) { - child->setPosition(Vector2(0, y - child->getContentSize().height * child->getScaleY() / 2.0f)); + child->setPosition(Vec2(0, y - child->getContentSize().height * child->getScaleY() / 2.0f)); y -= child->getContentSize().height * child->getScaleY() + padding; } } @@ -334,7 +334,7 @@ void Menu::alignItemsHorizontallyWithPadding(float padding) float x = -width / 2.0f; for(const auto &child : _children) { - child->setPosition(Vector2(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0)); + child->setPosition(Vec2(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0)); x += child->getContentSize().width * child->getScaleX() + padding; } } @@ -413,7 +413,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows) float tmp = child->getContentSize().height; rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); - child->setPosition(Vector2(x - winSize.width / 2, + child->setPosition(Vec2(x - winSize.width / 2, y - child->getContentSize().height / 2)); x += w; @@ -514,7 +514,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns) float tmp = child->getContentSize().width; columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp); - child->setPosition(Vector2(x + columnWidths[column] / 2, + child->setPosition(Vec2(x + columnWidths[column] / 2, y - winSize.height / 2)); y -= child->getContentSize().height + 10; @@ -533,7 +533,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns) MenuItem* Menu::getItemForTouch(Touch *touch) { - Vector2 touchLocation = touch->getLocation(); + Vec2 touchLocation = touch->getLocation(); if (!_children.empty()) { @@ -542,9 +542,9 @@ MenuItem* Menu::getItemForTouch(Touch *touch) MenuItem* child = dynamic_cast(*iter); if (child && child->isVisible() && child->isEnabled()) { - Vector2 local = child->convertToNodeSpace(touchLocation); + Vec2 local = child->convertToNodeSpace(touchLocation); Rect r = child->rect(); - r.origin = Vector2::ZERO; + r.origin = Vec2::ZERO; if (r.containsPoint(local)) { diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index a8ae9bc683..79891fbb9a 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -90,7 +90,7 @@ bool MenuItem::initWithTarget(cocos2d::Ref *target, SEL_MenuHandler selector ) bool MenuItem::initWithCallback(const ccMenuCallback& callback) { - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); _callback = callback; _enabled = true; _selected = false; @@ -179,7 +179,7 @@ void MenuItemLabel::setLabel(Node* var) { if (var) { - var->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + var->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); setContentSize(var->getContentSize()); addChild(var); } @@ -483,7 +483,7 @@ void MenuItemSprite::setNormalImage(Node* image) if (image) { addChild(image, 0, kNormalTag); - image->setAnchorPoint(Vector2(0, 0)); + image->setAnchorPoint(Vec2(0, 0)); } if (_normalImage) @@ -504,7 +504,7 @@ void MenuItemSprite::setSelectedImage(Node* image) if (image) { addChild(image, 0, kSelectedTag); - image->setAnchorPoint(Vector2(0, 0)); + image->setAnchorPoint(Vec2(0, 0)); } if (_selectedImage) @@ -524,7 +524,7 @@ void MenuItemSprite::setDisabledImage(Node* image) if (image) { addChild(image, 0, kDisableTag); - image->setAnchorPoint(Vector2(0, 0)); + image->setAnchorPoint(Vec2(0, 0)); } if (_disabledImage) @@ -935,7 +935,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index) this->addChild(item, 0, kCurrentItem); Size s = item->getContentSize(); this->setContentSize(s); - item->setPosition( Vector2( s.width/2, s.height/2 ) ); + item->setPosition( Vec2( s.width/2, s.height/2 ) ); } } diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 3ec2972d44..09fa33dc68 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -41,7 +41,7 @@ MotionStreak::MotionStreak() , _startingPositionInitialized(false) , _texture(nullptr) , _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) -, _positionR(Vector2::ZERO) +, _positionR(Vec2::ZERO) , _stroke(0.0f) , _fadeDelta(0.0f) , _minSeg(0.0f) @@ -102,12 +102,12 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture) { - Node::setPosition(Vector2::ZERO); - setAnchorPoint(Vector2::ZERO); + Node::setPosition(Vec2::ZERO); + setAnchorPoint(Vec2::ZERO); ignoreAnchorPointForPosition(true); _startingPositionInitialized = false; - _positionR = Vector2::ZERO; + _positionR = Vec2::ZERO; _fastMode = true; _minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg; _minSeg *= _minSeg; @@ -118,9 +118,9 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co _maxPoints = (int)(fade*60.0f)+2; _nuPoints = 0; _pointState = (float *)malloc(sizeof(float) * _maxPoints); - _pointVertexes = (Vector2*)malloc(sizeof(Vector2) * _maxPoints); + _pointVertexes = (Vec2*)malloc(sizeof(Vec2) * _maxPoints); - _vertices = (Vector2*)malloc(sizeof(Vector2) * _maxPoints * 2); + _vertices = (Vec2*)malloc(sizeof(Vec2) * _maxPoints * 2); _texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2); _colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4); @@ -137,7 +137,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co return true; } -void MotionStreak::setPosition(const Vector2& position) +void MotionStreak::setPosition(const Vec2& position) { if (!_startingPositionInitialized) { _startingPositionInitialized = true; @@ -154,7 +154,7 @@ void MotionStreak::setPosition(float x, float y) _positionR.y = y; } -const Vector2& MotionStreak::getPosition() const +const Vec2& MotionStreak::getPosition() const { return _positionR; } @@ -373,7 +373,7 @@ void MotionStreak::reset() _nuPoints = 0; } -void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated) +void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -385,7 +385,7 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated) #ifdef EMSCRIPTEN // Size calculations from ::initWithFade - setGLBufferData(_vertices, (sizeof(Vector2) * _maxPoints * 2), 0); + setGLBufferData(_vertices, (sizeof(Vec2) * _maxPoints * 2), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1); @@ -403,7 +403,7 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated) CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2); } -void MotionStreak::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if(_nuPoints <= 1) return; diff --git a/cocos/2d/CCMotionStreak.h b/cocos/2d/CCMotionStreak.h index 295ca3a9ec..20cfcf87ef 100644 --- a/cocos/2d/CCMotionStreak.h +++ b/cocos/2d/CCMotionStreak.h @@ -73,9 +73,9 @@ public: } // Overrides - virtual void setPosition(const Vector2& position) override; + virtual void setPosition(const Vec2& position) override; virtual void setPosition(float x, float y) override; - virtual const Vector2& getPosition() const override; + virtual const Vec2& getPosition() const override; virtual void getPosition(float* x, float* y) const override; virtual void setPositionX(float x) override; virtual void setPositionY(float y) override; @@ -85,7 +85,7 @@ public: * @js NA * @lua NA */ - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; /** * @js NA * @lua NA @@ -120,7 +120,7 @@ CC_CONSTRUCTOR_ACCESS: protected: //renderer callback - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); bool _fastMode; bool _startingPositionInitialized; @@ -128,7 +128,7 @@ protected: /** texture used for the motion streak */ Texture2D* _texture; BlendFunc _blendFunc; - Vector2 _positionR; + Vec2 _positionR; float _stroke; float _fadeDelta; @@ -139,11 +139,11 @@ protected: unsigned int _previousNuPoints; /** Pointers */ - Vector2* _pointVertexes; + Vec2* _pointVertexes; float* _pointState; // Opengl - Vector2* _vertices; + Vec2* _vertices; GLubyte* _colorPointer; Tex2F* _texCoords; diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 2d3ba688e9..461550ab50 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -81,11 +81,11 @@ Node::Node(void) , _scaleY(1.0f) , _scaleZ(1.0f) , _positionZ(0.0f) -, _position(Vector2::ZERO) +, _position(Vec2::ZERO) , _skewX(0.0f) , _skewY(0.0f) -, _anchorPointInPoints(Vector2::ZERO) -, _anchorPoint(Vector2::ZERO) +, _anchorPointInPoints(Vec2::ZERO) +, _anchorPoint(Vec2::ZERO) , _contentSize(Size::ZERO) , _useAdditionalTransform(false) , _transformDirty(true) @@ -135,7 +135,7 @@ Node::Node(void) ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; #endif - _transform = _inverse = _additionalTransform = Matrix::IDENTITY; + _transform = _inverse = _additionalTransform = Mat4::IDENTITY; } Node::~Node() @@ -277,7 +277,7 @@ float Node::getRotationSkewX() const return _rotationZ_X; } -void Node::setRotation3D(const Vector3& rotation) +void Node::setRotation3D(const Vec3& rotation) { if (_rotationX == rotation.x && _rotationY == rotation.y && @@ -301,12 +301,12 @@ void Node::setRotation3D(const Vector3& rotation) #endif } -Vector3 Node::getRotation3D() const +Vec3 Node::getRotation3D() const { // rotation Z is decomposed in 2 to simulate Skew for Flash animations CCASSERT(_rotationZ_X == _rotationZ_Y, "_rotationZ_X != _rotationZ_Y"); - return Vector3(_rotationX,_rotationY,_rotationZ_X); + return Vec3(_rotationX,_rotationY,_rotationZ_X); } void Node::setRotationSkewX(float rotationX) @@ -410,13 +410,13 @@ void Node::setScaleY(float scaleY) /// position getter -const Vector2& Node::getPosition() const +const Vec2& Node::getPosition() const { return _position; } /// position setter -void Node::setPosition(const Vector2& position) +void Node::setPosition(const Vec2& position) { if (_position.equals(position)) return; @@ -441,18 +441,18 @@ void Node::getPosition(float* x, float* y) const void Node::setPosition(float x, float y) { - setPosition(Vector2(x, y)); + setPosition(Vec2(x, y)); } -void Node::setPosition3D(const Vector3& position) +void Node::setPosition3D(const Vec3& position) { _positionZ = position.z; - setPosition(Vector2(position.x, position.y)); + setPosition(Vec2(position.x, position.y)); } -Vector3 Node::getPosition3D() const +Vec3 Node::getPosition3D() const { - Vector3 ret; + Vec3 ret; ret.x = _position.x; ret.y = _position.y; ret.z = _positionZ; @@ -466,7 +466,7 @@ float Node::getPositionX() const void Node::setPositionX(float x) { - setPosition(Vector2(x, _position.y)); + setPosition(Vec2(x, _position.y)); } float Node::getPositionY() const @@ -476,7 +476,7 @@ float Node::getPositionY() const void Node::setPositionY(float y) { - setPosition(Vector2(_position.x, y)); + setPosition(Vec2(_position.x, y)); } float Node::getPositionZ() const @@ -519,21 +519,21 @@ void Node::setVisible(bool var) } } -const Vector2& Node::getAnchorPointInPoints() const +const Vec2& Node::getAnchorPointInPoints() const { return _anchorPointInPoints; } /// anchorPoint getter -const Vector2& Node::getAnchorPoint() const +const Vec2& Node::getAnchorPoint() const { return _anchorPoint; } -void Node::setAnchorPoint(const Vector2& point) +void Node::setAnchorPoint(const Vec2& point) { #if CC_USE_PHYSICS - if (_physicsBody != nullptr && !point.equals(Vector2::ANCHOR_MIDDLE)) + if (_physicsBody != nullptr && !point.equals(Vec2::ANCHOR_MIDDLE)) { CCLOG("Node warning: This node has a physics body, the anchor must be in the middle, you cann't change this to other value."); return; @@ -543,7 +543,7 @@ void Node::setAnchorPoint(const Vector2& point) if( ! point.equals(_anchorPoint)) { _anchorPoint = point; - _anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); + _anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); _transformUpdated = _transformDirty = _inverseDirty = true; } } @@ -560,7 +560,7 @@ void Node::setContentSize(const Size & size) { _contentSize = size; - _anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); + _anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); _transformUpdated = _transformDirty = _inverseDirty = true; } } @@ -943,18 +943,18 @@ void Node::draw() draw(renderer, _modelViewTransform, true); } -void Node::draw(Renderer* renderer, const Matrix &transform, bool transformUpdated) +void Node::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated) { } void Node::visit() { auto renderer = Director::getInstance()->getRenderer(); - Matrix parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + Mat4 parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); visit(renderer, parentTransform, true); } -void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -969,7 +969,7 @@ void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentT // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1008,9 +1008,9 @@ void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentT director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -Matrix Node::transform(const Matrix& parentTransform) +Mat4 Node::transform(const Mat4& parentTransform) { - Matrix ret = this->getNodeToParentTransform(); + Mat4 ret = this->getNodeToParentTransform(); ret = parentTransform * ret; return ret; } @@ -1338,7 +1338,7 @@ AffineTransform Node::getNodeToParentAffineTransform() const return ret; } -const Matrix& Node::getNodeToParentTransform() const +const Mat4& Node::getNodeToParentTransform() const { if (_transformDirty) { @@ -1373,7 +1373,7 @@ const Matrix& Node::getNodeToParentTransform() const // optimization: // inline anchor point calculation if skew is not needed // Adjusted transform calculation for rotational skew - if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vector2::ZERO)) + if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO)) { x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY; y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY; @@ -1394,13 +1394,13 @@ const Matrix& Node::getNodeToParentTransform() const // FIX ME: Expensive operation. // FIX ME: It should be done together with the rotationZ if(_rotationY) { - Matrix rotY; - Matrix::createRotationY(CC_DEGREES_TO_RADIANS(_rotationY), &rotY); + Mat4 rotY; + Mat4::createRotationY(CC_DEGREES_TO_RADIANS(_rotationY), &rotY); _transform = _transform * rotY; } if(_rotationX) { - Matrix rotX; - Matrix::createRotationX(CC_DEGREES_TO_RADIANS(_rotationX), &rotX); + Mat4 rotX; + Mat4::createRotationX(CC_DEGREES_TO_RADIANS(_rotationX), &rotX); _transform = _transform * rotX; } @@ -1408,7 +1408,7 @@ const Matrix& Node::getNodeToParentTransform() const // If skew is needed, apply skew and then anchor point if (needsSkewMatrix) { - Matrix skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, + Mat4 skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); @@ -1416,9 +1416,9 @@ const Matrix& Node::getNodeToParentTransform() const _transform = _transform * skewMatrix; // adjust anchor point - if (!_anchorPointInPoints.equals(Vector2::ZERO)) + if (!_anchorPointInPoints.equals(Vec2::ZERO)) { - // XXX: Argh, Matrix needs a "translate" method. + // XXX: Argh, Mat4 needs a "translate" method. // XXX: Although this is faster than multiplying a vec4 * mat4 _transform.m[12] += _transform.m[0] * -_anchorPointInPoints.x + _transform.m[4] * -_anchorPointInPoints.y; _transform.m[13] += _transform.m[1] * -_anchorPointInPoints.x + _transform.m[5] * -_anchorPointInPoints.y; @@ -1436,7 +1436,7 @@ const Matrix& Node::getNodeToParentTransform() const return _transform; } -void Node::setNodeToParentTransform(const Matrix& transform) +void Node::setNodeToParentTransform(const Mat4& transform) { _transform = transform; _transformDirty = false; @@ -1445,12 +1445,12 @@ void Node::setNodeToParentTransform(const Matrix& transform) void Node::setAdditionalTransform(const AffineTransform& additionalTransform) { - Matrix tmp; + Mat4 tmp; CGAffineToGL(additionalTransform, tmp.m); setAdditionalTransform(&tmp); } -void Node::setAdditionalTransform(Matrix* additionalTransform) +void Node::setAdditionalTransform(Mat4* additionalTransform) { if(additionalTransform == nullptr) { _useAdditionalTransform = false; @@ -1465,13 +1465,13 @@ void Node::setAdditionalTransform(Matrix* additionalTransform) AffineTransform Node::getParentToNodeAffineTransform() const { AffineTransform ret; - Matrix ret4 = getParentToNodeTransform(); + Mat4 ret4 = getParentToNodeTransform(); GLToCGAffine(ret4.m,&ret); return ret; } -const Matrix& Node::getParentToNodeTransform() const +const Mat4& Node::getParentToNodeTransform() const { if ( _inverseDirty ) { _inverse = _transform.getInversed(); @@ -1492,9 +1492,9 @@ AffineTransform Node::getNodeToWorldAffineTransform() const return t; } -Matrix Node::getNodeToWorldTransform() const +Mat4 Node::getNodeToWorldTransform() const { - Matrix t = this->getNodeToParentTransform(); + Mat4 t = this->getNodeToParentTransform(); for (Node *p = _parent; p != nullptr; p = p->getParent()) { @@ -1509,59 +1509,59 @@ AffineTransform Node::getWorldToNodeAffineTransform() const return AffineTransformInvert(this->getNodeToWorldAffineTransform()); } -Matrix Node::getWorldToNodeTransform() const +Mat4 Node::getWorldToNodeTransform() const { return getNodeToWorldTransform().getInversed(); } -Vector2 Node::convertToNodeSpace(const Vector2& worldPoint) const +Vec2 Node::convertToNodeSpace(const Vec2& worldPoint) const { - Matrix tmp = getWorldToNodeTransform(); - Vector3 vec3(worldPoint.x, worldPoint.y, 0); - Vector3 ret; + Mat4 tmp = getWorldToNodeTransform(); + Vec3 vec3(worldPoint.x, worldPoint.y, 0); + Vec3 ret; tmp.transformPoint(vec3,&ret); - return Vector2(ret.x, ret.y); + return Vec2(ret.x, ret.y); } -Vector2 Node::convertToWorldSpace(const Vector2& nodePoint) const +Vec2 Node::convertToWorldSpace(const Vec2& nodePoint) const { - Matrix tmp = getNodeToWorldTransform(); - Vector3 vec3(nodePoint.x, nodePoint.y, 0); - Vector3 ret; + Mat4 tmp = getNodeToWorldTransform(); + Vec3 vec3(nodePoint.x, nodePoint.y, 0); + Vec3 ret; tmp.transformPoint(vec3,&ret); - return Vector2(ret.x, ret.y); + return Vec2(ret.x, ret.y); } -Vector2 Node::convertToNodeSpaceAR(const Vector2& worldPoint) const +Vec2 Node::convertToNodeSpaceAR(const Vec2& worldPoint) const { - Vector2 nodePoint = convertToNodeSpace(worldPoint); + Vec2 nodePoint = convertToNodeSpace(worldPoint); return nodePoint - _anchorPointInPoints; } -Vector2 Node::convertToWorldSpaceAR(const Vector2& nodePoint) const +Vec2 Node::convertToWorldSpaceAR(const Vec2& nodePoint) const { - Vector2 pt = nodePoint + _anchorPointInPoints; + Vec2 pt = nodePoint + _anchorPointInPoints; return convertToWorldSpace(pt); } -Vector2 Node::convertToWindowSpace(const Vector2& nodePoint) const +Vec2 Node::convertToWindowSpace(const Vec2& nodePoint) const { - Vector2 worldPoint = this->convertToWorldSpace(nodePoint); + Vec2 worldPoint = this->convertToWorldSpace(nodePoint); return Director::getInstance()->convertToUI(worldPoint); } -// convenience methods which take a Touch instead of Vector2 -Vector2 Node::convertTouchToNodeSpace(Touch *touch) const +// convenience methods which take a Touch instead of Vec2 +Vec2 Node::convertTouchToNodeSpace(Touch *touch) const { - Vector2 point = touch->getLocation(); + Vec2 point = touch->getLocation(); return this->convertToNodeSpace(point); } -Vector2 Node::convertTouchToNodeSpaceAR(Touch *touch) const +Vec2 Node::convertTouchToNodeSpaceAR(Touch *touch) const { - Vector2 point = touch->getLocation(); + Vec2 point = touch->getLocation(); return this->convertToNodeSpaceAR(point); } @@ -1608,7 +1608,7 @@ void Node::updatePhysicsBodyPosition(Scene* scene) { if (scene != nullptr && scene->getPhysicsWorld() != nullptr) { - Vector2 pos = getParent() == scene ? getPosition() : scene->convertToNodeSpace(_parent->convertToWorldSpace(getPosition())); + Vec2 pos = getParent() == scene ? getPosition() : scene->convertToNodeSpace(_parent->convertToWorldSpace(getPosition())); _physicsBody->setPosition(pos); } else @@ -1647,10 +1647,10 @@ void Node::setPhysicsBody(PhysicsBody* body) // physics rotation based on body position, but node rotation based on node anthor point // it cann't support both of them, so I clear the anthor point to default. - if (!getAnchorPoint().equals(Vector2::ANCHOR_MIDDLE)) + if (!getAnchorPoint().equals(Vec2::ANCHOR_MIDDLE)) { - CCLOG("Node warning: setPhysicsBody sets anchor point to Vector2::ANCHOR_MIDDLE."); - setAnchorPoint(Vector2::ANCHOR_MIDDLE); + CCLOG("Node warning: setPhysicsBody sets anchor point to Vec2::ANCHOR_MIDDLE."); + setAnchorPoint(Vec2::ANCHOR_MIDDLE); } } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 3f7f20d38c..f8a52ca287 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -273,37 +273,37 @@ public: /** * Sets the position (x,y) of the node in its parent's coordinate system. * - * Usually we use `Vector2(x,y)` to compose Vector2 object. + * Usually we use `Vec2(x,y)` to compose Vec2 object. * This code snippet sets the node in the center of screen. @code Size size = Director::getInstance()->getWinSize(); - node->setPosition( Vector2(size.width/2, size.height/2) ) + node->setPosition( Vec2(size.width/2, size.height/2) ) @endcode * * @param position The position (x,y) of the node in OpenGL coordinates */ - virtual void setPosition(const Vector2 &position); + virtual void setPosition(const Vec2 &position); /** * Gets the position (x,y) of the node in its parent's coordinate system. * - * @see setPosition(const Vector2&) + * @see setPosition(const Vec2&) * * @return The position (x,y) of the node in OpenGL coordinates * @code * In js and lua return value is table which contains x,y * @endcode */ - virtual const Vector2& getPosition() const; + virtual const Vec2& getPosition() const; /** * Sets the position (x,y) of the node in its parent's coordinate system. * - * Passing two numbers (x,y) is much efficient than passing Vector2 object. + * Passing two numbers (x,y) is much efficient than passing Vec2 object. * This method is bound to Lua and JavaScript. * Passing a number is 10 times faster than passing a object from Lua to c++ * @code // sample code in Lua - local pos = node::getPosition() -- returns Vector2 object from C++ + local pos = node::getPosition() -- returns Vec2 object from C++ node:setPosition(x, y) -- pass x, y coordinate to C++ @endcode * @@ -312,7 +312,7 @@ public: */ virtual void setPosition(float x, float y); /** - * Gets position in a more efficient way, returns two number instead of a Vector2 object + * Gets position in a more efficient way, returns two number instead of a Vec2 object * * @see `setPosition(float, float)` * In js,out value not return @@ -330,11 +330,11 @@ public: /** * Sets the position (X, Y, and Z) in its parent's coordinate system */ - virtual void setPosition3D(const Vector3& position); + virtual void setPosition3D(const Vec3& position); /** * returns the position (X,Y,Z) in its parent's coordinate system */ - virtual Vector3 getPosition3D() const; + virtual Vec3 getPosition3D() const; /** * Sets the 'z' coordinate in the position. It is the OpenGL Z vertex value. @@ -419,15 +419,15 @@ public: * * @param anchorPoint The anchor point of node. */ - virtual void setAnchorPoint(const Vector2& anchorPoint); + virtual void setAnchorPoint(const Vec2& anchorPoint); /** * Returns the anchor point in percent. * - * @see `setAnchorPoint(const Vector2&)` + * @see `setAnchorPoint(const Vec2&)` * * @return The anchor point of node. */ - virtual const Vector2& getAnchorPoint() const; + virtual const Vec2& getAnchorPoint() const; /** * Returns the anchorPoint in absolute pixels. * @@ -436,7 +436,7 @@ public: * * @return The anchor point in absolute pixels. */ - virtual const Vector2& getAnchorPointInPoints() const; + virtual const Vec2& getAnchorPointInPoints() const; /** @@ -498,11 +498,11 @@ public: * Sets the rotation (X,Y,Z) in degrees. * Useful for 3d rotations */ - virtual void setRotation3D(const Vector3& rotation); + virtual void setRotation3D(const Vec3& rotation); /** * returns the rotation (X,Y,Z) in degrees. */ - virtual Vector3 getRotation3D() const; + virtual Vec3 getRotation3D() const; /** * Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew. @@ -923,13 +923,13 @@ public: * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE * But if you enable any other GL state, you should disable it after drawing your node. */ - virtual void draw(Renderer *renderer, const Matrix& transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated); virtual void draw() final; /** * Visits this node's children and draw them recursively. */ - virtual void visit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated); + virtual void visit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated); virtual void visit() final; @@ -1194,13 +1194,13 @@ public: * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. * The matrix is in Pixels. */ - virtual const Matrix& getNodeToParentTransform() const; + virtual const Mat4& getNodeToParentTransform() const; virtual AffineTransform getNodeToParentAffineTransform() const; /** * Sets the Transformation matrix manually. */ - virtual void setNodeToParentTransform(const Matrix& transform); + virtual void setNodeToParentTransform(const Mat4& transform); /** @deprecated use getNodeToParentTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentAffineTransform(); } @@ -1209,7 +1209,7 @@ public: * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. * The matrix is in Pixels. */ - virtual const Matrix& getParentToNodeTransform() const; + virtual const Mat4& getParentToNodeTransform() const; virtual AffineTransform getParentToNodeAffineTransform() const; /** @deprecated Use getParentToNodeTransform() instead */ @@ -1218,7 +1218,7 @@ public: /** * Returns the world affine transform matrix. The matrix is in Pixels. */ - virtual Matrix getNodeToWorldTransform() const; + virtual Mat4 getNodeToWorldTransform() const; virtual AffineTransform getNodeToWorldAffineTransform() const; /** @deprecated Use getNodeToWorldTransform() instead */ @@ -1227,7 +1227,7 @@ public: /** * Returns the inverse world affine transform matrix. The matrix is in Pixels. */ - virtual Matrix getWorldToNodeTransform() const; + virtual Mat4 getWorldToNodeTransform() const; virtual AffineTransform getWorldToNodeAffineTransform() const; @@ -1241,36 +1241,36 @@ public: /// @name Coordinate Converters /** - * Converts a Vector2 to node (local) space coordinates. The result is in Points. + * Converts a Vec2 to node (local) space coordinates. The result is in Points. */ - Vector2 convertToNodeSpace(const Vector2& worldPoint) const; + Vec2 convertToNodeSpace(const Vec2& worldPoint) const; /** - * Converts a Vector2 to world space coordinates. The result is in Points. + * Converts a Vec2 to world space coordinates. The result is in Points. */ - Vector2 convertToWorldSpace(const Vector2& nodePoint) const; + Vec2 convertToWorldSpace(const Vec2& nodePoint) const; /** - * Converts a Vector2 to node (local) space coordinates. The result is in Points. + * Converts a Vec2 to node (local) space coordinates. The result is in Points. * treating the returned/received node point as anchor relative. */ - Vector2 convertToNodeSpaceAR(const Vector2& worldPoint) const; + Vec2 convertToNodeSpaceAR(const Vec2& worldPoint) const; /** - * Converts a local Vector2 to world space coordinates.The result is in Points. + * Converts a local Vec2 to world space coordinates.The result is in Points. * treating the returned/received node point as anchor relative. */ - Vector2 convertToWorldSpaceAR(const Vector2& nodePoint) const; + Vec2 convertToWorldSpaceAR(const Vec2& nodePoint) const; /** - * convenience methods which take a Touch instead of Vector2 + * convenience methods which take a Touch instead of Vec2 */ - Vector2 convertTouchToNodeSpace(Touch * touch) const; + Vec2 convertTouchToNodeSpace(Touch * touch) const; /** * converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). */ - Vector2 convertTouchToNodeSpaceAR(Touch * touch) const; + Vec2 convertTouchToNodeSpaceAR(Touch * touch) const; /** * Sets an additional transform matrix to the node. @@ -1280,7 +1280,7 @@ public: * @note The additional transform will be concatenated at the end of getNodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). */ - void setAdditionalTransform(Matrix* additionalTransform); + void setAdditionalTransform(Mat4* additionalTransform); void setAdditionalTransform(const AffineTransform& additionalTransform); /// @} end of Coordinate Converters @@ -1312,7 +1312,7 @@ public: #if CC_USE_PHYSICS /** * set the PhysicsBody that let the sprite effect with physics - * @note This method will set anchor point to Vector2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body. + * @note This method will set anchor point to Vec2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body. */ void setPhysicsBody(PhysicsBody* body); @@ -1359,9 +1359,9 @@ protected: void detachChild(Node *child, ssize_t index, bool doCleanup); /// Convert cocos2d coordinates to UI windows coordinate. - Vector2 convertToWindowSpace(const Vector2& nodePoint) const; + Vec2 convertToWindowSpace(const Vec2& nodePoint) const; - Matrix transform(const Matrix &parentTransform); + Mat4 transform(const Mat4 &parentTransform); virtual void updateCascadeOpacity(); virtual void disableCascadeOpacity(); @@ -1385,25 +1385,25 @@ protected: float _scaleY; ///< scaling factor on y-axis float _scaleZ; ///< scaling factor on z-axis - Vector2 _position; ///< position of the node + Vec2 _position; ///< position of the node float _positionZ; ///< OpenGL real Z position float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis - Vector2 _anchorPointInPoints; ///< anchor point in points - Vector2 _anchorPoint; ///< anchor point normalized (NOT in points) + Vec2 _anchorPointInPoints; ///< anchor point in points + Vec2 _anchorPoint; ///< anchor point normalized (NOT in points) Size _contentSize; ///< untransformed size of the node - Matrix _modelViewTransform; ///< ModelView transform of the Node. + Mat4 _modelViewTransform; ///< ModelView transform of the Node. // "cache" variables are allowed to be mutable - mutable Matrix _transform; ///< transform + mutable Mat4 _transform; ///< transform mutable bool _transformDirty; ///< transform dirty flag - mutable Matrix _inverse; ///< inverse transform + mutable Mat4 _inverse; ///< inverse transform mutable bool _inverseDirty; ///< inverse transform dirty flag - mutable Matrix _additionalTransform; ///< transform + mutable Mat4 _additionalTransform; ///< transform bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty bool _transformUpdated; ///< Whether or not the Transform object was updated since the last frame @@ -1434,7 +1434,7 @@ protected: bool _visible; ///< is this node visible - bool _ignoreAnchorPointForPosition; ///< true if the Anchor Vector2 will be (0,0) when you position the Node, false otherwise. + bool _ignoreAnchorPointForPosition; ///< true if the Anchor Vec2 will be (0,0) when you position the Node, false otherwise. ///< Used by Layer and Scene. bool _reorderChildDirty; ///< children order dirty flag diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index ca4b7aa105..7d4fbf9385 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw() } } -void NodeGrid::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -100,7 +100,7 @@ void NodeGrid::visit(Renderer *renderer, const Matrix &parentTransform, bool par _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/cocos/2d/CCNodeGrid.h b/cocos/2d/CCNodeGrid.h index 342553bdf1..d36f39ca7d 100644 --- a/cocos/2d/CCNodeGrid.h +++ b/cocos/2d/CCNodeGrid.h @@ -54,7 +54,7 @@ public: void setTarget(Node *target); // overrides - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; protected: NodeGrid(); diff --git a/cocos/2d/CCParallaxNode.cpp b/cocos/2d/CCParallaxNode.cpp index 0db8acdb7a..86f89e867f 100644 --- a/cocos/2d/CCParallaxNode.cpp +++ b/cocos/2d/CCParallaxNode.cpp @@ -32,7 +32,7 @@ NS_CC_BEGIN class PointObject : public Ref { public: - static PointObject * create(Vector2 ratio, Vector2 offset) + static PointObject * create(Vec2 ratio, Vec2 offset) { PointObject *ret = new PointObject(); ret->initWithPoint(ratio, offset); @@ -40,7 +40,7 @@ public: return ret; } - bool initWithPoint(Vector2 ratio, Vector2 offset) + bool initWithPoint(Vec2 ratio, Vec2 offset) { _ratio = ratio; _offset = offset; @@ -48,25 +48,25 @@ public: return true; } - inline const Vector2& getRatio() const { return _ratio; }; - inline void setRatio(const Vector2& ratio) { _ratio = ratio; }; + inline const Vec2& getRatio() const { return _ratio; }; + inline void setRatio(const Vec2& ratio) { _ratio = ratio; }; - inline const Vector2& getOffset() const { return _offset; }; - inline void setOffset(const Vector2& offset) { _offset = offset; }; + inline const Vec2& getOffset() const { return _offset; }; + inline void setOffset(const Vec2& offset) { _offset = offset; }; inline Node* getChild() const { return _child; }; inline void setChild(Node* child) { _child = child; }; private: - Vector2 _ratio; - Vector2 _offset; + Vec2 _ratio; + Vec2 _offset; Node *_child; // weak ref }; ParallaxNode::ParallaxNode() { _parallaxArray = ccArrayNew(5); - _lastPosition = Vector2(-100,-100); + _lastPosition = Vec2(-100,-100); } ParallaxNode::~ParallaxNode() @@ -93,14 +93,14 @@ void ParallaxNode::addChild(Node * child, int zOrder, int tag) CCASSERT(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead"); } -void ParallaxNode::addChild(Node *child, int z, const Vector2& ratio, const Vector2& offset) +void ParallaxNode::addChild(Node *child, int z, const Vec2& ratio, const Vec2& offset) { CCASSERT( child != nullptr, "Argument must be non-nil"); PointObject *obj = PointObject::create(ratio, offset); obj->setChild(child); ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj); - Vector2 pos = this->absolutePosition(); + Vec2 pos = this->absolutePosition(); pos.x = -pos.x + pos.x * ratio.x + offset.x; pos.y = -pos.y + pos.y * ratio.y + offset.y; child->setPosition(pos); @@ -128,9 +128,9 @@ void ParallaxNode::removeAllChildrenWithCleanup(bool cleanup) Node::removeAllChildrenWithCleanup(cleanup); } -Vector2 ParallaxNode::absolutePosition() +Vec2 ParallaxNode::absolutePosition() { - Vector2 ret = _position; + Vec2 ret = _position; Node *cn = this; while (cn->getParent() != nullptr) { @@ -145,11 +145,11 @@ The positions are updated at visit because: - using a timer is not guaranteed that it will called after all the positions were updated - overriding "draw" will only precise if the children have a z > 0 */ -void ParallaxNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { - // Vector2 pos = position_; - // Vector2 pos = [self convertToWorldSpace:Vector2::ZERO]; - Vector2 pos = this->absolutePosition(); + // Vec2 pos = position_; + // Vec2 pos = [self convertToWorldSpace:Vec2::ZERO]; + Vec2 pos = this->absolutePosition(); if( ! pos.equals(_lastPosition) ) { for( int i=0; i < _parallaxArray->num; i++ ) @@ -157,7 +157,7 @@ void ParallaxNode::visit(Renderer *renderer, const Matrix &parentTransform, bool PointObject *point = (PointObject*)_parallaxArray->arr[i]; float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x; float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y; - point->getChild()->setPosition(Vector2(x,y)); + point->getChild()->setPosition(Vec2(x,y)); } _lastPosition = pos; } diff --git a/cocos/2d/CCParallaxNode.h b/cocos/2d/CCParallaxNode.h index 54dc3897dc..66e92b078b 100644 --- a/cocos/2d/CCParallaxNode.h +++ b/cocos/2d/CCParallaxNode.h @@ -53,7 +53,7 @@ public: // prevents compiler warning: "Included function hides overloaded virtual functions" using Node::addChild; - void addChild(Node * child, int z, const Vector2& parallaxRatio, const Vector2& positionOffset); + void addChild(Node * child, int z, const Vec2& parallaxRatio, const Vec2& positionOffset); /** Sets an array of layers for the Parallax node */ void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; } @@ -67,7 +67,7 @@ public: virtual void addChild(Node * child, int zOrder, int tag) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; protected: /** Adds a child to the container with a z-order, a parallax ratio and a position offset @@ -82,9 +82,9 @@ protected: */ virtual ~ParallaxNode(); - Vector2 absolutePosition(); + Vec2 absolutePosition(); - Vector2 _lastPosition; + Vec2 _lastPosition; struct _ccArray* _parallaxArray; private: diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 77bca62e7e..9b2177fe28 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -121,7 +121,7 @@ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity) // override visit. // Don't call visit on it's children -void ParticleBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // CAREFUL: // This visit is almost identical to Node#visit @@ -141,7 +141,7 @@ void ParticleBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -383,7 +383,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup) _textureAtlas->removeAllQuads(); } -void ParticleBatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { CC_PROFILER_START("CCParticleBatchNode - draw"); diff --git a/cocos/2d/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h index 530aa483da..2b6d716a94 100644 --- a/cocos/2d/CCParticleBatchNode.h +++ b/cocos/2d/CCParticleBatchNode.h @@ -91,13 +91,13 @@ public: inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; }; // Overrides - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void reorderChild(Node * child, int zOrder) override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual Texture2D* getTexture(void) const override; virtual void setTexture(Texture2D *texture) override; /** diff --git a/cocos/2d/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp index 402701cc57..6498740b76 100644 --- a/cocos/2d/CCParticleExamples.cpp +++ b/cocos/2d/CCParticleExamples.cpp @@ -98,7 +98,7 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles) this->_emitterMode = Mode::GRAVITY; // Gravity Mode: gravity - this->modeA.gravity = Vector2(0,0); + this->modeA.gravity = Vec2(0,0); // Gravity Mode: radial acceleration this->modeA.radialAccel = 0; @@ -114,8 +114,8 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, 60)); - this->_posVar = Vector2(40, 20); + this->setPosition(Vec2(winSize.width/2, 60)); + this->_posVar = Vec2(40, 20); // life of particles _life = 3; @@ -203,7 +203,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles) this->_emitterMode = Mode::GRAVITY; // Gravity Mode: gravity - this->modeA.gravity = Vector2(0,-90); + this->modeA.gravity = Vec2(0,-90); // Gravity Mode: radial this->modeA.radialAccel = 0; @@ -215,7 +215,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); // angle this->_angle= 90; @@ -307,7 +307,7 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity mode: radial acceleration setRadialAccel(0); @@ -324,8 +324,8 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles _life = 1; @@ -411,7 +411,7 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity Mode: speed of particles setSpeed(60); @@ -431,8 +431,8 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles _life = 4; @@ -520,7 +520,7 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity Mode: speed of particles setSpeed(80); @@ -540,8 +540,8 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles _life = 4; @@ -628,7 +628,7 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(-200,200)); + setGravity(Vec2(-200,200)); // Gravity Mode: speed of particles setSpeed(15); @@ -648,8 +648,8 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles _life = 2; @@ -737,7 +737,7 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity Mode: speed of particles setSpeed(150); @@ -757,8 +757,8 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles _life = 12; @@ -845,7 +845,7 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity Mode: speed of particles setSpeed(70); @@ -865,8 +865,8 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + this->setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles _life = 5.0f; @@ -954,7 +954,7 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity Mode: radial acceleration setRadialAccel(0); @@ -970,8 +970,8 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, 0)); - setPosVar(Vector2(20, 0)); + this->setPosition(Vec2(winSize.width/2, 0)); + setPosVar(Vec2(20, 0)); // life of particles _life = 4; @@ -1059,7 +1059,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,-1)); + setGravity(Vec2(0,-1)); // Gravity Mode: speed of particles setSpeed(5); @@ -1075,8 +1075,8 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height + 10)); - setPosVar(Vector2(winSize.width/2, 0)); + this->setPosition(Vec2(winSize.width/2, winSize.height + 10)); + setPosVar(Vec2(winSize.width/2, 0)); // angle _angle = -90; @@ -1166,7 +1166,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles) setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(10,-10)); + setGravity(Vec2(10,-10)); // Gravity Mode: radial setRadialAccel(0); @@ -1187,8 +1187,8 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); - this->setPosition(Vector2(winSize.width/2, winSize.height)); - setPosVar(Vector2(winSize.width/2, 0)); + this->setPosition(Vec2(winSize.width/2, winSize.height)); + setPosVar(Vec2(winSize.width/2, 0)); // life of particles _life = 4.5f; diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index 368e99a582..eafe9e19d0 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -97,8 +97,8 @@ ParticleSystem::ParticleSystem() , _isActive(true) , _particleCount(0) , _duration(0) -, _sourcePosition(Vector2::ZERO) -, _posVar(Vector2::ZERO) +, _sourcePosition(Vec2::ZERO) +, _posVar(Vec2::ZERO) , _life(0) , _lifeVar(0) , _angle(0) @@ -120,7 +120,7 @@ ParticleSystem::ParticleSystem() , _yCoordFlipped(1) , _positionType(PositionType::FREE) { - modeA.gravity = Vector2::ZERO; + modeA.gravity = Vec2::ZERO; modeA.speed = 0; modeA.speedVar = 0; modeA.tangentialAccel = 0; @@ -257,7 +257,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& // position float x = dictionary["sourcePositionx"].asFloat(); float y = dictionary["sourcePositiony"].asFloat(); - this->setPosition( Vector2(x,y) ); + this->setPosition( Vec2(x,y) ); _posVar.x = dictionary["sourcePositionVariancex"].asFloat(); _posVar.y = dictionary["sourcePositionVariancey"].asFloat(); @@ -560,7 +560,7 @@ void ParticleSystem::initParticle(tParticle* particle) // position if (_positionType == PositionType::FREE) { - particle->startPos = this->convertToWorldSpace(Vector2::ZERO); + particle->startPos = this->convertToWorldSpace(Vec2::ZERO); } else if (_positionType == PositionType::RELATIVE) { @@ -573,7 +573,7 @@ void ParticleSystem::initParticle(tParticle* particle) // Mode Gravity: A if (_emitterMode == Mode::GRAVITY) { - Vector2 v(cosf( a ), sinf( a )); + Vec2 v(cosf( a ), sinf( a )); float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1(); // direction @@ -679,10 +679,10 @@ void ParticleSystem::update(float dt) _particleIdx = 0; - Vector2 currentPosition = Vector2::ZERO; + Vec2 currentPosition = Vec2::ZERO; if (_positionType == PositionType::FREE) { - currentPosition = this->convertToWorldSpace(Vector2::ZERO); + currentPosition = this->convertToWorldSpace(Vec2::ZERO); } else if (_positionType == PositionType::RELATIVE) { @@ -702,9 +702,9 @@ void ParticleSystem::update(float dt) // Mode A: gravity, direction, tangential accel & radial accel if (_emitterMode == Mode::GRAVITY) { - Vector2 tmp, radial, tangential; + Vec2 tmp, radial, tangential; - radial = Vector2::ZERO; + radial = Vec2::ZERO; // radial acceleration if (p->pos.x || p->pos.y) { @@ -761,11 +761,11 @@ void ParticleSystem::update(float dt) // update values in quad // - Vector2 newPos; + Vec2 newPos; if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE) { - Vector2 diff = currentPosition - p->startPos; + Vec2 diff = currentPosition - p->startPos; newPos = p->pos - diff; } else @@ -832,7 +832,7 @@ void ParticleSystem::updateWithNoTime(void) this->update(0.0f); } -void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) +void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vec2& newPosition) { CC_UNUSED_PARAM(particle); CC_UNUSED_PARAM(newPosition); @@ -967,13 +967,13 @@ bool ParticleSystem::getRotationIsDir() const return modeA.rotationIsDir; } -void ParticleSystem::setGravity(const Vector2& g) +void ParticleSystem::setGravity(const Vec2& g) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.gravity = g; } -const Vector2& ParticleSystem::getGravity() +const Vec2& ParticleSystem::getGravity() { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.gravity; diff --git a/cocos/2d/CCParticleSystem.h b/cocos/2d/CCParticleSystem.h index 514ea7ecc7..fc2050b7b4 100644 --- a/cocos/2d/CCParticleSystem.h +++ b/cocos/2d/CCParticleSystem.h @@ -45,8 +45,8 @@ class ParticleBatchNode; Structure that contains the values of each particle */ typedef struct sParticle { - Vector2 pos; - Vector2 startPos; + Vec2 pos; + Vec2 startPos; Color4F color; Color4F deltaColor; @@ -63,7 +63,7 @@ typedef struct sParticle { //! Mode A: gravity, direction, radial accel, tangential accel struct { - Vector2 dir; + Vec2 dir; float radialAccel; float tangentialAccel; } modeA; @@ -78,7 +78,7 @@ typedef struct sParticle { }tParticle; -//typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vector2); +//typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vec2); class Texture2D; @@ -192,7 +192,7 @@ public: bool isFull(); //! should be overridden by subclasses - virtual void updateQuadWithParticle(tParticle* particle, const Vector2& newPosition); + virtual void updateQuadWithParticle(tParticle* particle, const Vec2& newPosition); //! should be overridden by subclasses virtual void postStep(); @@ -202,8 +202,8 @@ public: virtual void setAutoRemoveOnFinish(bool var); // mode A - virtual const Vector2& getGravity(); - virtual void setGravity(const Vector2& g); + virtual const Vec2& getGravity(); + virtual void setGravity(const Vec2& g); virtual float getSpeed() const; virtual void setSpeed(float speed); virtual float getSpeedVar() const; @@ -256,12 +256,12 @@ public: inline void setDuration(float duration) { _duration = duration; }; /** sourcePosition of the emitter */ - inline const Vector2& getSourcePosition() const { return _sourcePosition; }; - inline void setSourcePosition(const Vector2& pos) { _sourcePosition = pos; }; + inline const Vec2& getSourcePosition() const { return _sourcePosition; }; + inline void setSourcePosition(const Vec2& pos) { _sourcePosition = pos; }; /** Position variance of the emitter */ - inline const Vector2& getPosVar() const { return _posVar; }; - inline void setPosVar(const Vector2& pos) { _posVar = pos; }; + inline const Vec2& getPosVar() const { return _posVar; }; + inline void setPosVar(const Vec2& pos) { _posVar = pos; }; /** life, and life variation of each particle */ inline float getLife() const { return _life; }; @@ -432,7 +432,7 @@ protected: //! Mode A:Gravity + Tangential Accel + Radial Accel struct { /** Gravity value. Only available in 'Gravity' mode. */ - Vector2 gravity; + Vec2 gravity; /** speed of each particle. Only available in 'Gravity' mode. */ float speed; /** speed variance of each particle. Only available in 'Gravity' mode. */ @@ -503,9 +503,9 @@ protected: /** How many seconds the emitter will run. -1 means 'forever' */ float _duration; /** sourcePosition of the emitter */ - Vector2 _sourcePosition; + Vec2 _sourcePosition; /** Position variance of the emitter */ - Vector2 _posVar; + Vec2 _posVar; /** life, and life variation of each particle */ float _life; /** life variance of each particle */ diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 8cf35514b5..fc4f5fd779 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -239,7 +239,7 @@ void ParticleSystemQuad::setTexture(Texture2D* texture) void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame) { - CCASSERT(spriteFrame->getOffsetInPixels().equals(Vector2::ZERO), + CCASSERT(spriteFrame->getOffsetInPixels().equals(Vec2::ZERO), "QuadParticle only supports SpriteFrames with no offsets"); // update texture before updating texture rect @@ -265,7 +265,7 @@ void ParticleSystemQuad::initIndices() } } -void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) +void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vec2& newPosition) { V3F_C4B_T2F_Quad *quad; @@ -368,7 +368,7 @@ void ParticleSystemQuad::postStep() } // overriding draw method -void ParticleSystemQuad::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad"); //quad command diff --git a/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index 4566f06e1d..6bd6d4e04f 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/CCParticleSystemQuad.h @@ -96,7 +96,7 @@ public: * @js NA * @lua NA */ - virtual void updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) override; + virtual void updateQuadWithParticle(tParticle* particle, const Vec2& newPosition) override; /** * @js NA * @lua NA @@ -106,7 +106,7 @@ public: * @js NA * @lua NA */ - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; /** * @js NA diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index f4fc73987f..d3249380fb 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -79,11 +79,11 @@ bool ProgressTimer::initWithSprite(Sprite* sp) _vertexData = nullptr; _vertexDataCount = 0; - setAnchorPoint(Vector2(0.5f,0.5f)); + setAnchorPoint(Vec2(0.5f,0.5f)); _type = Type::RADIAL; _reverseDirection = false; - setMidpoint(Vector2(0.5f, 0.5f)); - setBarChangeRate(Vector2(1,1)); + setMidpoint(Vec2(0.5f, 0.5f)); + setBarChangeRate(Vec2(1,1)); setSprite(sp); // shader state @@ -156,15 +156,15 @@ void ProgressTimer::setReverseProgress(bool reverse) /// // @returns the vertex position from the texture coordinate /// -Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha) +Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha) { Tex2F ret(0.0f, 0.0f); if (!_sprite) { return ret; } V3F_C4B_T2F_Quad quad = _sprite->getQuad(); - Vector2 min = Vector2(quad.bl.texCoords.u,quad.bl.texCoords.v); - Vector2 max = Vector2(quad.tr.texCoords.u,quad.tr.texCoords.v); + Vec2 min = Vec2(quad.bl.texCoords.u,quad.bl.texCoords.v); + Vec2 max = Vec2(quad.tr.texCoords.u,quad.tr.texCoords.v); // Fix bug #1303 so that progress timer handles sprite frame texture rotation if (_sprite->isTextureRectRotated()) { CC_SWAP(alpha.x, alpha.y, float); @@ -172,15 +172,15 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha) return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y); } -Vector2 ProgressTimer::vertexFromAlphaPoint(Vector2 alpha) +Vec2 ProgressTimer::vertexFromAlphaPoint(Vec2 alpha) { - Vector2 ret(0.0f, 0.0f); + Vec2 ret(0.0f, 0.0f); if (!_sprite) { return ret; } V3F_C4B_T2F_Quad quad = _sprite->getQuad(); - Vector2 min = Vector2(quad.bl.vertices.x,quad.bl.vertices.y); - Vector2 max = Vector2(quad.tr.vertices.x,quad.tr.vertices.y); + Vec2 min = Vec2(quad.bl.vertices.x,quad.bl.vertices.y); + Vec2 max = Vec2(quad.tr.vertices.x,quad.tr.vertices.y); ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x; ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y; return ret; @@ -217,12 +217,12 @@ void ProgressTimer::updateProgress(void) } } -void ProgressTimer::setAnchorPoint(const Vector2& anchorPoint) +void ProgressTimer::setAnchorPoint(const Vec2& anchorPoint) { Node::setAnchorPoint(anchorPoint); } -Vector2 ProgressTimer::getMidpoint() const +Vec2 ProgressTimer::getMidpoint() const { return _midpoint; } @@ -249,9 +249,9 @@ GLubyte ProgressTimer::getOpacity() const return _sprite->getOpacity(); } -void ProgressTimer::setMidpoint(const Vector2& midPoint) +void ProgressTimer::setMidpoint(const Vec2& midPoint) { - _midpoint = midPoint.getClampPoint(Vector2::ZERO, Vector2(1, 1)); + _midpoint = midPoint.getClampPoint(Vec2::ZERO, Vec2(1, 1)); } /// @@ -275,12 +275,12 @@ void ProgressTimer::updateRadial(void) // We find the vector to do a hit detection based on the percentage // We know the first vector is the one @ 12 o'clock (top,mid) so we rotate // from that by the progress angle around the _midpoint pivot - Vector2 topMid = Vector2(_midpoint.x, 1.f); - Vector2 percentagePt = topMid.rotateByAngle(_midpoint, angle); + Vec2 topMid = Vec2(_midpoint.x, 1.f); + Vec2 percentagePt = topMid.rotateByAngle(_midpoint, angle); int index = 0; - Vector2 hit = Vector2::ZERO; + Vec2 hit = Vec2::ZERO; if (alpha == 0.f) { // More efficient since we don't always need to check intersection @@ -302,8 +302,8 @@ void ProgressTimer::updateRadial(void) for (int i = 0; i <= kProgressTextureCoordsCount; ++i) { int pIndex = (i + (kProgressTextureCoordsCount - 1))%kProgressTextureCoordsCount; - Vector2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount); - Vector2 edgePtB = boundaryTexCoord(pIndex); + Vec2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount); + Vec2 edgePtB = boundaryTexCoord(pIndex); // Remember that the top edge is split in half for the 12 o'clock position // Let's deal with that here by finding the correct endpoints @@ -315,7 +315,7 @@ void ProgressTimer::updateRadial(void) // s and t are returned by ccpLineIntersect float s = 0, t = 0; - if(Vector2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t)) + if(Vec2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t)) { // Since our hit test is on rays we have to deal with the top edge @@ -374,7 +374,7 @@ void ProgressTimer::updateRadial(void) _vertexData[1].vertices = vertexFromAlphaPoint(topMid); for(int i = 0; i < index; ++i){ - Vector2 alphaPoint = boundaryTexCoord(i); + Vec2 alphaPoint = boundaryTexCoord(i); _vertexData[i+2].texCoords = textureCoordFromAlphaPoint(alphaPoint); _vertexData[i+2].vertices = vertexFromAlphaPoint(alphaPoint); } @@ -401,9 +401,9 @@ void ProgressTimer::updateBar(void) return; } float alpha = _percentage / 100.0f; - Vector2 alphaOffset = Vector2(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f; - Vector2 min = _midpoint - alphaOffset; - Vector2 max = _midpoint + alphaOffset; + Vec2 alphaOffset = Vec2(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f; + Vec2 min = _midpoint - alphaOffset; + Vec2 max = _midpoint + alphaOffset; if (min.x < 0.f) { max.x += -min.x; @@ -433,74 +433,74 @@ void ProgressTimer::updateBar(void) CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); } // TOPLEFT - _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y)); - _vertexData[0].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y)); + _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,max.y)); + _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(min.x,max.y)); // BOTLEFT - _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y)); - _vertexData[1].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y)); + _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,min.y)); + _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(min.x,min.y)); // TOPRIGHT - _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y)); - _vertexData[2].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y)); + _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,max.y)); + _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(max.x,max.y)); // BOTRIGHT - _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y)); - _vertexData[3].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y)); + _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,min.y)); + _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(max.x,min.y)); } else { if(!_vertexData) { _vertexDataCount = 8; _vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F)); CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); // TOPLEFT 1 - _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(0,1)); - _vertexData[0].vertices = vertexFromAlphaPoint(Vector2(0,1)); + _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(0,1)); + _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(0,1)); // BOTLEFT 1 - _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(0,0)); - _vertexData[1].vertices = vertexFromAlphaPoint(Vector2(0,0)); + _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(0,0)); + _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(0,0)); // TOPRIGHT 2 - _vertexData[6].texCoords = textureCoordFromAlphaPoint(Vector2(1,1)); - _vertexData[6].vertices = vertexFromAlphaPoint(Vector2(1,1)); + _vertexData[6].texCoords = textureCoordFromAlphaPoint(Vec2(1,1)); + _vertexData[6].vertices = vertexFromAlphaPoint(Vec2(1,1)); // BOTRIGHT 2 - _vertexData[7].texCoords = textureCoordFromAlphaPoint(Vector2(1,0)); - _vertexData[7].vertices = vertexFromAlphaPoint(Vector2(1,0)); + _vertexData[7].texCoords = textureCoordFromAlphaPoint(Vec2(1,0)); + _vertexData[7].vertices = vertexFromAlphaPoint(Vec2(1,0)); } // TOPRIGHT 1 - _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y)); - _vertexData[2].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y)); + _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,max.y)); + _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(min.x,max.y)); // BOTRIGHT 1 - _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y)); - _vertexData[3].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y)); + _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,min.y)); + _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(min.x,min.y)); // TOPLEFT 2 - _vertexData[4].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y)); - _vertexData[4].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y)); + _vertexData[4].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,max.y)); + _vertexData[4].vertices = vertexFromAlphaPoint(Vec2(max.x,max.y)); // BOTLEFT 2 - _vertexData[5].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y)); - _vertexData[5].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y)); + _vertexData[5].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,min.y)); + _vertexData[5].vertices = vertexFromAlphaPoint(Vec2(max.x,min.y)); } updateColor(); } -Vector2 ProgressTimer::boundaryTexCoord(char index) +Vec2 ProgressTimer::boundaryTexCoord(char index) { if (index < kProgressTextureCoordsCount) { if (_reverseDirection) { - return Vector2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1); + return Vec2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1); } else { - return Vector2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1); + return Vec2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1); } } - return Vector2::ZERO; + return Vec2::ZERO; } -void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated) +void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated) { getGLProgram()->use(); @@ -518,7 +518,7 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated) int offset = 0; glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); - offset += sizeof(Vector2); + offset += sizeof(Vec2); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); offset += sizeof(Color4B); @@ -551,7 +551,7 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated) } } -void ProgressTimer::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if( ! _vertexData || ! _sprite) return; diff --git a/cocos/2d/CCProgressTimer.h b/cocos/2d/CCProgressTimer.h index 2cf8695305..84a4da05b3 100644 --- a/cocos/2d/CCProgressTimer.h +++ b/cocos/2d/CCProgressTimer.h @@ -91,28 +91,28 @@ public: * If you're using radials type then the midpoint changes the center point * If you're using bar type the the midpoint changes the bar growth * it expands from the center but clamps to the sprites edge so: - * you want a left to right then set the midpoint all the way to Vector2(0,y) - * you want a right to left then set the midpoint all the way to Vector2(1,y) - * you want a bottom to top then set the midpoint all the way to Vector2(x,0) - * you want a top to bottom then set the midpoint all the way to Vector2(x,1) + * you want a left to right then set the midpoint all the way to Vec2(0,y) + * you want a right to left then set the midpoint all the way to Vec2(1,y) + * you want a bottom to top then set the midpoint all the way to Vec2(x,0) + * you want a top to bottom then set the midpoint all the way to Vec2(x,1) */ - void setMidpoint(const Vector2& point); + void setMidpoint(const Vec2& point); /** Returns the Midpoint */ - Vector2 getMidpoint() const; + Vec2 getMidpoint() const; /** * This allows the bar type to move the component at a specific rate * Set the component to 0 to make sure it stays at 100%. * For example you want a left to right bar but not have the height stay 100% - * Set the rate to be Vector2(0,1); and set the midpoint to = Vector2(0,.5f); + * Set the rate to be Vec2(0,1); and set the midpoint to = Vec2(0,.5f); */ - inline void setBarChangeRate(const Vector2& barChangeRate ) { _barChangeRate = barChangeRate; } + inline void setBarChangeRate(const Vec2& barChangeRate ) { _barChangeRate = barChangeRate; } /** Returns the BarChangeRate */ - inline Vector2 getBarChangeRate() const { return _barChangeRate; } + inline Vec2 getBarChangeRate() const { return _barChangeRate; } // Overrides - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; - virtual void setAnchorPoint(const Vector2& anchorPoint) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void setAnchorPoint(const Vec2& anchorPoint) override; virtual void setColor(const Color3B &color) override; virtual const Color3B& getColor() const override; virtual void setOpacity(GLubyte opacity) override; @@ -133,19 +133,19 @@ CC_CONSTRUCTOR_ACCESS: bool initWithSprite(Sprite* sp); protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); - Tex2F textureCoordFromAlphaPoint(Vector2 alpha); - Vector2 vertexFromAlphaPoint(Vector2 alpha); + Tex2F textureCoordFromAlphaPoint(Vec2 alpha); + Vec2 vertexFromAlphaPoint(Vec2 alpha); void updateProgress(void); void updateBar(void); void updateRadial(void); virtual void updateColor(void) override; - Vector2 boundaryTexCoord(char index); + Vec2 boundaryTexCoord(char index); Type _type; - Vector2 _midpoint; - Vector2 _barChangeRate; + Vec2 _midpoint; + Vec2 _barChangeRate; float _percentage; Sprite *_sprite; int _vertexDataCount; diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 52addc63a4..436e07daa8 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -306,7 +306,7 @@ void RenderTexture::setKeepMatrix(bool keepMatrix) _keepMatrix = keepMatrix; } -void RenderTexture::setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport) +void RenderTexture::setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport) { _rtTextureRect.origin.x = rtBegin.x; _rtTextureRect.origin.y = rtBegin.y; @@ -383,7 +383,7 @@ void RenderTexture::clearStencil(int stencilValue) glClearStencil(stencilClearValue); } -void RenderTexture::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // override visit. // Don't call visit on its children @@ -401,7 +401,7 @@ void RenderTexture::visit(Renderer *renderer, const Matrix &parentTransform, boo CCASSERT(nullptr != director, "Director is null when seting matrix stack"); // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); @@ -535,7 +535,7 @@ void RenderTexture::onBegin() director->setProjection(director->getProjection()); #if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - Matrix modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + Mat4 modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); modifiedProjection = CCEGLView::sharedOpenGLView()->getReverseOrientationMatrix() * modifiedProjection; director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION,modifiedProjection); #endif @@ -547,8 +547,8 @@ void RenderTexture::onBegin() float widthRatio = size.width / texSize.width; float heightRatio = size.height / texSize.height; - Matrix orthoMatrix; - Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); + Mat4 orthoMatrix; + Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); } @@ -654,7 +654,7 @@ void RenderTexture::onClearDepth() glClearDepth(depthClearValue); } -void RenderTexture::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if (_autoDraw) { @@ -703,8 +703,8 @@ void RenderTexture::begin() float widthRatio = size.width / texSize.width; float heightRatio = size.height / texSize.height; - Matrix orthoMatrix; - Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); + Mat4 orthoMatrix; + Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); } diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index 0cbf0da984..d3f7ece158 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -153,8 +153,8 @@ public: }; // Overrides - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; //flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix void setKeepMatrix(bool keepMatrix); @@ -163,7 +163,7 @@ public: //fullRect: the total size of screen //fullViewport: the total viewportSize */ - void setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport); + void setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport); public: // XXX should be procted. @@ -224,8 +224,8 @@ protected: void onSaveToFile(const std::string& fileName); - Matrix _oldTransMatrix, _oldProjMatrix; - Matrix _transformMatrix, _projectionMatrix; + Mat4 _oldTransMatrix, _oldProjMatrix; + Mat4 _transformMatrix, _projectionMatrix; private: CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture); diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 55fb9bfc82..e4e4c58a4c 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -41,7 +41,7 @@ Scene::Scene() #endif { _ignoreAnchorPointForPosition = true; - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); } Scene::~Scene() diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 4059c1f87a..a5c2049310 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -234,10 +234,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) _flippedX = _flippedY = false; // default transform anchor: center - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); // zwoptex default values - _offsetPosition = Vector2::ZERO; + _offsetPosition = Vec2::ZERO; // clean the Quad memset(&_quad, 0, sizeof(_quad)); @@ -367,7 +367,7 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme setVertexRect(rect); setTextureCoords(rect); - Vector2 relativeOffset = _unflippedOffsetPositionFromCenter; + Vec2 relativeOffset = _unflippedOffsetPositionFromCenter; // issue #732 if (_flippedX) @@ -399,10 +399,10 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme float y2 = y1 + _rect.size.height; // Don't update Z. - _quad.bl.vertices = Vector3(x1, y1, 0); - _quad.br.vertices = Vector3(x2, y1, 0); - _quad.tl.vertices = Vector3(x1, y2, 0); - _quad.tr.vertices = Vector3(x2, y2, 0); + _quad.bl.vertices = Vec3(x1, y1, 0); + _quad.br.vertices = Vec3(x2, y1, 0); + _quad.tl.vertices = Vec3(x1, y2, 0); + _quad.tr.vertices = Vec3(x2, y2, 0); } } @@ -505,7 +505,7 @@ void Sprite::updateTransform(void) // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !_visible || ( _parent && _parent != _batchNode && static_cast(_parent)->_shouldBeHidden) ) { - _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vector3(0,0,0); + _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0,0,0); _shouldBeHidden = true; } else @@ -519,8 +519,8 @@ void Sprite::updateTransform(void) else { CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); - Matrix nodeToParent = getNodeToParentTransform(); - Matrix parentTransform = static_cast(_parent)->_transformToBatch; + Mat4 nodeToParent = getNodeToParentTransform(); + Mat4 parentTransform = static_cast(_parent)->_transformToBatch; _transformToBatch = parentTransform * nodeToParent; } @@ -554,10 +554,10 @@ void Sprite::updateTransform(void) float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; - _quad.bl.vertices = Vector3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ ); - _quad.br.vertices = Vector3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ ); - _quad.tl.vertices = Vector3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ ); - _quad.tr.vertices = Vector3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ ); + _quad.bl.vertices = Vec3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ ); + _quad.br.vertices = Vec3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ ); + _quad.tl.vertices = Vec3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ ); + _quad.tr.vertices = Vec3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS @@ -583,7 +583,7 @@ void Sprite::updateTransform(void) // draw -void Sprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Sprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { // Don't do calculate the culling if the transform was not updated _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; @@ -604,15 +604,15 @@ void Sprite::drawDebugData() { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix oldModelView; + Mat4 oldModelView; oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); // draw bounding box - Vector2 vertices[4] = { - Vector2( _quad.bl.vertices.x, _quad.bl.vertices.y ), - Vector2( _quad.br.vertices.x, _quad.br.vertices.y ), - Vector2( _quad.tr.vertices.x, _quad.tr.vertices.y ), - Vector2( _quad.tl.vertices.x, _quad.tl.vertices.y ), + Vec2 vertices[4] = { + Vec2( _quad.bl.vertices.x, _quad.bl.vertices.y ), + Vec2( _quad.br.vertices.x, _quad.br.vertices.y ), + Vec2( _quad.tr.vertices.x, _quad.tr.vertices.y ), + Vec2( _quad.tl.vertices.x, _quad.tl.vertices.y ), }; DrawPrimitives::drawPoly(vertices, 4, true); @@ -742,7 +742,7 @@ void Sprite::setDirtyRecursively(bool bValue) } \ } -void Sprite::setPosition(const Vector2& pos) +void Sprite::setPosition(const Vec2& pos) { Node::setPosition(pos); SET_DIRTY_RECURSIVELY(); @@ -815,7 +815,7 @@ void Sprite::setPositionZ(float fVertexZ) SET_DIRTY_RECURSIVELY(); } -void Sprite::setAnchorPoint(const Vector2& anchor) +void Sprite::setAnchorPoint(const Vec2& anchor) { Node::setAnchorPoint(anchor); SET_DIRTY_RECURSIVELY(); @@ -996,15 +996,15 @@ void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode) float y1 = _offsetPosition.y; float x2 = x1 + _rect.size.width; float y2 = y1 + _rect.size.height; - _quad.bl.vertices = Vector3( x1, y1, 0 ); - _quad.br.vertices = Vector3( x2, y1, 0 ); - _quad.tl.vertices = Vector3( x1, y2, 0 ); - _quad.tr.vertices = Vector3( x2, y2, 0 ); + _quad.bl.vertices = Vec3( x1, y1, 0 ); + _quad.br.vertices = Vec3( x2, y1, 0 ); + _quad.tl.vertices = Vec3( x1, y2, 0 ); + _quad.tr.vertices = Vec3( x2, y2, 0 ); } else { // using batch - _transformToBatch = Matrix::IDENTITY; + _transformToBatch = Mat4::IDENTITY; setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref } } diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 7f401ec5b8..38d826fdb6 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -317,7 +317,7 @@ public: /** * Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex. */ - inline const Vector2& getOffsetPosition(void) const { return _offsetPosition; } + inline const Vec2& getOffsetPosition(void) const { return _offsetPosition; } /** @@ -402,7 +402,7 @@ public: * @js NA * @lua NA */ - virtual void setPosition(const Vector2& pos) override; + virtual void setPosition(const Vec2& pos) override; virtual void setPosition(float x, float y) override; virtual void setRotation(float rotation) override; virtual void setRotationSkewX(float rotationX) override; @@ -417,10 +417,10 @@ public: virtual void sortAllChildren() override; virtual void setScale(float scale) override; virtual void setPositionZ(float positionZ) override; - virtual void setAnchorPoint(const Vector2& anchor) override; + virtual void setAnchorPoint(const Vec2& anchor) override; virtual void ignoreAnchorPointForPosition(bool value) override; virtual void setVisible(bool bVisible) override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual void setOpacityModifyRGB(bool modify) override; virtual bool isOpacityModifyRGB(void) const override; /// @} @@ -535,7 +535,7 @@ protected: bool _dirty; /// Whether the sprite needs to be updated bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible - Matrix _transformToBatch; + Mat4 _transformToBatch; // // Data used when the sprite is self-rendered @@ -556,8 +556,8 @@ protected: bool _rectRotated; /// Whether the texture is rotated // Offset Position (used by Zwoptex) - Vector2 _offsetPosition; - Vector2 _unflippedOffsetPositionFromCenter; + Vec2 _offsetPosition; + Vec2 _unflippedOffsetPositionFromCenter; // vertex coords, texture coords and color info V3F_C4B_T2F_Quad _quad; diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index b2bfaa4bfb..4c44ae543e 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -132,7 +132,7 @@ SpriteBatchNode::~SpriteBatchNode() // override visit // don't call visit on it's children -void SpriteBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); @@ -156,7 +156,7 @@ void SpriteBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, b _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -356,7 +356,7 @@ void SpriteBatchNode::reorderBatch(bool reorder) _reorderChildDirty=reorder; } -void SpriteBatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { // Optimization: Fast Dispatch if( _textureAtlas->getTotalQuads() == 0 ) diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 0f3be91dd8..6f59a65ba1 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -134,7 +134,7 @@ public: */ virtual const BlendFunc& getBlendFunc() const override; - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; @@ -143,7 +143,7 @@ public: virtual void removeChild(Node *child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void sortAllChildren() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string getDescription() const override; /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. diff --git a/cocos/2d/CCSpriteFrame.cpp b/cocos/2d/CCSpriteFrame.cpp index 7301b4af59..86f46dc809 100644 --- a/cocos/2d/CCSpriteFrame.cpp +++ b/cocos/2d/CCSpriteFrame.cpp @@ -50,7 +50,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect return spriteFrame; } -SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) +SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize) { SpriteFrame *spriteFrame = new SpriteFrame(); spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize); @@ -59,7 +59,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect return spriteFrame; } -SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) +SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize) { SpriteFrame *spriteFrame = new SpriteFrame(); spriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize); @@ -71,16 +71,16 @@ SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect) { Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect); - return initWithTexture(texture, rectInPixels, false, Vector2::ZERO, rectInPixels.size); + return initWithTexture(texture, rectInPixels, false, Vec2::ZERO, rectInPixels.size); } bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect) { Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect ); - return initWithTextureFilename(filename, rectInPixels, false, Vector2::ZERO, rectInPixels.size); + return initWithTextureFilename(filename, rectInPixels, false, Vec2::ZERO, rectInPixels.size); } -bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) +bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize) { _texture = texture; @@ -100,7 +100,7 @@ bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rot return true; } -bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) +bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize) { _texture = nullptr; _textureFilename = filename; @@ -143,23 +143,23 @@ void SpriteFrame::setRectInPixels(const Rect& rectInPixels) _rect = CC_RECT_PIXELS_TO_POINTS(rectInPixels); } -const Vector2& SpriteFrame::getOffset() const +const Vec2& SpriteFrame::getOffset() const { return _offset; } -void SpriteFrame::setOffset(const Vector2& offsets) +void SpriteFrame::setOffset(const Vec2& offsets) { _offset = offsets; _offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset ); } -const Vector2& SpriteFrame::getOffsetInPixels() const +const Vec2& SpriteFrame::getOffsetInPixels() const { return _offsetInPixels; } -void SpriteFrame::setOffsetInPixels(const Vector2& offsetInPixels) +void SpriteFrame::setOffsetInPixels(const Vec2& offsetInPixels) { _offsetInPixels = offsetInPixels; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); diff --git a/cocos/2d/CCSpriteFrame.h b/cocos/2d/CCSpriteFrame.h index ae64fad5b7..bea7424ba3 100644 --- a/cocos/2d/CCSpriteFrame.h +++ b/cocos/2d/CCSpriteFrame.h @@ -64,7 +64,7 @@ public: /** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. */ - static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); + static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); /** Create a SpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. @@ -74,7 +74,7 @@ public: /** Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */ - static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); + static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); /** * @js NA * @lua NA @@ -94,14 +94,14 @@ public: /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */ - bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); + bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. @since v1.1 */ - bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); + bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); // attributes @@ -117,9 +117,9 @@ public: void setRect(const Rect& rect); /** get offset of the frame */ - const Vector2& getOffsetInPixels(void) const; + const Vec2& getOffsetInPixels(void) const; /** set offset of the frame */ - void setOffsetInPixels(const Vector2& offsetInPixels); + void setOffsetInPixels(const Vec2& offsetInPixels); /** get original size of the trimmed image */ inline const Size& getOriginalSizeInPixels(void) const { return _originalSizeInPixels; } @@ -136,19 +136,19 @@ public: /** set texture of the frame, the texture is retained */ void setTexture(Texture2D* pobTexture); - const Vector2& getOffset(void) const; - void setOffset(const Vector2& offsets); + const Vec2& getOffset(void) const; + void setOffset(const Vec2& offsets); // Overrides virtual SpriteFrame *clone() const override; protected: - Vector2 _offset; + Vec2 _offset; Size _originalSize; Rect _rectInPixels; bool _rotated; Rect _rect; - Vector2 _offsetInPixels; + Vec2 _offsetInPixels; Size _originalSizeInPixels; Texture2D *_texture; std::string _textureFilename; diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index eeb87fdd32..4f9cedfa9e 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -132,7 +132,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu spriteFrame->initWithTexture(texture, Rect(x, y, w, h), false, - Vector2(ox, oy), + Vec2(ox, oy), Size((float)ow, (float)oh) ); } @@ -147,7 +147,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu rotated = frameDict["rotated"].asBool(); } - Vector2 offset = PointFromString(frameDict["offset"].asString()); + Vec2 offset = PointFromString(frameDict["offset"].asString()); Size sourceSize = SizeFromString(frameDict["sourceSize"].asString()); // create frame @@ -163,7 +163,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu { // get values Size spriteSize = SizeFromString(frameDict["spriteSize"].asString()); - Vector2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString()); + Vec2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString()); Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString()); Rect textureRect = RectFromString(frameDict["textureRect"].asString()); bool textureRotated = frameDict["textureRotated"].asBool(); diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index d88dcd4c0e..8a61292f57 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -83,7 +83,7 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la _layerOrientation = mapInfo->getOrientation(); // offset (after layer orientation is set); - Vector2 offset = this->calculateLayerOffset(layerInfo->_offset); + Vec2 offset = this->calculateLayerOffset(layerInfo->_offset); this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset)); _atlasIndexArray = ccCArrayNew(totalNumberOfTiles); @@ -176,7 +176,7 @@ void TMXLayer::setupTiles() // XXX: gid == 0 --> empty tile if (gid != 0) { - this->appendTileForGID(gid, Vector2(x, y)); + this->appendTileForGID(gid, Vec2(x, y)); } } } @@ -223,25 +223,25 @@ void TMXLayer::parseInternalProperties() } } -void TMXLayer::setupTileSprite(Sprite* sprite, Vector2 pos, int gid) +void TMXLayer::setupTileSprite(Sprite* sprite, Vec2 pos, int gid) { sprite->setPosition(getPositionAt(pos)); sprite->setPositionZ((float)getVertexZForPos(pos)); - sprite->setAnchorPoint(Vector2::ZERO); + sprite->setAnchorPoint(Vec2::ZERO); sprite->setOpacity(_opacity); //issue 1264, flip can be undone as well sprite->setFlippedX(false); sprite->setFlippedY(false); sprite->setRotation(0.0f); - sprite->setAnchorPoint(Vector2(0,0)); + sprite->setAnchorPoint(Vec2(0,0)); // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. if (gid & kTMXTileDiagonalFlag) { // put the anchor in the middle for ease of rotation. - sprite->setAnchorPoint(Vector2(0.5f,0.5f)); - sprite->setPosition(Vector2(getPositionAt(pos).x + sprite->getContentSize().height/2, + sprite->setAnchorPoint(Vec2(0.5f,0.5f)); + sprite->setPosition(Vec2(getPositionAt(pos).x + sprite->getContentSize().height/2, getPositionAt(pos).y + sprite->getContentSize().width/2 ) ); int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag ); @@ -305,7 +305,7 @@ Sprite* TMXLayer::reusedTileWithRect(Rect rect) } // TMXLayer - obtaining tiles/gids -Sprite * TMXLayer::getTileAt(const Vector2& pos) +Sprite * TMXLayer::getTileAt(const Vec2& pos) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); @@ -329,7 +329,7 @@ Sprite * TMXLayer::getTileAt(const Vector2& pos) tile->setBatchNode(this); tile->setPosition(getPositionAt(pos)); tile->setPositionZ((float)getVertexZForPos(pos)); - tile->setAnchorPoint(Vector2::ZERO); + tile->setAnchorPoint(Vec2::ZERO); tile->setOpacity(_opacity); ssize_t indexForZ = atlasIndexForExistantZ(z); @@ -340,7 +340,7 @@ Sprite * TMXLayer::getTileAt(const Vector2& pos) return tile; } -uint32_t TMXLayer::getTileGIDAt(const Vector2& pos, TMXTileFlags* flags/* = nullptr*/) +uint32_t TMXLayer::getTileGIDAt(const Vec2& pos, TMXTileFlags* flags/* = nullptr*/) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); @@ -359,7 +359,7 @@ uint32_t TMXLayer::getTileGIDAt(const Vector2& pos, TMXTileFlags* flags/* = null } // TMXLayer - adding helper methods -Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos) +Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vec2& pos) { if (gid != 0 && (static_cast((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0) { @@ -399,7 +399,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos) return nullptr; } -Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& pos) +Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vec2& pos) { Rect rect = _tileSet->getRectForGID(gid); rect = Rect(rect.origin.x / _contentScaleFactor, rect.origin.y / _contentScaleFactor, rect.size.width/ _contentScaleFactor, rect.size.height/ _contentScaleFactor); @@ -421,7 +421,7 @@ Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& pos) // used only when parsing the map. useless after the map was parsed // since lot's of assumptions are no longer true -Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vector2& pos) +Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vec2& pos) { if (gid != 0 && (static_cast((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0) { @@ -485,12 +485,12 @@ ssize_t TMXLayer::atlasIndexForNewZ(int z) } // TMXLayer - adding / remove tiles -void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos) +void TMXLayer::setTileGID(uint32_t gid, const Vec2& pos) { setTileGID(gid, pos, (TMXTileFlags)0); } -void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos, TMXTileFlags flags) +void TMXLayer::setTileGID(uint32_t gid, const Vec2& pos, TMXTileFlags flags) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); @@ -564,7 +564,7 @@ void TMXLayer::removeChild(Node* node, bool cleanup) SpriteBatchNode::removeChild(sprite, cleanup); } -void TMXLayer::removeTileAt(const Vector2& pos) +void TMXLayer::removeTileAt(const Vec2& pos) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); @@ -606,28 +606,28 @@ void TMXLayer::removeTileAt(const Vector2& pos) } //CCTMXLayer - obtaining positions, offset -Vector2 TMXLayer::calculateLayerOffset(const Vector2& pos) +Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos) { - Vector2 ret = Vector2::ZERO; + Vec2 ret = Vec2::ZERO; switch (_layerOrientation) { case TMXOrientationOrtho: - ret = Vector2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); + ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); break; case TMXOrientationIso: - ret = Vector2((_mapTileSize.width /2) * (pos.x - pos.y), + ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y), (_mapTileSize.height /2 ) * (-pos.x - pos.y)); break; case TMXOrientationHex: - CCASSERT(pos.equals(Vector2::ZERO), "offset for hexagonal map not implemented yet"); + CCASSERT(pos.equals(Vec2::ZERO), "offset for hexagonal map not implemented yet"); break; } return ret; } -Vector2 TMXLayer::getPositionAt(const Vector2& pos) +Vec2 TMXLayer::getPositionAt(const Vec2& pos) { - Vector2 ret = Vector2::ZERO; + Vec2 ret = Vec2::ZERO; switch (_layerOrientation) { case TMXOrientationOrtho: @@ -644,19 +644,19 @@ Vector2 TMXLayer::getPositionAt(const Vector2& pos) return ret; } -Vector2 TMXLayer::getPositionForOrthoAt(const Vector2& pos) +Vec2 TMXLayer::getPositionForOrthoAt(const Vec2& pos) { - return Vector2(pos.x * _mapTileSize.width, + return Vec2(pos.x * _mapTileSize.width, (_layerSize.height - pos.y - 1) * _mapTileSize.height); } -Vector2 TMXLayer::getPositionForIsoAt(const Vector2& pos) +Vec2 TMXLayer::getPositionForIsoAt(const Vec2& pos) { - return Vector2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1), + return Vec2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1), _mapTileSize.height /2 * ((_layerSize.height * 2 - pos.x - pos.y) - 2)); } -Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos) +Vec2 TMXLayer::getPositionForHexAt(const Vec2& pos) { float diffY = 0; if ((int)pos.x % 2 == 1) @@ -664,12 +664,12 @@ Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos) diffY = -_mapTileSize.height/2 ; } - Vector2 xy = Vector2(pos.x * _mapTileSize.width*3/4, + Vec2 xy = Vec2(pos.x * _mapTileSize.width*3/4, (_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY); return xy; } -int TMXLayer::getVertexZForPos(const Vector2& pos) +int TMXLayer::getVertexZForPos(const Vec2& pos) { int ret = 0; int maxVal = 0; diff --git a/cocos/2d/CCTMXLayer.h b/cocos/2d/CCTMXLayer.h index a59e228d03..58ffa34db4 100644 --- a/cocos/2d/CCTMXLayer.h +++ b/cocos/2d/CCTMXLayer.h @@ -102,16 +102,16 @@ public: The Sprite can be treated like any other Sprite: rotated, scaled, translated, opacity, color, etc. You can remove either by calling: - layer->removeChild(sprite, cleanup); - - or layer->removeTileAt(Vector2(x,y)); + - or layer->removeTileAt(Vec2(x,y)); */ - Sprite* getTileAt(const Vector2& tileCoordinate); - CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Vector2& tileCoordinate) { return getTileAt(tileCoordinate); }; + Sprite* getTileAt(const Vec2& tileCoordinate); + CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Vec2& tileCoordinate) { return getTileAt(tileCoordinate); }; /** returns the tile gid at a given tile coordinate. It also returns the tile flags. This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap]) */ - uint32_t getTileGIDAt(const Vector2& tileCoordinate, TMXTileFlags* flags = nullptr); - CC_DEPRECATED_ATTRIBUTE uint32_t tileGIDAt(const Vector2& tileCoordinate, TMXTileFlags* flags = nullptr){ + uint32_t getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr); + CC_DEPRECATED_ATTRIBUTE uint32_t tileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr){ return getTileGIDAt(tileCoordinate, flags); }; @@ -119,7 +119,7 @@ public: The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. If a tile is already placed at that position, then it will be removed. */ - void setTileGID(uint32_t gid, const Vector2& tileCoordinate); + void setTileGID(uint32_t gid, const Vec2& tileCoordinate); /** sets the tile gid (gid = tile global id) at a given tile coordinate. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. @@ -128,14 +128,14 @@ public: Use withFlags if the tile flags need to be changed as well */ - void setTileGID(uint32_t gid, const Vector2& tileCoordinate, TMXTileFlags flags); + void setTileGID(uint32_t gid, const Vec2& tileCoordinate, TMXTileFlags flags); /** removes a tile at given tile coordinate */ - void removeTileAt(const Vector2& tileCoordinate); + void removeTileAt(const Vec2& tileCoordinate); /** returns the position in points of a given tile coordinate */ - Vector2 getPositionAt(const Vector2& tileCoordinate); - CC_DEPRECATED_ATTRIBUTE Vector2 positionAt(const Vector2& tileCoordinate) { return getPositionAt(tileCoordinate); }; + Vec2 getPositionAt(const Vec2& tileCoordinate); + CC_DEPRECATED_ATTRIBUTE Vec2 positionAt(const Vec2& tileCoordinate) { return getPositionAt(tileCoordinate); }; /** return the value for the specific property name */ Value getProperty(const std::string& propertyName) const; @@ -193,22 +193,22 @@ public: virtual std::string getDescription() const override; private: - Vector2 getPositionForIsoAt(const Vector2& pos); - Vector2 getPositionForOrthoAt(const Vector2& pos); - Vector2 getPositionForHexAt(const Vector2& pos); + Vec2 getPositionForIsoAt(const Vec2& pos); + Vec2 getPositionForOrthoAt(const Vec2& pos); + Vec2 getPositionForHexAt(const Vec2& pos); - Vector2 calculateLayerOffset(const Vector2& offset); + Vec2 calculateLayerOffset(const Vec2& offset); /* optimization methods */ - Sprite* appendTileForGID(uint32_t gid, const Vector2& pos); - Sprite* insertTileForGID(uint32_t gid, const Vector2& pos); - Sprite* updateTileForGID(uint32_t gid, const Vector2& pos); + Sprite* appendTileForGID(uint32_t gid, const Vec2& pos); + Sprite* insertTileForGID(uint32_t gid, const Vec2& pos); + Sprite* updateTileForGID(uint32_t gid, const Vec2& pos); /* The layer recognizes some special properties, like cc_vertez */ void parseInternalProperties(); - void setupTileSprite(Sprite* sprite, Vector2 pos, int gid); + void setupTileSprite(Sprite* sprite, Vec2 pos, int gid); Sprite* reusedTileWithRect(Rect rect); - int getVertexZForPos(const Vector2& pos); + int getVertexZForPos(const Vec2& pos); // index ssize_t atlasIndexForExistantZ(int z); diff --git a/cocos/2d/CCTMXObjectGroup.cpp b/cocos/2d/CCTMXObjectGroup.cpp index 9d014fa459..6b2a55af32 100644 --- a/cocos/2d/CCTMXObjectGroup.cpp +++ b/cocos/2d/CCTMXObjectGroup.cpp @@ -34,7 +34,7 @@ NS_CC_BEGIN TMXObjectGroup::TMXObjectGroup() : _groupName("") - , _positionOffset(Vector2::ZERO) + , _positionOffset(Vec2::ZERO) { } diff --git a/cocos/2d/CCTMXObjectGroup.h b/cocos/2d/CCTMXObjectGroup.h index e31d39ded0..83d6945a59 100644 --- a/cocos/2d/CCTMXObjectGroup.h +++ b/cocos/2d/CCTMXObjectGroup.h @@ -71,10 +71,10 @@ public: CC_DEPRECATED_ATTRIBUTE ValueMap objectNamed(const std::string& objectName) const { return getObject(objectName); }; /** Gets the offset position of child objects */ - inline const Vector2& getPositionOffset() const { return _positionOffset; }; + inline const Vec2& getPositionOffset() const { return _positionOffset; }; /** Sets the offset position of child objects */ - inline void setPositionOffset(const Vector2& offset) { _positionOffset = offset; }; + inline void setPositionOffset(const Vec2& offset) { _positionOffset = offset; }; /** Gets the list of properties stored in a dictionary */ inline const ValueMap& getProperties() const { return _properties; }; @@ -98,7 +98,7 @@ protected: /** name of the group */ std::string _groupName; /** offset position of child objects */ - Vector2 _positionOffset; + Vec2 _positionOffset; /** list of properties stored in a dictionary */ ValueMap _properties; /** array of the objects */ diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index f07708117a..a2de4100a6 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -45,7 +45,7 @@ TMXLayerInfo::TMXLayerInfo() : _name("") , _tiles(nullptr) , _ownTiles(true) -, _offset(Vector2::ZERO) +, _offset(Vec2::ZERO) { } @@ -348,7 +348,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) float x = attributeDict["x"].asFloat(); float y = attributeDict["y"].asFloat(); - layer->_offset = Vector2(x,y); + layer->_offset = Vec2(x,y); tmxMapInfo->getLayers().pushBack(layer); layer->release(); @@ -361,7 +361,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { TMXObjectGroup *objectGroup = new TMXObjectGroup(); objectGroup->setGroupName(attributeDict["name"].asString()); - Vector2 positionOffset; + Vec2 positionOffset; positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width; positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height; objectGroup->setPositionOffset(positionOffset); @@ -452,7 +452,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) // Y int y = attributeDict["y"].asInt(); - Vector2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt()); + Vec2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt()); p = CC_POINT_PIXELS_TO_POINTS(p); dict["x"] = Value(p.x); dict["y"] = Value(p.y); diff --git a/cocos/2d/CCTMXXMLParser.h b/cocos/2d/CCTMXXMLParser.h index f84f7d8ba8..94621db3b0 100644 --- a/cocos/2d/CCTMXXMLParser.h +++ b/cocos/2d/CCTMXXMLParser.h @@ -112,7 +112,7 @@ public: bool _visible; unsigned char _opacity; bool _ownTiles; - Vector2 _offset; + Vec2 _offset; }; /** @brief TMXTilesetInfo contains the information about the tilesets like: diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 44666aab61..9a49232431 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -263,7 +263,7 @@ void TextFieldTTF::setTextColor(const Color4B &color) Label::setTextColor(_colorText); } -void TextFieldTTF::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated)) { diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index 722e3143cb..98b3283492 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -86,7 +86,7 @@ public: /** @brief If the sender doesn't want to draw, return true. */ - virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Matrix &transform, bool transformUpdated) + virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, bool transformUpdated) { CC_UNUSED_PARAM(sender); return false; @@ -165,7 +165,7 @@ public: virtual void setSecureTextEntry(bool value); virtual bool isSecureTextEntry(); - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; protected: ////////////////////////////////////////////////////////////////////////// diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index cd7075b4cd..f6a6df9033 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -1142,7 +1142,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin // implementation Texture2D (Drawing) -void Texture2D::drawAtPoint(const Vector2& point) +void Texture2D::drawAtPoint(const Vec2& point) { GLfloat coordinates[] = { 0.0f, _maxT, diff --git a/cocos/2d/CCTexture2D.h b/cocos/2d/CCTexture2D.h index a2892c99bf..744ae29786 100644 --- a/cocos/2d/CCTexture2D.h +++ b/cocos/2d/CCTexture2D.h @@ -219,7 +219,7 @@ public: These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled. */ /** draws a texture at a given point */ - void drawAtPoint(const Vector2& point); + void drawAtPoint(const Vec2& point); /** draws a texture inside a rect */ void drawInRect(const Rect& rect); diff --git a/cocos/2d/CCTileMapAtlas.cpp b/cocos/2d/CCTileMapAtlas.cpp index 14e93b6ace..77f4e7d43f 100644 --- a/cocos/2d/CCTileMapAtlas.cpp +++ b/cocos/2d/CCTileMapAtlas.cpp @@ -125,7 +125,7 @@ void TileMapAtlas::loadTGAfile(const std::string& file) } // TileMapAtlas - Atlas generation / updates -void TileMapAtlas::setTile(const Color3B& tile, const Vector2& position) +void TileMapAtlas::setTile(const Color3B& tile, const Vec2& position) { CCASSERT(_TGAInfo != nullptr, "tgaInfo must not be nil"); CCASSERT(position.x < _TGAInfo->width, "Invalid position.x"); @@ -151,7 +151,7 @@ void TileMapAtlas::setTile(const Color3B& tile, const Vector2& position) } } -Color3B TileMapAtlas::getTileAt(const Vector2& position) const +Color3B TileMapAtlas::getTileAt(const Vec2& position) const { CCASSERT( _TGAInfo != nullptr, "tgaInfo must not be nil"); CCASSERT( position.x < _TGAInfo->width, "Invalid position.x"); @@ -163,7 +163,7 @@ Color3B TileMapAtlas::getTileAt(const Vector2& position) const return value; } -void TileMapAtlas::updateAtlasValueAt(const Vector2& pos, const Color3B& value, int index) +void TileMapAtlas::updateAtlasValueAt(const Vec2& pos, const Color3B& value, int index) { CCASSERT( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index"); @@ -244,7 +244,7 @@ void TileMapAtlas::updateAtlasValues() if( value.r != 0 ) { - this->updateAtlasValueAt(Vector2(x,y), value, total); + this->updateAtlasValueAt(Vec2(x,y), value, total); std::string key = StringUtils::toString(x) + "," + StringUtils::toString(y); _posToAtlasIndex[key] = total; diff --git a/cocos/2d/CCTileMapAtlas.h b/cocos/2d/CCTileMapAtlas.h index f38b71239d..7ac9382f3c 100644 --- a/cocos/2d/CCTileMapAtlas.h +++ b/cocos/2d/CCTileMapAtlas.h @@ -78,12 +78,12 @@ public: /** returns a tile from position x,y. For the moment only channel R is used */ - Color3B getTileAt(const Vector2& position) const; - CC_DEPRECATED_ATTRIBUTE Color3B tileAt(const Vector2& position) const { return getTileAt(position); }; + Color3B getTileAt(const Vec2& position) const; + CC_DEPRECATED_ATTRIBUTE Color3B tileAt(const Vec2& position) const { return getTileAt(position); }; /** sets a tile at position x,y. For the moment only channel R is used */ - void setTile(const Color3B& tile, const Vector2& position); + void setTile(const Color3B& tile, const Vec2& position); /** dealloc the map from memory */ void releaseMap(); @@ -93,7 +93,7 @@ public: protected: void loadTGAfile(const std::string& file); void calculateItemsToRender(); - void updateAtlasValueAt(const Vector2& pos, const Color3B& value, int index); + void updateAtlasValueAt(const Vec2& pos, const Color3B& value, int index); void updateAtlasValues(); diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 1c0faf7e1a..492a820ca0 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -103,7 +103,7 @@ void TransitionScene::sceneOrder() _isInSceneOnTop = true; } -void TransitionScene::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Scene::draw(renderer, transform, transformUpdated); @@ -120,13 +120,13 @@ void TransitionScene::finish() { // clean up _inScene->setVisible(true); - _inScene->setPosition(Vector2(0,0)); + _inScene->setPosition(Vec2(0,0)); _inScene->setScale(1.0f); _inScene->setRotation(0.0f); _inScene->setAdditionalTransform(nullptr); _outScene->setVisible(false); - _outScene->setPosition(Vector2(0,0)); + _outScene->setPosition(Vec2(0,0)); _outScene->setScale(1.0f); _outScene->setRotation(0.0f); _outScene->setAdditionalTransform(nullptr); @@ -255,8 +255,8 @@ void TransitionRotoZoom:: onEnter() _inScene->setScale(0.001f); _outScene->setScale(1.0f); - _inScene->setAnchorPoint(Vector2(0.5f, 0.5f)); - _outScene->setAnchorPoint(Vector2(0.5f, 0.5f)); + _inScene->setAnchorPoint(Vec2(0.5f, 0.5f)); + _outScene->setAnchorPoint(Vec2(0.5f, 0.5f)); ActionInterval *rotozoom = (ActionInterval*)(Sequence::create ( @@ -310,11 +310,11 @@ void TransitionJumpZoom::onEnter() Size s = Director::getInstance()->getWinSize(); _inScene->setScale(0.5f); - _inScene->setPosition(Vector2(s.width, 0)); - _inScene->setAnchorPoint(Vector2(0.5f, 0.5f)); - _outScene->setAnchorPoint(Vector2(0.5f, 0.5f)); + _inScene->setPosition(Vec2(s.width, 0)); + _inScene->setAnchorPoint(Vec2(0.5f, 0.5f)); + _outScene->setAnchorPoint(Vec2(0.5f, 0.5f)); - ActionInterval *jump = JumpBy::create(_duration/4, Vector2(-s.width,0), s.width/4, 2); + ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0), s.width/4, 2); ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f); ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f); @@ -379,7 +379,7 @@ void TransitionMoveInL::onEnter() ActionInterval* TransitionMoveInL::action() { - return MoveTo::create(_duration, Vector2(0,0)); + return MoveTo::create(_duration, Vec2(0,0)); } ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action) @@ -391,7 +391,7 @@ ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action) void TransitionMoveInL::initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition(Vector2(-s.width,0)); + _inScene->setPosition(Vec2(-s.width,0)); } // @@ -419,7 +419,7 @@ TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene) void TransitionMoveInR::initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(s.width,0) ); + _inScene->setPosition( Vec2(s.width,0) ); } // @@ -447,7 +447,7 @@ TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene) void TransitionMoveInT::initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(0,s.height) ); + _inScene->setPosition( Vec2(0,s.height) ); } // @@ -475,7 +475,7 @@ TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene) void TransitionMoveInB::initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(0,-s.height) ); + _inScene->setPosition( Vec2(0,-s.height) ); } @@ -523,13 +523,13 @@ void TransitionSlideInL::sceneOrder() void TransitionSlideInL:: initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(-(s.width-ADJUST_FACTOR),0) ); + _inScene->setPosition( Vec2(-(s.width-ADJUST_FACTOR),0) ); } ActionInterval* TransitionSlideInL::action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vector2(s.width-ADJUST_FACTOR,0)); + return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0)); } ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action) @@ -579,14 +579,14 @@ void TransitionSlideInR::sceneOrder() void TransitionSlideInR::initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(s.width-ADJUST_FACTOR,0) ); + _inScene->setPosition( Vec2(s.width-ADJUST_FACTOR,0) ); } ActionInterval* TransitionSlideInR:: action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vector2(-(s.width-ADJUST_FACTOR),0)); + return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0)); } @@ -620,14 +620,14 @@ void TransitionSlideInT::sceneOrder() void TransitionSlideInT::initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(0,s.height-ADJUST_FACTOR) ); + _inScene->setPosition( Vec2(0,s.height-ADJUST_FACTOR) ); } ActionInterval* TransitionSlideInT::action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vector2(0,-(s.height-ADJUST_FACTOR))); + return MoveBy::create(_duration, Vec2(0,-(s.height-ADJUST_FACTOR))); } // @@ -660,14 +660,14 @@ void TransitionSlideInB::sceneOrder() void TransitionSlideInB:: initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition( Vector2(0,-(s.height-ADJUST_FACTOR)) ); + _inScene->setPosition( Vec2(0,-(s.height-ADJUST_FACTOR)) ); } ActionInterval* TransitionSlideInB:: action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vector2(0,s.height-ADJUST_FACTOR)); + return MoveBy::create(_duration, Vec2(0,s.height-ADJUST_FACTOR)); } // @@ -699,8 +699,8 @@ void TransitionShrinkGrow::onEnter() _inScene->setScale(0.001f); _outScene->setScale(1.0f); - _inScene->setAnchorPoint(Vector2(2/3.0f,0.5f)); - _outScene->setAnchorPoint(Vector2(1/3.0f,0.5f)); + _inScene->setAnchorPoint(Vec2(2/3.0f,0.5f)); + _outScene->setAnchorPoint(Vec2(1/3.0f,0.5f)); ActionInterval* scaleOut = ScaleTo::create(_duration, 0.01f); ActionInterval* scaleIn = ScaleTo::create(_duration, 1.0f); @@ -1261,7 +1261,7 @@ TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene) return nullptr; } -void TransitionCrossFade::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { // override draw since both scenes (textures) are rendered in 1 scene } @@ -1284,9 +1284,9 @@ void TransitionCrossFade::onEnter() return; } - inTexture->getSprite()->setAnchorPoint( Vector2(0.5f,0.5f) ); - inTexture->setPosition( Vector2(size.width/2, size.height/2) ); - inTexture->setAnchorPoint( Vector2(0.5f,0.5f) ); + inTexture->getSprite()->setAnchorPoint( Vec2(0.5f,0.5f) ); + inTexture->setPosition( Vec2(size.width/2, size.height/2) ); + inTexture->setAnchorPoint( Vec2(0.5f,0.5f) ); // render inScene to its texturebuffer inTexture->begin(); @@ -1295,9 +1295,9 @@ void TransitionCrossFade::onEnter() // create the second render texture for outScene RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height); - outTexture->getSprite()->setAnchorPoint( Vector2(0.5f,0.5f) ); - outTexture->setPosition( Vector2(size.width/2, size.height/2) ); - outTexture->setAnchorPoint( Vector2(0.5f,0.5f) ); + outTexture->getSprite()->setAnchorPoint( Vec2(0.5f,0.5f) ); + outTexture->setPosition( Vec2(size.width/2, size.height/2) ); + outTexture->setAnchorPoint( Vec2(0.5f,0.5f) ); // render outScene to its texturebuffer outTexture->begin(); @@ -1410,7 +1410,7 @@ void TransitionTurnOffTiles::onExit() TransitionScene::onExit(); } -void TransitionTurnOffTiles::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Scene::draw(renderer, transform, transformUpdated); @@ -1490,7 +1490,7 @@ void TransitionSplitCols::switchTargetToInscene() _gridProxy->setTarget(_inScene); } -void TransitionSplitCols::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Scene::draw(renderer, transform, transformUpdated); _gridProxy->visit(renderer, transform, transformUpdated); @@ -1606,7 +1606,7 @@ void TransitionFadeTR::onExit() TransitionScene::onExit(); } -void TransitionFadeTR::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Scene::draw(renderer, transform, transformUpdated); diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index 8a42ddc262..1d8cd84eb0 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -91,7 +91,7 @@ public: // // Overrides // - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual void onEnter() override; virtual void onExit() override; virtual void cleanup() override; @@ -613,7 +613,7 @@ public : * @js NA * @lua NA */ - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; /** * @js NA * @lua NA @@ -651,7 +651,7 @@ public : virtual void onEnter() override; virtual void onExit() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: TransitionTurnOffTiles(); @@ -684,7 +684,7 @@ public: virtual void onEnter() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual void onExit() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: TransitionSplitCols(); virtual ~TransitionSplitCols(); @@ -735,7 +735,7 @@ public: virtual void onEnter() override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; virtual void onExit() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: TransitionFadeTR(); virtual ~TransitionFadeTR(); diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index fed9981646..5fc9f40311 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -92,7 +92,7 @@ void TransitionPageTurn::onDisablePolygonOffset() glPolygonOffset(0, 0); } -void TransitionPageTurn::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Scene::draw(renderer, transform, transformUpdated); diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index 3fdb165a35..c12339418a 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -72,7 +72,7 @@ public: // // Overrides // - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; /** * Creates a base transition with duration and incoming scene. diff --git a/cocos/2d/CCTransitionProgress.cpp b/cocos/2d/CCTransitionProgress.cpp index 1166f7f1f1..867661e247 100644 --- a/cocos/2d/CCTransitionProgress.cpp +++ b/cocos/2d/CCTransitionProgress.cpp @@ -73,9 +73,9 @@ void TransitionProgress::onEnter() // create the second render texture for outScene RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height); - texture->getSprite()->setAnchorPoint(Vector2(0.5f,0.5f)); - texture->setPosition(Vector2(size.width/2, size.height/2)); - texture->setAnchorPoint(Vector2(0.5f,0.5f)); + texture->getSprite()->setAnchorPoint(Vec2(0.5f,0.5f)); + texture->setPosition(Vec2(size.width/2, size.height/2)); + texture->setAnchorPoint(Vec2(0.5f,0.5f)); // render outScene to its texturebuffer texture->beginWithClear(0, 0, 0, 1); @@ -145,8 +145,8 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R // Return the radial type that we want to use node->setReverseDirection(false); node->setPercentage(100); - node->setPosition(Vector2(size.width/2, size.height/2)); - node->setAnchorPoint(Vector2(0.5f,0.5f)); + node->setPosition(Vec2(size.width/2, size.height/2)); + node->setAnchorPoint(Vec2(0.5f,0.5f)); return node; } @@ -189,8 +189,8 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re // Return the radial type that we want to use node->setReverseDirection(true); node->setPercentage(100); - node->setPosition(Vector2(size.width/2, size.height/2)); - node->setAnchorPoint(Vector2(0.5f,0.5f)); + node->setPosition(Vec2(size.width/2, size.height/2)); + node->setAnchorPoint(Vec2(0.5f,0.5f)); return node; } @@ -218,12 +218,12 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture( node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::BAR); - node->setMidpoint(Vector2(1, 0)); - node->setBarChangeRate(Vector2(1,0)); + node->setMidpoint(Vec2(1, 0)); + node->setBarChangeRate(Vec2(1,0)); node->setPercentage(100); - node->setPosition(Vector2(size.width/2, size.height/2)); - node->setAnchorPoint(Vector2(0.5f,0.5f)); + node->setPosition(Vec2(size.width/2, size.height/2)); + node->setAnchorPoint(Vec2(0.5f,0.5f)); return node; } @@ -251,12 +251,12 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re node->getSprite()->setFlippedY(true); node->setType(ProgressTimer::Type::BAR); - node->setMidpoint(Vector2(0, 0)); - node->setBarChangeRate(Vector2(0,1)); + node->setMidpoint(Vec2(0, 0)); + node->setBarChangeRate(Vec2(0,1)); node->setPercentage(100); - node->setPosition(Vector2(size.width/2, size.height/2)); - node->setAnchorPoint(Vector2(0.5f,0.5f)); + node->setPosition(Vec2(size.width/2, size.height/2)); + node->setAnchorPoint(Vec2(0.5f,0.5f)); return node; } @@ -297,12 +297,12 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::BAR); - node->setMidpoint(Vector2(0.5f, 0.5f)); - node->setBarChangeRate(Vector2(1, 1)); + node->setMidpoint(Vec2(0.5f, 0.5f)); + node->setBarChangeRate(Vec2(1, 1)); node->setPercentage(0); - node->setPosition(Vector2(size.width/2, size.height/2)); - node->setAnchorPoint(Vector2(0.5f,0.5f)); + node->setPosition(Vec2(size.width/2, size.height/2)); + node->setAnchorPoint(Vec2(0.5f,0.5f)); return node; } @@ -331,12 +331,12 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::BAR ); - node->setMidpoint(Vector2(0.5f, 0.5f)); - node->setBarChangeRate(Vector2(1, 1)); + node->setMidpoint(Vec2(0.5f, 0.5f)); + node->setBarChangeRate(Vec2(1, 1)); node->setPercentage(100); - node->setPosition(Vector2(size.width/2, size.height/2)); - node->setAnchorPoint(Vector2(0.5f,0.5f)); + node->setPosition(Vec2(size.width/2, size.height/2)); + node->setAnchorPoint(Vec2(0.5f,0.5f)); return node; } diff --git a/cocos/2d/CCVertex.cpp b/cocos/2d/CCVertex.cpp index 3b08383f0e..8a96b2c2ee 100644 --- a/cocos/2d/CCVertex.cpp +++ b/cocos/2d/CCVertex.cpp @@ -29,7 +29,7 @@ NS_CC_BEGIN -void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints) +void ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned int offset, unsigned int nuPoints) { nuPoints += offset; if(nuPoints<=1) return; @@ -42,8 +42,8 @@ void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, uns for(unsigned int i = offset; i1.0f) diff --git a/cocos/2d/CCVertex.h b/cocos/2d/CCVertex.h index fca1ab3b44..a084a7168e 100644 --- a/cocos/2d/CCVertex.h +++ b/cocos/2d/CCVertex.h @@ -38,7 +38,7 @@ NS_CC_BEGIN /** @file CCVertex.h */ /** converts a line to a polygon */ -void CC_DLL ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints); +void CC_DLL ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned int offset, unsigned int nuPoints); /** returns whether or not the line intersects */ bool CC_DLL ccVertexLineIntersect(float Ax, float Ay, diff --git a/cocos/2d/platform/CCGLViewProtocol.cpp b/cocos/2d/platform/CCGLViewProtocol.cpp index 6090772309..ffd2632bce 100644 --- a/cocos/2d/platform/CCGLViewProtocol.cpp +++ b/cocos/2d/platform/CCGLViewProtocol.cpp @@ -178,16 +178,16 @@ Size GLViewProtocol::getVisibleSize() const } } -Vector2 GLViewProtocol::getVisibleOrigin() const +Vec2 GLViewProtocol::getVisibleOrigin() const { if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) { - return Vector2((_designResolutionSize.width - _screenSize.width/_scaleX)/2, + return Vec2((_designResolutionSize.width - _screenSize.width/_scaleX)/2, (_designResolutionSize.height - _screenSize.height/_scaleY)/2); } else { - return Vector2::ZERO; + return Vec2::ZERO; } } diff --git a/cocos/2d/platform/CCGLViewProtocol.h b/cocos/2d/platform/CCGLViewProtocol.h index aaa795a9e5..3b7404ecd0 100644 --- a/cocos/2d/platform/CCGLViewProtocol.h +++ b/cocos/2d/platform/CCGLViewProtocol.h @@ -113,7 +113,7 @@ public: /** * Get the visible origin point of opengl viewport. */ - virtual Vector2 getVisibleOrigin() const; + virtual Vec2 getVisibleOrigin() const; /** * Get the visible rectangle of opengl viewport. diff --git a/cocos/2d/platform/desktop/CCGLView.cpp b/cocos/2d/platform/desktop/CCGLView.cpp index 4a8783e7a6..30077f7130 100644 --- a/cocos/2d/platform/desktop/CCGLView.cpp +++ b/cocos/2d/platform/desktop/CCGLView.cpp @@ -548,7 +548,7 @@ void GLView::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int if(GLFW_PRESS == action) { _captured = true; - if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Vector2(_mouseX,_mouseY))) + if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Vec2(_mouseX,_mouseY))) { intptr_t id = 0; this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY); diff --git a/cocos/2d/platform/winrt/CCGLView.cpp b/cocos/2d/platform/winrt/CCGLView.cpp index 90a5568562..f78be18d6c 100644 --- a/cocos/2d/platform/winrt/CCGLView.cpp +++ b/cocos/2d/platform/winrt/CCGLView.cpp @@ -165,11 +165,11 @@ void WinRTWindow::ResizeWindow() GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); } -cocos2d::Vector2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) { +cocos2d::Vec2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) { auto p = args->CurrentPoint; float x = getScaledDPIValue(p->Position.X); float y = getScaledDPIValue(p->Position.Y); - Vector2 pt(x, y); + Vec2 pt(x, y); float zoomFactor = GLView::sharedOpenGLView()->getFrameZoomFactor(); @@ -264,7 +264,7 @@ void WinRTWindow::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ ar { float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta; int id = 0; - Vector2 p(0.0f,0.0f); + Vec2 p(0.0f,0.0f); GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &p.x, &p.y); p.y += direction; GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); @@ -288,7 +288,7 @@ void GLView::OnPointerPressed(PointerEventArgs^ args) { #if 0 int id = args->CurrentPoint->PointerId; - Vector2 pt = GetPoint(args); + Vec2 pt = GetPoint(args); handleTouchesBegin(1, &id, &pt.x, &pt.y); #endif } @@ -302,7 +302,7 @@ void GLView::OnPointerMoved(PointerEventArgs^ args) if (m_lastPointValid) { int id = args->CurrentPoint->PointerId; - Vector2 p = GetPoint(args); + Vec2 p = GetPoint(args); handleTouchesMove(1, &id, &p.x, &p.y); } m_lastPoint = currentPoint->Position; @@ -319,7 +319,7 @@ void GLView::OnPointerReleased(PointerEventArgs^ args) { #if 0 int id = args->CurrentPoint->PointerId; - Vector2 pt = GetPoint(args); + Vec2 pt = GetPoint(args); handleTouchesEnd(1, &id, &pt.x, &pt.y); #endif // 0 @@ -330,7 +330,7 @@ void GLView::OnPointerReleased(PointerEventArgs^ args) void WinRTWindow::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; - Vector2 pt = GetCCPoint(args); + Vec2 pt = GetCCPoint(args); GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &pt.x, &pt.y); } @@ -342,7 +342,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) if (m_lastPointValid) { int id = args->CurrentPoint->PointerId; - Vector2 p = GetCCPoint(args); + Vec2 p = GetCCPoint(args); GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); } m_lastPoint = currentPoint->Position; @@ -357,7 +357,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) void WinRTWindow::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; - Vector2 pt = GetCCPoint(args); + Vec2 pt = GetCCPoint(args); GLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &pt.x, &pt.y); } diff --git a/cocos/2d/platform/winrt/CCGLView.h b/cocos/2d/platform/winrt/CCGLView.h index b51e9adf7f..6864805e59 100644 --- a/cocos/2d/platform/winrt/CCGLView.h +++ b/cocos/2d/platform/winrt/CCGLView.h @@ -56,7 +56,7 @@ public: private: - cocos2d::Vector2 GetCCPoint(Windows::UI::Core::PointerEventArgs^ args); + cocos2d::Vec2 GetCCPoint(Windows::UI::Core::PointerEventArgs^ args); void OnTextKeyDown(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void OnTextKeyUp(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); diff --git a/cocos/2d/platform/wp8/CCGLView.cpp b/cocos/2d/platform/wp8/CCGLView.cpp index 5716466c59..d89fab28f5 100644 --- a/cocos/2d/platform/wp8/CCGLView.cpp +++ b/cocos/2d/platform/wp8/CCGLView.cpp @@ -190,7 +190,7 @@ void GLView::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) void GLView::OnPointerPressed(PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; - Vector2 pt = GetPoint(args); + Vec2 pt = GetPoint(args); handleTouchesBegin(1, &id, &pt.x, &pt.y); } @@ -199,7 +199,7 @@ void GLView::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args) { float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta; int id = 0; - Vector2 p(0.0f,0.0f); + Vec2 p(0.0f,0.0f); handleTouchesBegin(1, &id, &p.x, &p.y); p.y += direction; handleTouchesMove(1, &id, &p.x, &p.y); @@ -229,7 +229,7 @@ void GLView::OnPointerMoved( PointerEventArgs^ args) if (m_lastPointValid) { int id = args->CurrentPoint->PointerId; - Vector2 p = GetPoint(args); + Vec2 p = GetPoint(args); handleTouchesMove(1, &id, &p.x, &p.y); } m_lastPoint = currentPoint->Position; @@ -249,7 +249,7 @@ void GLView::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) void GLView::OnPointerReleased(PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; - Vector2 pt = GetPoint(args); + Vec2 pt = GetPoint(args); handleTouchesEnd(1, &id, &pt.x, &pt.y); } @@ -429,9 +429,9 @@ void GLView::UpdateOrientationMatrix() } } -cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Point p) +cocos2d::Vec2 GLView::TransformToOrientation(Windows::Foundation::Point p) { - cocos2d::Vector2 returnValue; + cocos2d::Vec2 returnValue; float x = p.X; float y = p.Y; @@ -440,16 +440,16 @@ cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Point p) { case DisplayOrientations::Portrait: default: - returnValue = Vector2(x, y); + returnValue = Vec2(x, y); break; case DisplayOrientations::Landscape: - returnValue = Vector2(y, m_width - x); + returnValue = Vec2(y, m_width - x); break; case DisplayOrientations::PortraitFlipped: - returnValue = Vector2(m_width - x, m_height - y); + returnValue = Vec2(m_width - x, m_height - y); break; case DisplayOrientations::LandscapeFlipped: - returnValue = Vector2(m_height - y, x); + returnValue = Vec2(m_height - y, x); break; } @@ -464,7 +464,7 @@ cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Point p) return returnValue; } -Vector2 GLView::GetPoint(PointerEventArgs^ args) { +Vec2 GLView::GetPoint(PointerEventArgs^ args) { return TransformToOrientation(args->CurrentPoint->Position); diff --git a/cocos/2d/platform/wp8/CCGLView.h b/cocos/2d/platform/wp8/CCGLView.h index 187c796ad9..9ffa1f9d29 100644 --- a/cocos/2d/platform/wp8/CCGLView.h +++ b/cocos/2d/platform/wp8/CCGLView.h @@ -146,8 +146,8 @@ private: void UpdateWindowSize(); void UpdateOrientationMatrix(); - cocos2d::Vector2 TransformToOrientation(Windows::Foundation::Point point); - cocos2d::Vector2 GetPoint(Windows::UI::Core::PointerEventArgs^ args); + cocos2d::Vec2 TransformToOrientation(Windows::Foundation::Point point); + cocos2d::Vec2 GetPoint(Windows::UI::Core::PointerEventArgs^ args); Windows::Foundation::Rect m_windowBounds; Windows::Foundation::EventRegistrationToken m_eventToken; diff --git a/cocos/2d/platform/wp8/Direct3DBase.cpp b/cocos/2d/platform/wp8/Direct3DBase.cpp index d6e0132f13..f909b07507 100644 --- a/cocos/2d/platform/wp8/Direct3DBase.cpp +++ b/cocos/2d/platform/wp8/Direct3DBase.cpp @@ -330,9 +330,9 @@ void Direct3DBase::ComputeOrientationMatrices() } } -Vector2 Direct3DBase::TransformToOrientation(Vector2 point, bool dipsToPixels) +Vec2 Direct3DBase::TransformToOrientation(Vec2 point, bool dipsToPixels) { - Vector2 returnValue; + Vec2 returnValue; switch (m_orientation) { @@ -340,20 +340,20 @@ Vector2 Direct3DBase::TransformToOrientation(Vector2 point, bool dipsToPixels) returnValue = point; break; case DisplayOrientations::Landscape: - returnValue = Vector2(point.Y, m_windowBounds.Width - point.X); + returnValue = Vec2(point.Y, m_windowBounds.Width - point.X); break; case DisplayOrientations::PortraitFlipped: - returnValue = Vector2(m_windowBounds.Width - point.X, m_windowBounds.Height - point.Y); + returnValue = Vec2(m_windowBounds.Width - point.X, m_windowBounds.Height - point.Y); break; case DisplayOrientations::LandscapeFlipped: - returnValue = Vector2(m_windowBounds.Height -point.Y, point.X); + returnValue = Vec2(m_windowBounds.Height -point.Y, point.X); break; default: throw ref new Platform::FailureException(); break; } - return dipsToPixels ? Vector2(ConvertDipsToPixels(returnValue.X), + return dipsToPixels ? Vec2(ConvertDipsToPixels(returnValue.X), ConvertDipsToPixels(returnValue.Y)) : returnValue; } diff --git a/cocos/2d/platform/wp8/Direct3DBase.h b/cocos/2d/platform/wp8/Direct3DBase.h index a4a61c82e1..dfc4bfd3af 100644 --- a/cocos/2d/platform/wp8/Direct3DBase.h +++ b/cocos/2d/platform/wp8/Direct3DBase.h @@ -24,7 +24,7 @@ public: virtual void Present(); virtual float ConvertDipsToPixels(float dips); virtual void ComputeOrientationMatrices(); - virtual Windows::Foundation::Vector2 TransformToOrientation(Windows::Foundation::Vector2 point, bool dipsToPixels=true); + virtual Windows::Foundation::Vec2 TransformToOrientation(Windows::Foundation::Vec2 point, bool dipsToPixels=true); float getOrientedWindowWidth() {return m_orientedScreenSize.Width;}; float getOrientedWindowHeight() {return m_orientedScreenSize.Height;}; diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 6ef63e5eb5..a70ccabbc7 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -288,14 +288,14 @@ void Director::drawScene() // draw the scene if (_runningScene) { - _runningScene->visit(_renderer, Matrix::IDENTITY, false); + _runningScene->visit(_renderer, Mat4::IDENTITY, false); _eventDispatcher->dispatchEvent(_eventAfterVisit); } // draw the notifications node if (_notificationNode) { - _notificationNode->visit(_renderer, Matrix::IDENTITY, false); + _notificationNode->visit(_renderer, Mat4::IDENTITY, false); } if (_displayStats) @@ -449,9 +449,9 @@ void Director::initMatrixStack() _textureMatrixStack.pop(); } - _modelViewMatrixStack.push(Matrix::IDENTITY); - _projectionMatrixStack.push(Matrix::IDENTITY); - _textureMatrixStack.push(Matrix::IDENTITY); + _modelViewMatrixStack.push(Mat4::IDENTITY); + _projectionMatrixStack.push(Mat4::IDENTITY); + _textureMatrixStack.push(Mat4::IDENTITY); } void Director::resetMatrixStack() @@ -483,15 +483,15 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE type) { if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) { - _modelViewMatrixStack.top() = Matrix::IDENTITY; + _modelViewMatrixStack.top() = Mat4::IDENTITY; } else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type) { - _projectionMatrixStack.top() = Matrix::IDENTITY; + _projectionMatrixStack.top() = Mat4::IDENTITY; } else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type) { - _textureMatrixStack.top() = Matrix::IDENTITY; + _textureMatrixStack.top() = Mat4::IDENTITY; } else { @@ -499,7 +499,7 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE type) } } -void Director::loadMatrix(MATRIX_STACK_TYPE type, const Matrix& mat) +void Director::loadMatrix(MATRIX_STACK_TYPE type, const Mat4& mat) { if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) { @@ -519,7 +519,7 @@ void Director::loadMatrix(MATRIX_STACK_TYPE type, const Matrix& mat) } } -void Director::multiplyMatrix(MATRIX_STACK_TYPE type, const Matrix& mat) +void Director::multiplyMatrix(MATRIX_STACK_TYPE type, const Mat4& mat) { if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) { @@ -559,9 +559,9 @@ void Director::pushMatrix(MATRIX_STACK_TYPE type) } } -Matrix Director::getMatrix(MATRIX_STACK_TYPE type) +Mat4 Director::getMatrix(MATRIX_STACK_TYPE type) { - Matrix result; + Mat4 result; if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) { result = _modelViewMatrixStack.top(); @@ -608,8 +608,8 @@ void Director::setProjection(Projection projection) multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, getOpenGLView()->getOrientationMatrix()); } #endif - Matrix orthoMatrix; - Matrix::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix); + Mat4 orthoMatrix; + Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); break; @@ -619,7 +619,7 @@ void Director::setProjection(Projection projection) { float zeye = this->getZEye(); - Matrix matrixPerspective, matrixLookup; + Mat4 matrixPerspective, matrixLookup; loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); @@ -632,12 +632,12 @@ void Director::setProjection(Projection projection) } #endif // issue #1334 - Matrix::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective); + Mat4::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixPerspective); - Vector3 eye(size.width/2, size.height/2, zeye), center(size.width/2, size.height/2, 0.0f), up(0.0f, 1.0f, 0.0f); - Matrix::createLookAt(eye, center, up, &matrixLookup); + Vec3 eye(size.width/2, size.height/2, zeye), center(size.width/2, size.height/2, 0.0f), up(0.0f, 1.0f, 0.0f); + Mat4::createLookAt(eye, center, up, &matrixLookup); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixLookup); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -712,14 +712,14 @@ void Director::setDepthTest(bool on) CHECK_GL_ERROR_DEBUG(); } -static void GLToClipTransform(Matrix *transformOut) +static void GLToClipTransform(Mat4 *transformOut) { if(nullptr == transformOut) return; Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix projection; + Mat4 projection; projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); #if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 @@ -727,44 +727,44 @@ static void GLToClipTransform(Matrix *transformOut) projection = Director::getInstance()->getOpenGLView()->getReverseOrientationMatrix() * projection; #endif - Matrix modelview; + Mat4 modelview; modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); *transformOut = projection * modelview; } -Vector2 Director::convertToGL(const Vector2& uiPoint) +Vec2 Director::convertToGL(const Vec2& uiPoint) { - Matrix transform; + Mat4 transform; GLToClipTransform(&transform); - Matrix transformInv = transform.getInversed(); + Mat4 transformInv = transform.getInversed(); // Calculate z=0 using -> transform*[0, 0, 0, 1]/w float zClip = transform.m[14]/transform.m[15]; Size glSize = _openGLView->getDesignResolutionSize(); - Vector4 clipCoord(2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip, 1); + Vec4 clipCoord(2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip, 1); - Vector4 glCoord; + Vec4 glCoord; //transformInv.transformPoint(clipCoord, &glCoord); transformInv.transformVector(clipCoord, &glCoord); float factor = 1.0/glCoord.w; - return Vector2(glCoord.x * factor, glCoord.y * factor); + return Vec2(glCoord.x * factor, glCoord.y * factor); } -Vector2 Director::convertToUI(const Vector2& glPoint) +Vec2 Director::convertToUI(const Vec2& glPoint) { - Matrix transform; + Mat4 transform; GLToClipTransform(&transform); - Vector4 clipCoord; + Vec4 clipCoord; // Need to calculate the zero depth from the transform. - Vector4 glCoord(glPoint.x, glPoint.y, 0.0, 1); + Vec4 glCoord(glPoint.x, glPoint.y, 0.0, 1); transform.transformVector(glCoord, &clipCoord); Size glSize = _openGLView->getDesignResolutionSize(); float factor = 1.0/glCoord.w; - return Vector2(glSize.width*(clipCoord.x*0.5 + 0.5) * factor, glSize.height*(-clipCoord.y*0.5 + 0.5) * factor); + return Vec2(glSize.width*(clipCoord.x*0.5 + 0.5) * factor, glSize.height*(-clipCoord.y*0.5 + 0.5) * factor); } const Size& Director::getWinSize(void) const @@ -789,7 +789,7 @@ Size Director::getVisibleSize() const } } -Vector2 Director::getVisibleOrigin() const +Vec2 Director::getVisibleOrigin() const { if (_openGLView) { @@ -797,7 +797,7 @@ Vector2 Director::getVisibleOrigin() const } else { - return Vector2::ZERO; + return Vec2::ZERO; } } @@ -1080,7 +1080,7 @@ void Director::showStats() prevVerts = currentVerts; } - Matrix identity = Matrix::IDENTITY; + Mat4 identity = Mat4::IDENTITY; _drawnVerticesLabel->visit(_renderer, identity, false); _drawnBatchesLabel->visit(_renderer, identity, false); @@ -1165,9 +1165,9 @@ void Director::createStatsLabel() Texture2D::setDefaultAlphaPixelFormat(currentFormat); const int height_spacing = 22 / CC_CONTENT_SCALE_FACTOR(); - _drawnVerticesLabel->setPosition(Vector2(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION); - _drawnBatchesLabel->setPosition(Vector2(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION); - _FPSLabel->setPosition(Vector2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION); + _drawnVerticesLabel->setPosition(Vec2(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION); + _drawnBatchesLabel->setPosition(Vec2(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION); + _FPSLabel->setPosition(Vec2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION); } void Director::setContentScaleFactor(float scaleFactor) diff --git a/cocos/base/CCDirector.h b/cocos/base/CCDirector.h index 6a69f8c2c1..5505787cb0 100644 --- a/cocos/base/CCDirector.h +++ b/cocos/base/CCDirector.h @@ -94,18 +94,18 @@ enum class MATRIX_STACK_TYPE class CC_DLL Director : public Ref { private: - std::stack _modelViewMatrixStack; - std::stack _projectionMatrixStack; - std::stack _textureMatrixStack; + std::stack _modelViewMatrixStack; + std::stack _projectionMatrixStack; + std::stack _textureMatrixStack; protected: void initMatrixStack(); public: void pushMatrix(MATRIX_STACK_TYPE type); void popMatrix(MATRIX_STACK_TYPE type); void loadIdentityMatrix(MATRIX_STACK_TYPE type); - void loadMatrix(MATRIX_STACK_TYPE type, const Matrix& mat); - void multiplyMatrix(MATRIX_STACK_TYPE type, const Matrix& mat); - Matrix getMatrix(MATRIX_STACK_TYPE type); + void loadMatrix(MATRIX_STACK_TYPE type, const Mat4& mat); + void multiplyMatrix(MATRIX_STACK_TYPE type, const Mat4& mat); + Mat4 getMatrix(MATRIX_STACK_TYPE type); void resetMatrixStack(); public: static const char *EVENT_PROJECTION_CHANGED; @@ -231,17 +231,17 @@ public: /** returns visible origin of the OpenGL view in points. */ - Vector2 getVisibleOrigin() const; + Vec2 getVisibleOrigin() const; /** converts a UIKit coordinate to an OpenGL coordinate Useful to convert (multi) touch coordinates to the current layout (portrait or landscape) */ - Vector2 convertToGL(const Vector2& point); + Vec2 convertToGL(const Vec2& point); /** converts an OpenGL coordinate to a UIKit coordinate Useful to convert node points to window points for calls such as glScissor */ - Vector2 convertToUI(const Vector2& point); + Vec2 convertToUI(const Vec2& point); /// XXX: missing description float getZEye() const; @@ -527,6 +527,7 @@ public: DisplayLinkDirector() : _invalid(false) {} + virtual ~DisplayLinkDirector(){} // // Overrides diff --git a/cocos/base/CCNS.cpp b/cocos/base/CCNS.cpp index 112dcdaa4b..452e3a7458 100644 --- a/cocos/base/CCNS.cpp +++ b/cocos/base/CCNS.cpp @@ -144,9 +144,9 @@ Rect RectFromString(const std::string& str) return result; } -Vector2 PointFromString(const std::string& str) +Vec2 PointFromString(const std::string& str) { - Vector2 ret = Vector2::ZERO; + Vec2 ret = Vec2::ZERO; do { @@ -156,7 +156,7 @@ Vector2 PointFromString(const std::string& str) float x = (float) atof(strs[0].c_str()); float y = (float) atof(strs[1].c_str()); - ret = Vector2(x, y); + ret = Vec2(x, y); } while (0); return ret; diff --git a/cocos/base/CCNS.h b/cocos/base/CCNS.h index 7fff7245db..4ee039150a 100644 --- a/cocos/base/CCNS.h +++ b/cocos/base/CCNS.h @@ -55,9 +55,9 @@ Rect CC_DLL RectFromString(const std::string& str); An example of a valid string is "{3.0,2.5}". The string is not localized, so items are always separated with a comma. @return A Core Graphics structure that represents a point. - If the string is not well-formed, the function returns Vector2::ZERO. + If the string is not well-formed, the function returns Vec2::ZERO. */ -Vector2 CC_DLL PointFromString(const std::string& str); +Vec2 CC_DLL PointFromString(const std::string& str); /** @brief Returns a Core Graphics size structure corresponding to the data in a given string. diff --git a/cocos/base/CCTouch.cpp b/cocos/base/CCTouch.cpp index 62798e46d1..1209e222a7 100644 --- a/cocos/base/CCTouch.cpp +++ b/cocos/base/CCTouch.cpp @@ -29,43 +29,43 @@ NS_CC_BEGIN // returns the current touch location in screen coordinates -Vector2 Touch::getLocationInView() const +Vec2 Touch::getLocationInView() const { return _point; } // returns the previous touch location in screen coordinates -Vector2 Touch::getPreviousLocationInView() const +Vec2 Touch::getPreviousLocationInView() const { return _prevPoint; } // returns the start touch location in screen coordinates -Vector2 Touch::getStartLocationInView() const +Vec2 Touch::getStartLocationInView() const { return _startPoint; } // returns the current touch location in OpenGL coordinates -Vector2 Touch::getLocation() const +Vec2 Touch::getLocation() const { return Director::getInstance()->convertToGL(_point); } // returns the previous touch location in OpenGL coordinates -Vector2 Touch::getPreviousLocation() const +Vec2 Touch::getPreviousLocation() const { return Director::getInstance()->convertToGL(_prevPoint); } // returns the start touch location in OpenGL coordinates -Vector2 Touch::getStartLocation() const +Vec2 Touch::getStartLocation() const { return Director::getInstance()->convertToGL(_startPoint); } // returns the delta position between the current location and the previous location in OpenGL coordinates -Vector2 Touch::getDelta() const +Vec2 Touch::getDelta() const { return getLocation() - getPreviousLocation(); } diff --git a/cocos/base/CCTouch.h b/cocos/base/CCTouch.h index 98d37816a8..624016aafd 100644 --- a/cocos/base/CCTouch.h +++ b/cocos/base/CCTouch.h @@ -53,19 +53,19 @@ public: {} /** returns the current touch location in OpenGL coordinates */ - Vector2 getLocation() const; + Vec2 getLocation() const; /** returns the previous touch location in OpenGL coordinates */ - Vector2 getPreviousLocation() const; + Vec2 getPreviousLocation() const; /** returns the start touch location in OpenGL coordinates */ - Vector2 getStartLocation() const; + Vec2 getStartLocation() const; /** returns the delta of 2 current touches locations in screen coordinates */ - Vector2 getDelta() const; + Vec2 getDelta() const; /** returns the current touch location in screen coordinates */ - Vector2 getLocationInView() const; + Vec2 getLocationInView() const; /** returns the previous touch location in screen coordinates */ - Vector2 getPreviousLocationInView() const; + Vec2 getPreviousLocationInView() const; /** returns the start touch location in screen coordinates */ - Vector2 getStartLocationInView() const; + Vec2 getStartLocationInView() const; void setTouchInfo(int id, float x, float y) { @@ -91,9 +91,9 @@ public: private: int _id; bool _startPointCaptured; - Vector2 _startPoint; - Vector2 _point; - Vector2 _prevPoint; + Vec2 _startPoint; + Vec2 _point; + Vec2 _prevPoint; }; // end of input group diff --git a/cocos/base/ccConfig.h b/cocos/base/ccConfig.h index 5727a8944a..5fb3474a7f 100644 --- a/cocos/base/ccConfig.h +++ b/cocos/base/ccConfig.h @@ -109,7 +109,7 @@ To enabled set it to 1. Disabled by default. Default: 0,0 (bottom-left corner) */ #ifndef CC_DIRECTOR_FPS_POSITION -#define CC_DIRECTOR_FPS_POSITION Vector2(0,0) +#define CC_DIRECTOR_FPS_POSITION Vec2(0,0) #endif /** @def CC_DIRECTOR_DISPATCH_FAST_EVENTS diff --git a/cocos/base/ccMacros.h b/cocos/base/ccMacros.h index 917f7329da..476a1e0de7 100644 --- a/cocos/base/ccMacros.h +++ b/cocos/base/ccMacros.h @@ -153,13 +153,13 @@ On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1 Converts a rect in pixels to points */ #define CC_POINT_PIXELS_TO_POINTS(__pixels__) \ -Vector2( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR()) +Vec2( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR()) /** @def CC_POINT_POINTS_TO_PIXELS Converts a rect in points to pixels */ #define CC_POINT_POINTS_TO_PIXELS(__points__) \ -Vector2( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR()) +Vec2( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR()) /** @def CC_POINT_PIXELS_TO_POINTS Converts a rect in pixels to points diff --git a/cocos/base/ccTypes.h b/cocos/base/ccTypes.h index 2806a74aac..3b884d55a8 100644 --- a/cocos/base/ccTypes.h +++ b/cocos/base/ccTypes.h @@ -192,10 +192,10 @@ struct Tex2F { }; -//! Vector2 Sprite component +//! Vec2 Sprite component struct PointSprite { - Vector2 pos; // 8 bytes + Vec2 pos; // 8 bytes Color4B color; // 4 bytes GLfloat size; // 4 bytes }; @@ -203,48 +203,48 @@ struct PointSprite //! A 2D Quad. 4 * 2 floats struct Quad2 { - Vector2 tl; - Vector2 tr; - Vector2 bl; - Vector2 br; + Vec2 tl; + Vec2 tr; + Vec2 bl; + Vec2 br; }; //! A 3D Quad. 4 * 3 floats struct Quad3 { - Vector3 bl; - Vector3 br; - Vector3 tl; - Vector3 tr; + Vec3 bl; + Vec3 br; + Vec3 tl; + Vec3 tr; }; -//! a Vector2 with a vertex point, a tex coord point and a color 4B +//! a Vec2 with a vertex point, a tex coord point and a color 4B struct V2F_C4B_T2F { //! vertices (2F) - Vector2 vertices; + Vec2 vertices; //! colors (4B) Color4B colors; //! tex coords (2F) Tex2F texCoords; }; -//! a Vector2 with a vertex point, a tex coord point and a color 4F +//! a Vec2 with a vertex point, a tex coord point and a color 4F struct V2F_C4F_T2F { //! vertices (2F) - Vector2 vertices; + Vec2 vertices; //! colors (4F) Color4F colors; //! tex coords (2F) Tex2F texCoords; }; -//! a Vector2 with a vertex point, a tex coord point and a color 4B +//! a Vec2 with a vertex point, a tex coord point and a color 4B struct V3F_C4B_T2F { //! vertices (3F) - Vector3 vertices; // 12 bytes + Vec3 vertices; // 12 bytes //! colors (4B) Color4B colors; // 4 bytes @@ -256,11 +256,11 @@ struct V3F_C4B_T2F //! A Triangle of V2F_C4B_T2F struct V2F_C4B_T2F_Triangle { - //! Vector2 A + //! Vec2 A V2F_C4B_T2F a; - //! Vector2 B + //! Vec2 B V2F_C4B_T2F b; - //! Vector2 B + //! Vec2 B V2F_C4B_T2F c; }; diff --git a/cocos/deprecated/CCDeprecated.cpp b/cocos/deprecated/CCDeprecated.cpp index 4c77adebbe..c4bd24010d 100644 --- a/cocos/deprecated/CCDeprecated.cpp +++ b/cocos/deprecated/CCDeprecated.cpp @@ -34,7 +34,7 @@ NS_CC_BEGIN -const Vector2 CCPointZero = Vector2::ZERO; +const Vec2 CCPointZero = Vec2::ZERO; /* The "zero" size -- equivalent to Size(0, 0). */ const Size CCSizeZero = Size::ZERO; @@ -90,67 +90,67 @@ void ccDrawFree() DrawPrimitives::free(); } -void ccDrawPoint( const Vector2& point ) +void ccDrawPoint( const Vec2& point ) { DrawPrimitives::drawPoint(point); } -void ccDrawPoints( const Vector2 *points, unsigned int numberOfPoints ) +void ccDrawPoints( const Vec2 *points, unsigned int numberOfPoints ) { DrawPrimitives::drawPoints(points, numberOfPoints); } -void ccDrawLine( const Vector2& origin, const Vector2& destination ) +void ccDrawLine( const Vec2& origin, const Vec2& destination ) { DrawPrimitives::drawLine(origin, destination); } -void ccDrawRect( Vector2 origin, Vector2 destination ) +void ccDrawRect( Vec2 origin, Vec2 destination ) { DrawPrimitives::drawRect(origin, destination); } -void ccDrawSolidRect( Vector2 origin, Vector2 destination, Color4F color ) +void ccDrawSolidRect( Vec2 origin, Vec2 destination, Color4F color ) { DrawPrimitives::drawSolidRect(origin, destination, color); } -void ccDrawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon ) +void ccDrawPoly( const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon ) { DrawPrimitives::drawPoly(vertices, numOfVertices, closePolygon); } -void ccDrawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color ) +void ccDrawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color ) { DrawPrimitives::drawSolidPoly(poli, numberOfPoints, color); } -void ccDrawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) +void ccDrawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) { DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY); } -void ccDrawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) +void ccDrawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) { DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter); } -void ccDrawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) +void ccDrawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) { DrawPrimitives::drawSolidCircle(center, radius, angle, segments, scaleX, scaleY); } -void ccDrawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments) +void ccDrawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments) { DrawPrimitives::drawSolidCircle(center, radius, angle, segments); } -void ccDrawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments) +void ccDrawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments) { DrawPrimitives::drawQuadBezier(origin, control, destination, segments); } -void ccDrawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments) +void ccDrawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments) { DrawPrimitives::drawCubicBezier(origin, control1, control2, destination, segments); } @@ -216,38 +216,38 @@ void CC_DLL kmGLLoadIdentity(void) Director::getInstance()->loadIdentityMatrix(currentActiveStackType); } -void CC_DLL kmGLLoadMatrix(const Matrix* pIn) +void CC_DLL kmGLLoadMatrix(const Mat4* pIn) { Director::getInstance()->loadMatrix(currentActiveStackType, *pIn); } -void CC_DLL kmGLMultMatrix(const Matrix* pIn) +void CC_DLL kmGLMultMatrix(const Mat4* pIn) { Director::getInstance()->multiplyMatrix(currentActiveStackType, *pIn); } void CC_DLL kmGLTranslatef(float x, float y, float z) { - Matrix mat; - Matrix::createTranslation(Vector3(x, y, z), &mat); + Mat4 mat; + Mat4::createTranslation(Vec3(x, y, z), &mat); Director::getInstance()->multiplyMatrix(currentActiveStackType, mat); } void CC_DLL kmGLRotatef(float angle, float x, float y, float z) { - Matrix mat; - Matrix::createRotation(Vector3(x, y, z), angle, &mat); + Mat4 mat; + Mat4::createRotation(Vec3(x, y, z), angle, &mat); Director::getInstance()->multiplyMatrix(currentActiveStackType, mat); } void CC_DLL kmGLScalef(float x, float y, float z) { - Matrix mat; - Matrix::createScale(x, y, z, &mat); + Mat4 mat; + Mat4::createScale(x, y, z, &mat); Director::getInstance()->multiplyMatrix(currentActiveStackType, mat); } -void CC_DLL kmGLGetMatrix(unsigned int mode, Matrix* pOut) +void CC_DLL kmGLGetMatrix(unsigned int mode, Mat4* pOut) { if(KM_GL_MODELVIEW == mode) *pOut = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -261,97 +261,97 @@ void CC_DLL kmGLGetMatrix(unsigned int mode, Matrix* pOut) } } -Matrix* kmMat4Fill(Matrix* pOut, const float* pMat) +Mat4* kmMat4Fill(Mat4* pOut, const float* pMat) { pOut->set(pMat); return pOut; } -Matrix* kmMat4Assign(Matrix* pOut, const Matrix* pIn) +Mat4* kmMat4Assign(Mat4* pOut, const Mat4* pIn) { pOut->set(pIn->m); return pOut; } -Matrix* kmMat4Identity(Matrix* pOut) +Mat4* kmMat4Identity(Mat4* pOut) { - *pOut = Matrix::IDENTITY; + *pOut = Mat4::IDENTITY; return pOut; } -Matrix* kmMat4Inverse(Matrix* pOut, const Matrix* pM) +Mat4* kmMat4Inverse(Mat4* pOut, const Mat4* pM) { *pOut = pM->getInversed(); return pOut; } -Matrix* kmMat4Transpose(Matrix* pOut, const Matrix* pIn) +Mat4* kmMat4Transpose(Mat4* pOut, const Mat4* pIn) { *pOut = pIn->getTransposed(); return pOut; } -Matrix* kmMat4Multiply(Matrix* pOut, const Matrix* pM1, const Matrix* pM2) +Mat4* kmMat4Multiply(Mat4* pOut, const Mat4* pM1, const Mat4* pM2) { *pOut = (*pM1) * (*pM2); return pOut; } -Matrix* kmMat4Translation(Matrix* pOut, const float x, const float y, const float z) +Mat4* kmMat4Translation(Mat4* pOut, const float x, const float y, const float z) { - Matrix::createTranslation(x, y, z, pOut); + Mat4::createTranslation(x, y, z, pOut); return pOut; } -Matrix* kmMat4RotationX(Matrix* pOut, const float radians) +Mat4* kmMat4RotationX(Mat4* pOut, const float radians) { - Matrix::createRotationX(radians, pOut); + Mat4::createRotationX(radians, pOut); return pOut; } -Matrix* kmMat4RotationY(Matrix* pOut, const float radians) +Mat4* kmMat4RotationY(Mat4* pOut, const float radians) { - Matrix::createRotationY(radians, pOut); + Mat4::createRotationY(radians, pOut); return pOut; } -Matrix* kmMat4RotationZ(Matrix* pOut, const float radians) +Mat4* kmMat4RotationZ(Mat4* pOut, const float radians) { - Matrix::createRotationZ(radians, pOut); + Mat4::createRotationZ(radians, pOut); return pOut; } -Matrix* kmMat4RotationAxisAngle(Matrix* pOut, const Vector3* axis, float radians) +Mat4* kmMat4RotationAxisAngle(Mat4* pOut, const Vec3* axis, float radians) { - Matrix::createRotation(*axis, radians, pOut); + Mat4::createRotation(*axis, radians, pOut); return pOut; } -Matrix* kmMat4Scaling(Matrix* pOut, const float x, const float y, const float z) +Mat4* kmMat4Scaling(Mat4* pOut, const float x, const float y, const float z) { - Matrix::createScale(x, y, z, pOut); + Mat4::createScale(x, y, z, pOut); return pOut; } -Matrix* kmMat4PerspectiveProjection(Matrix* pOut, float fovY, float aspect, float zNear, float zFar) +Mat4* kmMat4PerspectiveProjection(Mat4* pOut, float fovY, float aspect, float zNear, float zFar) { - Matrix::createPerspective(fovY, aspect, zNear, zFar, pOut); + Mat4::createPerspective(fovY, aspect, zNear, zFar, pOut); return pOut; } -Matrix* kmMat4OrthographicProjection(Matrix* pOut, float left, float right, float bottom, float top, float nearVal, float farVal) +Mat4* kmMat4OrthographicProjection(Mat4* pOut, float left, float right, float bottom, float top, float nearVal, float farVal) { - Matrix::createOrthographicOffCenter(left, right, bottom, top, nearVal, farVal, pOut); + Mat4::createOrthographicOffCenter(left, right, bottom, top, nearVal, farVal, pOut); return pOut; } -Matrix* kmMat4LookAt(Matrix* pOut, const Vector3* pEye, const Vector3* pCenter, const Vector3* pUp) +Mat4* kmMat4LookAt(Mat4* pOut, const Vec3* pEye, const Vec3* pCenter, const Vec3* pUp) { - Matrix::createLookAt(*pEye, *pCenter, *pUp, pOut); + Mat4::createLookAt(*pEye, *pCenter, *pUp, pOut); return pOut; } -Vector3* kmVec3Fill(Vector3* pOut, float x, float y, float z) +Vec3* kmVec3Fill(Vec3* pOut, float x, float y, float z) { pOut->x = x; pOut->y = y; @@ -359,17 +359,17 @@ Vector3* kmVec3Fill(Vector3* pOut, float x, float y, float z) return pOut; } -float kmVec3Length(const Vector3* pIn) +float kmVec3Length(const Vec3* pIn) { return pIn->length(); } -float kmVec3LengthSq(const Vector3* pIn) +float kmVec3LengthSq(const Vec3* pIn) { return pIn->lengthSquared(); } -CC_DLL Vector3* kmVec3Lerp(Vector3* pOut, const Vector3* pV1, const Vector3* pV2, float t) +CC_DLL Vec3* kmVec3Lerp(Vec3* pOut, const Vec3* pV1, const Vec3* pV2, float t) { pOut->x = pV1->x + t * ( pV2->x - pV1->x ); pOut->y = pV1->y + t * ( pV2->y - pV1->y ); @@ -377,160 +377,160 @@ CC_DLL Vector3* kmVec3Lerp(Vector3* pOut, const Vector3* pV1, const Vector3* pV2 return pOut; } -Vector3* kmVec3Normalize(Vector3* pOut, const Vector3* pIn) +Vec3* kmVec3Normalize(Vec3* pOut, const Vec3* pIn) { *pOut = pIn->getNormalized(); return pOut; } -Vector3* kmVec3Cross(Vector3* pOut, const Vector3* pV1, const Vector3* pV2) +Vec3* kmVec3Cross(Vec3* pOut, const Vec3* pV1, const Vec3* pV2) { - Vector3::cross(*pV1, *pV2, pOut); + Vec3::cross(*pV1, *pV2, pOut); return pOut; } -float kmVec3Dot(const Vector3* pV1, const Vector3* pV2) +float kmVec3Dot(const Vec3* pV1, const Vec3* pV2) { - return Vector3::dot(*pV1, *pV2); + return Vec3::dot(*pV1, *pV2); } -Vector3* kmVec3Add(Vector3* pOut, const Vector3* pV1, const Vector3* pV2) +Vec3* kmVec3Add(Vec3* pOut, const Vec3* pV1, const Vec3* pV2) { - Vector3::add(*pV1, *pV2, pOut); + Vec3::add(*pV1, *pV2, pOut); return pOut; } -Vector3* kmVec3Subtract(Vector3* pOut, const Vector3* pV1, const Vector3* pV2) +Vec3* kmVec3Subtract(Vec3* pOut, const Vec3* pV1, const Vec3* pV2) { - Vector3::subtract(*pV1, *pV2, pOut); + Vec3::subtract(*pV1, *pV2, pOut); return pOut; } -Vector3* kmVec3Transform(Vector3* pOut, const Vector3* pV1, const Matrix* pM) +Vec3* kmVec3Transform(Vec3* pOut, const Vec3* pV1, const Mat4* pM) { pM->transformPoint(*pV1, pOut); return pOut; } -Vector3* kmVec3TransformNormal(Vector3* pOut, const Vector3* pV, const Matrix* pM) +Vec3* kmVec3TransformNormal(Vec3* pOut, const Vec3* pV, const Mat4* pM) { pM->transformVector(*pV, pOut); return pOut; } -Vector3* kmVec3TransformCoord(Vector3* pOut, const Vector3* pV, const Matrix* pM) +Vec3* kmVec3TransformCoord(Vec3* pOut, const Vec3* pV, const Mat4* pM) { - Vector4 v(pV->x, pV->y, pV->z, 1); + Vec4 v(pV->x, pV->y, pV->z, 1); pM->transformVector(&v); v = v * (1/v.w); pOut->set(v.x, v.y, v.z); return pOut; } -Vector3* kmVec3Scale(Vector3* pOut, const Vector3* pIn, const float s) +Vec3* kmVec3Scale(Vec3* pOut, const Vec3* pIn, const float s) { *pOut = *pIn * s; return pOut; } -Vector3* kmVec3Assign(Vector3* pOut, const Vector3* pIn) +Vec3* kmVec3Assign(Vec3* pOut, const Vec3* pIn) { *pOut = *pIn; return pOut; } -Vector3* kmVec3Zero(Vector3* pOut) +Vec3* kmVec3Zero(Vec3* pOut) { pOut->set(0, 0, 0); return pOut; } -Vector2* kmVec2Fill(Vector2* pOut, float x, float y) +Vec2* kmVec2Fill(Vec2* pOut, float x, float y) { pOut->set(x, y); return pOut; } -float kmVec2Length(const Vector2* pIn) +float kmVec2Length(const Vec2* pIn) { return pIn->length(); } -float kmVec2LengthSq(const Vector2* pIn) +float kmVec2LengthSq(const Vec2* pIn) { return pIn->lengthSquared(); } -Vector2* kmVec2Normalize(Vector2* pOut, const Vector2* pIn) +Vec2* kmVec2Normalize(Vec2* pOut, const Vec2* pIn) { *pOut = pIn->getNormalized(); return pOut; } -Vector2* kmVec2Lerp(Vector2* pOut, const Vector2* pV1, const Vector2* pV2, float t) +Vec2* kmVec2Lerp(Vec2* pOut, const Vec2* pV1, const Vec2* pV2, float t) { pOut->x = pV1->x + t * ( pV2->x - pV1->x ); pOut->y = pV1->y + t * ( pV2->y - pV1->y ); return pOut; } -Vector2* kmVec2Add(Vector2* pOut, const Vector2* pV1, const Vector2* pV2) +Vec2* kmVec2Add(Vec2* pOut, const Vec2* pV1, const Vec2* pV2) { - Vector2::add(*pV1, *pV2, pOut); + Vec2::add(*pV1, *pV2, pOut); return pOut; } -float kmVec2Dot(const Vector2* pV1, const Vector2* pV2) +float kmVec2Dot(const Vec2* pV1, const Vec2* pV2) { - return Vector2::dot(*pV1, *pV2); + return Vec2::dot(*pV1, *pV2); } -Vector2* kmVec2Subtract(Vector2* pOut, const Vector2* pV1, const Vector2* pV2) +Vec2* kmVec2Subtract(Vec2* pOut, const Vec2* pV1, const Vec2* pV2) { - Vector2::subtract(*pV1, *pV2, pOut); + Vec2::subtract(*pV1, *pV2, pOut); return pOut; } -Vector2* kmVec2Scale(Vector2* pOut, const Vector2* pIn, const float s) +Vec2* kmVec2Scale(Vec2* pOut, const Vec2* pIn, const float s) { *pOut = *pIn * s; return pOut; } -Vector2* kmVec2Assign(Vector2* pOut, const Vector2* pIn) +Vec2* kmVec2Assign(Vec2* pOut, const Vec2* pIn) { *pOut = *pIn; return pOut; } -Vector4* kmVec4Fill(Vector4* pOut, float x, float y, float z, float w) +Vec4* kmVec4Fill(Vec4* pOut, float x, float y, float z, float w) { pOut->set(x, y, z, w); return pOut; } -Vector4* kmVec4Add(Vector4* pOut, const Vector4* pV1, const Vector4* pV2) +Vec4* kmVec4Add(Vec4* pOut, const Vec4* pV1, const Vec4* pV2) { - Vector4::add(*pV1, *pV2, pOut); + Vec4::add(*pV1, *pV2, pOut); return pOut; } -float kmVec4Dot(const Vector4* pV1, const Vector4* pV2) +float kmVec4Dot(const Vec4* pV1, const Vec4* pV2) { - return Vector4::dot(*pV1, *pV2); + return Vec4::dot(*pV1, *pV2); } -float kmVec4Length(const Vector4* pIn) +float kmVec4Length(const Vec4* pIn) { return pIn->length(); } -float kmVec4LengthSq(const Vector4* pIn) +float kmVec4LengthSq(const Vec4* pIn) { return pIn->lengthSquared(); } -Vector4* kmVec4Lerp(Vector4* pOut, const Vector4* pV1, const Vector4* pV2, float t) +Vec4* kmVec4Lerp(Vec4* pOut, const Vec4* pV1, const Vec4* pV2, float t) { pOut->x = pV1->x + t * ( pV2->x - pV1->x ); pOut->y = pV1->y + t * ( pV2->y - pV1->y ); @@ -539,55 +539,55 @@ Vector4* kmVec4Lerp(Vector4* pOut, const Vector4* pV1, const Vector4* pV2, float return pOut; } -Vector4* kmVec4Normalize(Vector4* pOut, const Vector4* pIn) +Vec4* kmVec4Normalize(Vec4* pOut, const Vec4* pIn) { *pOut = pIn->getNormalized(); return pOut; } -Vector4* kmVec4Scale(Vector4* pOut, const Vector4* pIn, const float s) +Vec4* kmVec4Scale(Vec4* pOut, const Vec4* pIn, const float s) { *pOut = *pIn * s; return pOut; } -Vector4* kmVec4Subtract(Vector4* pOut, const Vector4* pV1, const Vector4* pV2) +Vec4* kmVec4Subtract(Vec4* pOut, const Vec4* pV1, const Vec4* pV2) { - Vector4::subtract(*pV1, *pV2, pOut); + Vec4::subtract(*pV1, *pV2, pOut); return pOut; } -Vector4* kmVec4Assign(Vector4* pOut, const Vector4* pIn) +Vec4* kmVec4Assign(Vec4* pOut, const Vec4* pIn) { *pOut = *pIn; return pOut; } -Vector4* kmVec4MultiplyMat4(Vector4* pOut, const Vector4* pV, const Matrix* pM) +Vec4* kmVec4MultiplyMat4(Vec4* pOut, const Vec4* pV, const Mat4* pM) { pM->transformVector(*pV, pOut); return pOut; } -Vector4* kmVec4Transform(Vector4* pOut, const Vector4* pV, const Matrix* pM) +Vec4* kmVec4Transform(Vec4* pOut, const Vec4* pV, const Mat4* pM) { pM->transformVector(*pV, pOut); return pOut; } -const Vector3 KM_VEC3_NEG_Z = Vector3(0, 0, -1); -const Vector3 KM_VEC3_POS_Z = Vector3(0, 0, 1); -const Vector3 KM_VEC3_POS_Y = Vector3(0, 1, 0); -const Vector3 KM_VEC3_NEG_Y = Vector3(0, -1, 0); -const Vector3 KM_VEC3_NEG_X = Vector3(-1, 0, 0); -const Vector3 KM_VEC3_POS_X = Vector3(1, 0, 0); -const Vector3 KM_VEC3_ZERO = Vector3(0, 0, 0); +const Vec3 KM_VEC3_NEG_Z = Vec3(0, 0, -1); +const Vec3 KM_VEC3_POS_Z = Vec3(0, 0, 1); +const Vec3 KM_VEC3_POS_Y = Vec3(0, 1, 0); +const Vec3 KM_VEC3_NEG_Y = Vec3(0, -1, 0); +const Vec3 KM_VEC3_NEG_X = Vec3(-1, 0, 0); +const Vec3 KM_VEC3_POS_X = Vec3(1, 0, 0); +const Vec3 KM_VEC3_ZERO = Vec3(0, 0, 0); -const Vector2 KM_VEC2_POS_Y = Vector2(0, 1); -const Vector2 KM_VEC2_NEG_Y = Vector2(0, -1); -const Vector2 KM_VEC2_NEG_X = Vector2(-1, 0); -const Vector2 KM_VEC2_POS_X = Vector2(1, 0); -const Vector2 KM_VEC2_ZERO = Vector2(0, 0); +const Vec2 KM_VEC2_POS_Y = Vec2(0, 1); +const Vec2 KM_VEC2_NEG_Y = Vec2(0, -1); +const Vec2 KM_VEC2_NEG_X = Vec2(-1, 0); +const Vec2 KM_VEC2_POS_X = Vec2(1, 0); +const Vec2 KM_VEC2_ZERO = Vec2(0, 0); NS_CC_END diff --git a/cocos/deprecated/CCDeprecated.h b/cocos/deprecated/CCDeprecated.h index 7f89021b8c..e8b154e6b5 100644 --- a/cocos/deprecated/CCDeprecated.h +++ b/cocos/deprecated/CCDeprecated.h @@ -40,66 +40,66 @@ NS_CC_BEGIN * @{ */ -/** Helper macro that creates a Vector2 - @return Vector2 +/** Helper macro that creates a Vec2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE inline Vector2 ccp(float x, float y) +CC_DEPRECATED_ATTRIBUTE inline Vec2 ccp(float x, float y) { - return Vector2(x, y); + return Vec2(x, y); } /** Returns opposite of point. - @return Vector2 + @return Vec2 @since v0.7.2 - @deprecated please use Vector2::-, for example: -v1 + @deprecated please use Vec2::-, for example: -v1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpNeg(const Vector2& v) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpNeg(const Vec2& v) { return -v; } /** Calculates sum of two points. - @return Vector2 + @return Vec2 @since v0.7.2 - @deprecated please use Vector2::+, for example: v1 + v2 + @deprecated please use Vec2::+, for example: v1 + v2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpAdd(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpAdd(const Vec2& v1, const Vec2& v2) { return v1 + v2; } /** Calculates difference of two points. - @return Vector2 + @return Vec2 @since v0.7.2 - @deprecated please use Vector2::-, for example: v1 - v2 + @deprecated please use Vec2::-, for example: v1 - v2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpSub(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpSub(const Vec2& v1, const Vec2& v2) { return v1 - v2; } /** Returns point multiplied by given factor. - @return Vector2 + @return Vec2 @since v0.7.2 - @deprecated please use Vector2::*, for example: v1 * v2 + @deprecated please use Vec2::*, for example: v1 * v2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpMult(const Vector2& v, const float s) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpMult(const Vec2& v, const float s) { return v * s; } /** Calculates midpoint between two points. - @return Vector2 + @return Vec2 @since v0.7.2 @deprecated please use it like (v1 + v2) / 2.0f */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpMidpoint(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpMidpoint(const Vec2& v1, const Vec2& v2) { return v1.getMidpoint(v2); } @@ -109,7 +109,7 @@ ccpMidpoint(const Vector2& v1, const Vector2& v2) @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float -ccpDot(const Vector2& v1, const Vector2& v2) +ccpDot(const Vec2& v1, const Vec2& v2) { return v1.dot(v2); } @@ -119,67 +119,67 @@ ccpDot(const Vector2& v1, const Vector2& v2) @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float -ccpCross(const Vector2& v1, const Vector2& v2) +ccpCross(const Vec2& v1, const Vec2& v2) { return v1.cross(v2); } /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpPerp(const Vector2& v) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpPerp(const Vec2& v) { return v.getPerp(); } /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpRPerp(const Vector2& v) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpRPerp(const Vec2& v) { return v.getRPerp(); } /** Calculates the projection of v1 over v2. - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpProject(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpProject(const Vec2& v1, const Vec2& v2) { return v1.project(v2); } /** Rotates two points. - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpRotate(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpRotate(const Vec2& v1, const Vec2& v2) { return v1.rotate(v2); } /** Unrotates two points. - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 -ccpUnrotate(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 +ccpUnrotate(const Vec2& v1, const Vec2& v2) { return v1.unrotate(v2); } -/** Calculates the square length of a Vector2 (not calling sqrt() ) +/** Calculates the square length of a Vec2 (not calling sqrt() ) @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float -ccpLengthSQ(const Vector2& v) +ccpLengthSQ(const Vec2& v) { return v.getLengthSq(); } @@ -190,7 +190,7 @@ ccpLengthSQ(const Vector2& v) @since v1.1 */ CC_DEPRECATED_ATTRIBUTE static inline float -ccpDistanceSQ(const Vector2 p1, const Vector2 p2) +ccpDistanceSQ(const Vec2 p1, const Vec2 p2) { return (p1 - p2).getLengthSq(); } @@ -200,7 +200,7 @@ ccpDistanceSQ(const Vector2 p1, const Vector2 p2) @return float @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline float ccpLength(const Vector2& v) +CC_DEPRECATED_ATTRIBUTE static inline float ccpLength(const Vec2& v) { return v.getLength(); } @@ -209,34 +209,34 @@ CC_DEPRECATED_ATTRIBUTE static inline float ccpLength(const Vector2& v) @return float @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline float ccpDistance(const Vector2& v1, const Vector2& v2) +CC_DEPRECATED_ATTRIBUTE static inline float ccpDistance(const Vec2& v1, const Vec2& v2) { return v1.getDistance(v2); } /** Returns point multiplied to a length of 1. - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpNormalize(const Vector2& v) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpNormalize(const Vec2& v) { return v.getNormalized(); } /** Converts radians to a normalized vector. - @return Vector2 + @return Vec2 @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpForAngle(const float a) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpForAngle(const float a) { - return Vector2::forAngle(a); + return Vec2::forAngle(a); } /** Converts a vector to radians. @return float @since v0.7.2 */ -CC_DEPRECATED_ATTRIBUTE static inline float ccpToAngle(const Vector2& v) +CC_DEPRECATED_ATTRIBUTE static inline float ccpToAngle(const Vec2& v) { return v.getAngle(); } @@ -245,17 +245,17 @@ CC_DEPRECATED_ATTRIBUTE static inline float ccpToAngle(const Vector2& v) /** Clamp a point between from and to. @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpClamp(const Vector2& p, const Vector2& from, const Vector2& to) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpClamp(const Vec2& p, const Vec2& from, const Vec2& to) { return p.getClampPoint(from, to); } -/** Quickly convert Size to a Vector2 +/** Quickly convert Size to a Vec2 @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpFromSize(const Size& s) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpFromSize(const Size& s) { - return Vector2(s); + return Vec2(s); } /** Run a math operation function on each point component @@ -265,7 +265,7 @@ CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpFromSize(const Size& s) * ccpCompOp(p,floorf); @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpCompOp(const Vector2& p, float (*opFunc)(float)) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpCompOp(const Vec2& p, float (*opFunc)(float)) { return p.compOp(opFunc); } @@ -277,7 +277,7 @@ CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpCompOp(const Vector2& p, float otherwise a value between a..b @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpLerp(const Vector2& a, const Vector2& b, float alpha) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpLerp(const Vec2& a, const Vec2& b, float alpha) { return a.lerp(b, alpha); } @@ -286,7 +286,7 @@ CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpLerp(const Vector2& a, const Ve /** @returns if points have fuzzy equality which means equal with some degree of variance. @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline bool ccpFuzzyEqual(const Vector2& a, const Vector2& b, float variance) +CC_DEPRECATED_ATTRIBUTE static inline bool ccpFuzzyEqual(const Vec2& a, const Vec2& b, float variance) { return a.fuzzyEquals(b, variance); } @@ -296,15 +296,15 @@ CC_DEPRECATED_ATTRIBUTE static inline bool ccpFuzzyEqual(const Vector2& a, const @returns a component-wise multiplication @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpCompMult(const Vector2& a, const Vector2& b) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpCompMult(const Vec2& a, const Vec2& b) { - return Vector2(a.x * b.x, a.y * b.y); + return Vec2(a.x * b.x, a.y * b.y); } /** @returns the signed angle in radians between two vector directions @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline float ccpAngleSigned(const Vector2& a, const Vector2& b) +CC_DEPRECATED_ATTRIBUTE static inline float ccpAngleSigned(const Vec2& a, const Vec2& b) { return a.getAngle(b); } @@ -312,7 +312,7 @@ CC_DEPRECATED_ATTRIBUTE static inline float ccpAngleSigned(const Vector2& a, con /** @returns the angle in radians between two vector directions @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline float ccpAngle(const Vector2& a, const Vector2& b) +CC_DEPRECATED_ATTRIBUTE static inline float ccpAngle(const Vec2& a, const Vec2& b) { return a.getAngle(b); } @@ -324,7 +324,7 @@ CC_DEPRECATED_ATTRIBUTE static inline float ccpAngle(const Vector2& a, const Vec @returns the rotated point @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpRotateByAngle(const Vector2& v, const Vector2& pivot, float angle) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpRotateByAngle(const Vec2& v, const Vec2& pivot, float angle) { return v.rotateByAngle(pivot, angle); } @@ -350,34 +350,34 @@ CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpRotateByAngle(const Vector2& v, the hit point also is p1 + s * (p2 - p1); @since v0.99.1 */ -CC_DEPRECATED_ATTRIBUTE static inline bool ccpLineIntersect(const Vector2& p1, const Vector2& p2, - const Vector2& p3, const Vector2& p4, +CC_DEPRECATED_ATTRIBUTE static inline bool ccpLineIntersect(const Vec2& p1, const Vec2& p2, + const Vec2& p3, const Vec2& p4, float *s, float *t) { - return Vector2::isLineIntersect(p1, p2, p3, p4, s, t); + return Vec2::isLineIntersect(p1, p2, p3, p4, s, t); } /* ccpSegmentIntersect returns true if Segment A-B intersects with segment C-D @since v1.0.0 */ -CC_DEPRECATED_ATTRIBUTE static inline bool ccpSegmentIntersect(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D) +CC_DEPRECATED_ATTRIBUTE static inline bool ccpSegmentIntersect(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D) { - return Vector2::isSegmentIntersect(A, B, C, D); + return Vec2::isSegmentIntersect(A, B, C, D); } /* ccpIntersectPoint returns the intersection point of line A-B, C-D @since v1.0.0 */ -CC_DEPRECATED_ATTRIBUTE static inline Vector2 ccpIntersectPoint(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 ccpIntersectPoint(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D) { - return Vector2::getIntersectPoint(A, B, C, D); + return Vec2::getIntersectPoint(A, B, C, D); } -CC_DEPRECATED_ATTRIBUTE inline Vector2 CCPointMake(float x, float y) +CC_DEPRECATED_ATTRIBUTE inline Vec2 CCPointMake(float x, float y) { - return Vector2(x, y); + return Vec2(x, y); } CC_DEPRECATED_ATTRIBUTE inline Size CCSizeMake(float width, float height) @@ -391,7 +391,7 @@ CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, fl } -CC_DEPRECATED_ATTRIBUTE extern const Vector2 CCPointZero; +CC_DEPRECATED_ATTRIBUTE extern const Vec2 CCPointZero; /* The "zero" size -- equivalent to Size(0, 0). */ CC_DEPRECATED_ATTRIBUTE extern const Size CCSizeZero; @@ -454,15 +454,15 @@ CC_DEPRECATED_ATTRIBUTE static inline bool ccc4FEqual(Color4F a, Color4F b) return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; } -CC_DEPRECATED_ATTRIBUTE static inline Vector2 vertex2(const float x, const float y) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 vertex2(const float x, const float y) { - Vector2 c(x, y); + Vec2 c(x, y); return c; } -CC_DEPRECATED_ATTRIBUTE static inline Vector3 vertex3(const float x, const float y, const float z) +CC_DEPRECATED_ATTRIBUTE static inline Vec3 vertex3(const float x, const float y, const float z) { - Vector3 c(x, y, z); + Vec3 c(x, y, z); return c; } @@ -477,7 +477,7 @@ CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMake(floa return AffineTransformMake(a, b, c, d, tx, ty); } -CC_DEPRECATED_ATTRIBUTE static inline Vector2 CCPointApplyAffineTransform(const Vector2& point, const AffineTransform& t) +CC_DEPRECATED_ATTRIBUTE static inline Vec2 CCPointApplyAffineTransform(const Vec2& point, const AffineTransform& t) { return PointApplyAffineTransform(point, t); } @@ -770,17 +770,17 @@ CC_DEPRECATED_ATTRIBUTE typedef GLView CCEGLView; CC_DEPRECATED_ATTRIBUTE typedef Component CCComponent; CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform; -CC_DEPRECATED_ATTRIBUTE typedef Vector2 CCPoint; -CC_DEPRECATED_ATTRIBUTE typedef Vector2 Point; +CC_DEPRECATED_ATTRIBUTE typedef Vec2 CCPoint; +CC_DEPRECATED_ATTRIBUTE typedef Vec2 Point; CC_DEPRECATED_ATTRIBUTE typedef Size CCSize; CC_DEPRECATED_ATTRIBUTE typedef Rect CCRect; CC_DEPRECATED_ATTRIBUTE typedef Color3B ccColor3B; CC_DEPRECATED_ATTRIBUTE typedef Color4F ccColor4F; CC_DEPRECATED_ATTRIBUTE typedef Color4B ccColor4B; -CC_DEPRECATED_ATTRIBUTE typedef Vector2 ccVertex2F; -CC_DEPRECATED_ATTRIBUTE typedef Vector2 Vertex2F; -CC_DEPRECATED_ATTRIBUTE typedef Vector3 ccVertex3F; -CC_DEPRECATED_ATTRIBUTE typedef Vector3 Vertex3F; +CC_DEPRECATED_ATTRIBUTE typedef Vec2 ccVertex2F; +CC_DEPRECATED_ATTRIBUTE typedef Vec2 Vertex2F; +CC_DEPRECATED_ATTRIBUTE typedef Vec3 ccVertex3F; +CC_DEPRECATED_ATTRIBUTE typedef Vec3 Vertex3F; CC_DEPRECATED_ATTRIBUTE typedef Tex2F ccTex2F; CC_DEPRECATED_ATTRIBUTE typedef PointSprite ccPointSprite; CC_DEPRECATED_ATTRIBUTE typedef Quad2 ccQuad2; @@ -991,19 +991,19 @@ CC_DEPRECATED_ATTRIBUTE void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawInit(); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawFree(); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoint( const Vector2& point ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoints( const Vector2 *points, unsigned int numberOfPoints ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawLine( const Vector2& origin, const Vector2& destination ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawRect( Vector2 origin, Vector2 destination ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidRect( Vector2 origin, Vector2 destination, Color4F color ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoint( const Vec2& point ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoints( const Vec2 *points, unsigned int numberOfPoints ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawLine( const Vec2& origin, const Vec2& destination ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawRect( Vec2 origin, Vec2 destination ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidRect( Vec2 origin, Vec2 destination, Color4F color ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoly( const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); @@ -1057,7 +1057,7 @@ CC_DEPRECATED_ATTRIBUTE typedef __LayerRGBA LayerRGBA; CC_DEPRECATED_ATTRIBUTE typedef float kmScalar; //kmMat4 and kmMat4 stack -CC_DEPRECATED_ATTRIBUTE typedef Matrix kmMat4; +CC_DEPRECATED_ATTRIBUTE typedef Mat4 kmMat4; CC_DEPRECATED_ATTRIBUTE const unsigned int KM_GL_MODELVIEW = 0x1700; CC_DEPRECATED_ATTRIBUTE const unsigned int KM_GL_PROJECTION = 0x1701; CC_DEPRECATED_ATTRIBUTE const unsigned int KM_GL_TEXTURE = 0x1702; @@ -1067,90 +1067,90 @@ CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLPushMatrix(void); CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLPopMatrix(void); CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLMatrixMode(unsigned int mode); CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLLoadIdentity(void); -CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLLoadMatrix(const Matrix* pIn); -CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLMultMatrix(const Matrix* pIn); +CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLLoadMatrix(const Mat4* pIn); +CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLMultMatrix(const Mat4* pIn); CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLTranslatef(float x, float y, float z); CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLRotatef(float angle, float x, float y, float z); CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLScalef(float x, float y, float z); -CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLGetMatrix(unsigned int mode, Matrix* pOut); +CC_DEPRECATED_ATTRIBUTE void CC_DLL kmGLGetMatrix(unsigned int mode, Mat4* pOut); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Fill(Matrix* pOut, const float* pMat); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Assign(Matrix* pOut, const Matrix* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Identity(Matrix* pOut); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Inverse(Matrix* pOut, const Matrix* pM); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Transpose(Matrix* pOut, const Matrix* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Multiply(Matrix* pOut, const Matrix* pM1, const Matrix* pM2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Translation(Matrix* pOut, const float x, const float y, const float z); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4RotationX(Matrix* pOut, const float radians); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4RotationY(Matrix* pOut, const float radians); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4RotationZ(Matrix* pOut, const float radians); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4RotationAxisAngle(Matrix* pOut, const Vector3* axis, float radians); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4Scaling(Matrix* pOut, const float x, const float y, const float z); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Fill(Mat4* pOut, const float* pMat); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Assign(Mat4* pOut, const Mat4* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Identity(Mat4* pOut); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Inverse(Mat4* pOut, const Mat4* pM); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Transpose(Mat4* pOut, const Mat4* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Multiply(Mat4* pOut, const Mat4* pM1, const Mat4* pM2); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Translation(Mat4* pOut, const float x, const float y, const float z); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4RotationX(Mat4* pOut, const float radians); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4RotationY(Mat4* pOut, const float radians); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4RotationZ(Mat4* pOut, const float radians); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4RotationAxisAngle(Mat4* pOut, const Vec3* axis, float radians); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4Scaling(Mat4* pOut, const float x, const float y, const float z); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4PerspectiveProjection(Matrix* pOut, float fovY, float aspect, float zNear, float zFar); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4OrthographicProjection(Matrix* pOut, float left, float right, float bottom, float top, float nearVal, float farVal); -CC_DEPRECATED_ATTRIBUTE CC_DLL Matrix* kmMat4LookAt(Matrix* pOut, const Vector3* pEye, const Vector3* pCenter, const Vector3* pUp); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4PerspectiveProjection(Mat4* pOut, float fovY, float aspect, float zNear, float zFar); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4OrthographicProjection(Mat4* pOut, float left, float right, float bottom, float top, float nearVal, float farVal); +CC_DEPRECATED_ATTRIBUTE CC_DLL Mat4* kmMat4LookAt(Mat4* pOut, const Vec3* pEye, const Vec3* pCenter, const Vec3* pUp); //kmVec3 -CC_DEPRECATED_ATTRIBUTE typedef Vector3 kmVec3; -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Fill(Vector3* pOut, float x, float y, float z); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec3Length(const Vector3* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec3LengthSq(const Vector3* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Lerp(Vector3* pOut, const Vector3* pV1, const Vector3* pV2, float t); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Normalize(Vector3* pOut, const Vector3* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Cross(Vector3* pOut, const Vector3* pV1, const Vector3* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec3Dot(const Vector3* pV1, const Vector3* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Add(Vector3* pOut, const Vector3* pV1, const Vector3* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Subtract(Vector3* pOut, const Vector3* pV1, const Vector3* pV2); +CC_DEPRECATED_ATTRIBUTE typedef Vec3 kmVec3; +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Fill(Vec3* pOut, float x, float y, float z); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec3Length(const Vec3* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec3LengthSq(const Vec3* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Lerp(Vec3* pOut, const Vec3* pV1, const Vec3* pV2, float t); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Normalize(Vec3* pOut, const Vec3* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Cross(Vec3* pOut, const Vec3* pV1, const Vec3* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec3Dot(const Vec3* pV1, const Vec3* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Add(Vec3* pOut, const Vec3* pV1, const Vec3* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Subtract(Vec3* pOut, const Vec3* pV1, const Vec3* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Transform(Vector3* pOut, const Vector3* pV1, const Matrix* pM); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3TransformNormal(Vector3* pOut, const Vector3* pV, const Matrix* pM); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3TransformCoord(Vector3* pOut, const Vector3* pV, const Matrix* pM); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Scale(Vector3* pOut, const Vector3* pIn, const float s); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Assign(Vector3* pOut, const Vector3* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector3* kmVec3Zero(Vector3* pOut); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Transform(Vec3* pOut, const Vec3* pV1, const Mat4* pM); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3TransformNormal(Vec3* pOut, const Vec3* pV, const Mat4* pM); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3TransformCoord(Vec3* pOut, const Vec3* pV, const Mat4* pM); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Scale(Vec3* pOut, const Vec3* pIn, const float s); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Assign(Vec3* pOut, const Vec3* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec3* kmVec3Zero(Vec3* pOut); -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_NEG_Z; -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_POS_Z; -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_POS_Y; -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_NEG_Y; -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_NEG_X; -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_POS_X; -CC_DEPRECATED_ATTRIBUTE extern const Vector3 KM_VEC3_ZERO; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_NEG_Z; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_POS_Z; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_POS_Y; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_NEG_Y; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_NEG_X; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_POS_X; +CC_DEPRECATED_ATTRIBUTE extern const Vec3 KM_VEC3_ZERO; //kmVec2 -CC_DEPRECATED_ATTRIBUTE typedef Vector2 kmVec2; -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Fill(Vector2* pOut, float x, float y); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec2Length(const Vector2* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec2LengthSq(const Vector2* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Normalize(Vector2* pOut, const Vector2* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Lerp(Vector2* pOut, const Vector2* pV1, const Vector2* pV2, float t); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Add(Vector2* pOut, const Vector2* pV1, const Vector2* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec2Dot(const Vector2* pV1, const Vector2* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Subtract(Vector2* pOut, const Vector2* pV1, const Vector2* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Scale(Vector2* pOut, const Vector2* pIn, const float s); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector2* kmVec2Assign(Vector2* pOut, const Vector2* pIn); +CC_DEPRECATED_ATTRIBUTE typedef Vec2 kmVec2; +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Fill(Vec2* pOut, float x, float y); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec2Length(const Vec2* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec2LengthSq(const Vec2* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Normalize(Vec2* pOut, const Vec2* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Lerp(Vec2* pOut, const Vec2* pV1, const Vec2* pV2, float t); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Add(Vec2* pOut, const Vec2* pV1, const Vec2* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec2Dot(const Vec2* pV1, const Vec2* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Subtract(Vec2* pOut, const Vec2* pV1, const Vec2* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Scale(Vec2* pOut, const Vec2* pIn, const float s); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec2* kmVec2Assign(Vec2* pOut, const Vec2* pIn); -CC_DEPRECATED_ATTRIBUTE extern const Vector2 KM_VEC2_POS_Y; -CC_DEPRECATED_ATTRIBUTE extern const Vector2 KM_VEC2_NEG_Y; -CC_DEPRECATED_ATTRIBUTE extern const Vector2 KM_VEC2_NEG_X; -CC_DEPRECATED_ATTRIBUTE extern const Vector2 KM_VEC2_POS_X; -CC_DEPRECATED_ATTRIBUTE extern const Vector2 KM_VEC2_ZERO; +CC_DEPRECATED_ATTRIBUTE extern const Vec2 KM_VEC2_POS_Y; +CC_DEPRECATED_ATTRIBUTE extern const Vec2 KM_VEC2_NEG_Y; +CC_DEPRECATED_ATTRIBUTE extern const Vec2 KM_VEC2_NEG_X; +CC_DEPRECATED_ATTRIBUTE extern const Vec2 KM_VEC2_POS_X; +CC_DEPRECATED_ATTRIBUTE extern const Vec2 KM_VEC2_ZERO; //kmVec4 -CC_DEPRECATED_ATTRIBUTE typedef Vector4 kmVec4; -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Fill(Vector4* pOut, float x, float y, float z, float w); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Add(Vector4* pOut, const Vector4* pV1, const Vector4* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec4Dot(const Vector4* pV1, const Vector4* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec4Length(const Vector4* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec4LengthSq(const Vector4* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Lerp(Vector4* pOut, const Vector4* pV1, const Vector4* pV2, float t); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Normalize(Vector4* pOut, const Vector4* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Scale(Vector4* pOut, const Vector4* pIn, const float s); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Subtract(Vector4* pOut, const Vector4* pV1, const Vector4* pV2); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Assign(Vector4* pOut, const Vector4* pIn); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4MultiplyMat4(Vector4* pOut, const Vector4* pV, const Matrix* pM); -CC_DEPRECATED_ATTRIBUTE CC_DLL Vector4* kmVec4Transform(Vector4* pOut, const Vector4* pV, const Matrix* pM); +CC_DEPRECATED_ATTRIBUTE typedef Vec4 kmVec4; +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Fill(Vec4* pOut, float x, float y, float z, float w); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Add(Vec4* pOut, const Vec4* pV1, const Vec4* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec4Dot(const Vec4* pV1, const Vec4* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec4Length(const Vec4* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL float kmVec4LengthSq(const Vec4* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Lerp(Vec4* pOut, const Vec4* pV1, const Vec4* pV2, float t); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Normalize(Vec4* pOut, const Vec4* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Scale(Vec4* pOut, const Vec4* pIn, const float s); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Subtract(Vec4* pOut, const Vec4* pV1, const Vec4* pV2); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Assign(Vec4* pOut, const Vec4* pIn); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4MultiplyMat4(Vec4* pOut, const Vec4* pV, const Mat4* pM); +CC_DEPRECATED_ATTRIBUTE CC_DLL Vec4* kmVec4Transform(Vec4* pOut, const Vec4* pV, const Mat4* pM); //end of deprecated attributes and methods for kazMath diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index ff7cb97304..e8efa687fb 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -380,7 +380,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr Size containerSize = getContainerSize(pNode->getParent()); - Vector2 absPos = getAbsolutePosition(Vector2(x,y), type, containerSize, propName); + Vec2 absPos = getAbsolutePosition(Vec2(x,y), type, containerSize, propName); return MoveTo::create(duration, absPos); } @@ -452,7 +452,7 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); - pNode->setPosition(getAbsolutePosition(Vector2(x,y), type, getContainerSize(pNode->getParent()), propName)); + pNode->setPosition(getAbsolutePosition(Vec2(x,y), type, getContainerSize(pNode->getParent()), propName)); } else if (propName == "scale") { diff --git a/cocos/editor-support/cocosbuilder/CCControlButtonLoader.cpp b/cocos/editor-support/cocosbuilder/CCControlButtonLoader.cpp index 5a11278e91..74c6cf37aa 100644 --- a/cocos/editor-support/cocosbuilder/CCControlButtonLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCControlButtonLoader.cpp @@ -68,7 +68,7 @@ void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParen } } -void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vector2 pPoint, CCBReader * ccbReader) { +void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) { ((ControlButton *)pNode)->setLabelAnchorPoint(pPoint); } else { diff --git a/cocos/editor-support/cocosbuilder/CCControlButtonLoader.h b/cocos/editor-support/cocosbuilder/CCControlButtonLoader.h index 12e591fe62..2259f90470 100644 --- a/cocos/editor-support/cocosbuilder/CCControlButtonLoader.h +++ b/cocos/editor-support/cocosbuilder/CCControlButtonLoader.h @@ -29,7 +29,7 @@ class ControlButtonLoader : public ControlLoader { virtual void onHandlePropTypeString(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pString, CCBReader * ccbReader); virtual void onHandlePropTypeFontTTF(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader); virtual void onHandlePropTypeFloatScale(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader); - virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vector2 pPoint, CCBReader * ccbReader); + virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader); virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); diff --git a/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.cpp b/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.cpp index 7b61318474..aaf3eddbce 100644 --- a/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.cpp @@ -40,7 +40,7 @@ void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent } -void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vector2 pPoint, CCBReader * ccbReader) { +void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) { ((LayerGradient *)pNode)->setVector(pPoint); diff --git a/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.h b/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.h index 55569df800..cf4222b0bd 100644 --- a/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.h +++ b/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.h @@ -22,7 +22,7 @@ protected: virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); - virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vector2 pPoint, CCBReader * ccbReader); + virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); }; diff --git a/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.cpp b/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.cpp index 64c6fd353b..633237cd90 100644 --- a/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.cpp +++ b/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.cpp @@ -5,9 +5,9 @@ using namespace cocos2d; namespace cocosbuilder { -Vector2 getAbsolutePosition(const Vector2 &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName) +Vec2 getAbsolutePosition(const Vec2 &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName) { - Vector2 absPt = Vector2(0,0); + Vec2 absPt = Vec2(0,0); if (type == CCBReader::PositionType::RELATIVE_BOTTOM_LEFT) { absPt = pt; diff --git a/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.h b/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.h index 657cbaa963..c451d2bfc2 100644 --- a/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.h +++ b/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.h @@ -5,7 +5,7 @@ namespace cocosbuilder { -extern cocos2d::Vector2 getAbsolutePosition(const cocos2d::Vector2 &pt, CCBReader::PositionType type, const cocos2d::Size &containerSize, const std::string&propName); +extern cocos2d::Vec2 getAbsolutePosition(const cocos2d::Vec2 &pt, CCBReader::PositionType type, const cocos2d::Size &containerSize, const std::string&propName); extern void setRelativeScale(cocos2d::Node *node, float scaleX, float scaleY, CCBReader::ScaleType type, const std::string& propName); diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index 9c2f987e20..f97adba07f 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -110,7 +110,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe { case CCBReader::PropertyType::POSITION: { - Vector2 position = this->parsePropTypePosition(pNode, pParent, ccbReader, propertyName.c_str()); + Vec2 position = this->parsePropTypePosition(pNode, pParent, ccbReader, propertyName.c_str()); if (setProp) { this->onHandlePropTypePosition(pNode, pParent, propertyName.c_str(), position, ccbReader); @@ -119,7 +119,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe } case CCBReader::PropertyType::POINT: { - Vector2 point = this->parsePropTypePoint(pNode, pParent, ccbReader); + Vec2 point = this->parsePropTypePoint(pNode, pParent, ccbReader); if (setProp) { this->onHandlePropTypePoint(pNode, pParent, propertyName.c_str(), point, ccbReader); @@ -128,7 +128,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe } case CCBReader::PropertyType::POINT_LOCK: { - Vector2 pointLock = this->parsePropTypePointLock(pNode, pParent, ccbReader); + Vec2 pointLock = this->parsePropTypePointLock(pNode, pParent, ccbReader); if (setProp) { this->onHandlePropTypePointLock(pNode, pParent, propertyName.c_str(), pointLock, ccbReader); @@ -367,7 +367,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe } } -Vector2 NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) +Vec2 NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); @@ -376,7 +376,7 @@ Vector2 NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReade Size containerSize = ccbReader->getAnimationManager()->getContainerSize(pParent); - Vector2 pt = getAbsolutePosition(Vector2(x,y), type, containerSize, pPropertyName); + Vec2 pt = getAbsolutePosition(Vec2(x,y), type, containerSize, pPropertyName); pNode->setPosition(pt); if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) @@ -392,19 +392,19 @@ Vector2 NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReade return pt; } -Vector2 NodeLoader::parsePropTypePoint(Node * pNode, Node * pParent, CCBReader * ccbReader) +Vec2 NodeLoader::parsePropTypePoint(Node * pNode, Node * pParent, CCBReader * ccbReader) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); - return Vector2(x, y); + return Vec2(x, y); } -Vector2 NodeLoader::parsePropTypePointLock(Node * pNode, Node * pParent, CCBReader * ccbReader) { +Vec2 NodeLoader::parsePropTypePointLock(Node * pNode, Node * pParent, CCBReader * ccbReader) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); - return Vector2(x, y); + return Vec2(x, y); } Size NodeLoader::parsePropTypeSize(Node * pNode, Node * pParent, CCBReader * ccbReader) { @@ -997,7 +997,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader -void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const char* pPropertyName, Vector2 pPosition, CCBReader * ccbReader) { +void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const char* pPropertyName, Vec2 pPosition, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) { pNode->setPosition(pPosition); } else { @@ -1005,7 +1005,7 @@ void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const ch } } -void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* pPropertyName, Vector2 pPoint, CCBReader * ccbReader) { +void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* pPropertyName, Vec2 pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) { pNode->setAnchorPoint(pPoint); } else { @@ -1013,7 +1013,7 @@ void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* } } -void NodeLoader::onHandlePropTypePointLock(Node * pNode, Node * pParent, const char* pPropertyName, Vector2 pPointLock, CCBReader * ccbReader) { +void NodeLoader::onHandlePropTypePointLock(Node * pNode, Node * pParent, const char* pPropertyName, Vec2 pPointLock, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.h b/cocos/editor-support/cocosbuilder/CCNodeLoader.h index 381a944257..9c31637439 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.h +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.h @@ -78,9 +78,9 @@ class NodeLoader : public cocos2d::Ref { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Node); - virtual cocos2d::Vector2 parsePropTypePosition(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); - virtual cocos2d::Vector2 parsePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); - virtual cocos2d::Vector2 parsePropTypePointLock(cocos2d::Node * pNode,cocos2d:: Node * pParent, CCBReader * ccbReader); + virtual cocos2d::Vec2 parsePropTypePosition(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); + virtual cocos2d::Vec2 parsePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); + virtual cocos2d::Vec2 parsePropTypePointLock(cocos2d::Node * pNode,cocos2d:: Node * pParent, CCBReader * ccbReader); virtual cocos2d::Size parsePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual float * parsePropTypeScaleLock(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual float parsePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); @@ -108,9 +108,9 @@ class NodeLoader : public cocos2d::Ref { virtual float * parsePropTypeFloatXY(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); - virtual void onHandlePropTypePosition(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char* pPropertyName, cocos2d::Vector2 pPosition, CCBReader * ccbReader); - virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Vector2 pPoint, CCBReader * ccbReader); - virtual void onHandlePropTypePointLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Vector2 pPointLock, CCBReader * ccbReader); + virtual void onHandlePropTypePosition(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char* pPropertyName, cocos2d::Vec2 pPosition, CCBReader * ccbReader); + virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader); + virtual void onHandlePropTypePointLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Vec2 pPointLock, CCBReader * ccbReader); virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); virtual void onHandlePropTypeScaleLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float * pScaleLock, CCBReader * ccbReader); virtual void onHandlePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float pFloat, CCBReader * ccbReader); diff --git a/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.cpp b/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.cpp index d2e94c7103..490703fcdb 100644 --- a/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.cpp @@ -35,7 +35,7 @@ void ParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node } } -void ParticleSystemQuadLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vector2 pPoint, CCBReader * ccbReader) { +void ParticleSystemQuadLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) { ((ParticleSystemQuad *)pNode)->setPosVar(pPoint); } else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) { diff --git a/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h b/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h index a3ce7c1265..e509a40f5c 100644 --- a/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h +++ b/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h @@ -39,7 +39,7 @@ protected: * @js NA * @lua NA */ - virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vector2 pPoint, CCBReader * ccbReader); + virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader); /** * @js NA * @lua NA diff --git a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h index 39ac673b01..33e13bba18 100644 --- a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h +++ b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h @@ -31,7 +31,7 @@ protected: virtual cocos2d::extension::Scale9Sprite * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) { cocos2d::extension::Scale9Sprite* pNode = cocos2d::extension::Scale9Sprite::create(); - pNode->setAnchorPoint(cocos2d::Vector2::ZERO); + pNode->setAnchorPoint(cocos2d::Vec2::ZERO); return pNode; }; diff --git a/cocos/editor-support/cocostudio/CCActionFrame.cpp b/cocos/editor-support/cocostudio/CCActionFrame.cpp index 327ca65ddd..61c6a72ad1 100644 --- a/cocos/editor-support/cocostudio/CCActionFrame.cpp +++ b/cocos/editor-support/cocostudio/CCActionFrame.cpp @@ -221,7 +221,7 @@ ActionInterval* ActionFrame::getEasingAction(ActionInterval* action) ////////////////////////////////////////////////////////////////////////// ActionMoveFrame::ActionMoveFrame() - : _position(Vector2(0.0f,0.0f)) + : _position(Vec2(0.0f,0.0f)) { _frameType = (int)kKeyframeMove; } @@ -229,11 +229,11 @@ ActionMoveFrame::~ActionMoveFrame() { } -void ActionMoveFrame::setPosition(Vector2 pos) +void ActionMoveFrame::setPosition(Vec2 pos) { _position = pos; } -Vector2 ActionMoveFrame::getPosition() +Vec2 ActionMoveFrame::getPosition() { return _position; } diff --git a/cocos/editor-support/cocostudio/CCActionFrame.h b/cocos/editor-support/cocostudio/CCActionFrame.h index f5ef0ba2e4..367aeb59ba 100644 --- a/cocos/editor-support/cocostudio/CCActionFrame.h +++ b/cocos/editor-support/cocostudio/CCActionFrame.h @@ -229,14 +229,14 @@ public: * * @param the move action position. */ - void setPosition(cocos2d::Vector2 pos); + void setPosition(cocos2d::Vec2 pos); /** * Gets the move action position. * * @return the move action position. */ - cocos2d::Vector2 getPosition(); + cocos2d::Vec2 getPosition(); /** * Gets the ActionInterval of ActionFrame. @@ -247,7 +247,7 @@ public: */ virtual cocos2d::ActionInterval* getAction(float duration); protected: - cocos2d::Vector2 _position; + cocos2d::Vec2 _position; }; /** diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index 69e81f8b69..f610c0e15f 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -99,7 +99,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) actionFrame->setFrameIndex(frameInex); actionFrame->setEasingType(frameTweenType); actionFrame->setEasingParameter(frameTweenParameter); - actionFrame->setPosition(Vector2(positionX, positionY)); + actionFrame->setPosition(Vec2(positionX, positionY)); auto cActionArray = _frameArray.at((int)kKeyframeMove); cActionArray->pushBack(actionFrame); actionFrame->release(); diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 43707dd634..6177661b38 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -316,7 +316,7 @@ const cocos2d::Map& Armature::getBoneDic() const return _boneDic; } -const Matrix& Armature::getNodeToParentTransform() const +const Mat4& Armature::getNodeToParentTransform() const { if (_transformDirty) _armatureTransformDirty = true; @@ -329,25 +329,25 @@ void Armature::updateOffsetPoint() // Set contentsize and Calculate anchor point. Rect rect = getBoundingBox(); setContentSize(rect.size); - _offsetPoint = Vector2(-rect.origin.x, -rect.origin.y); + _offsetPoint = Vec2(-rect.origin.x, -rect.origin.y); if (rect.size.width != 0 && rect.size.height != 0) { - setAnchorPoint(Vector2(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height)); + setAnchorPoint(Vec2(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height)); } } -void Armature::setAnchorPoint(const Vector2& point) +void Armature::setAnchorPoint(const Vec2& point) { if( ! point.equals(_anchorPoint)) { _anchorPoint = point; - _anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y); - _realAnchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y); + _anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y); + _realAnchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y); _transformDirty = _inverseDirty = true; } } -const Vector2& Armature::getAnchorPointInPoints() const +const Vec2& Armature::getAnchorPointInPoints() const { return _realAnchorPointInPoints; } @@ -378,7 +378,7 @@ void Armature::update(float dt) _armatureTransformDirty = false; } -void Armature::draw(cocos2d::Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if (_parentBone == nullptr && _batchNode == nullptr) { @@ -445,7 +445,7 @@ void Armature::onExit() } -void Armature::visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -459,7 +459,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -573,13 +573,13 @@ void CCArmature::drawContour() for (auto& object : bodyList) { ColliderBody *body = static_cast(object); - const std::vector &vertexList = body->getCalculatedVertexList(); + const std::vector &vertexList = body->getCalculatedVertexList(); unsigned long length = vertexList.size(); - Vector2 *points = new Vector2[length]; + Vec2 *points = new Vec2[length]; for (unsigned long i = 0; ipopMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void BatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if (_children.empty()) { diff --git a/cocos/editor-support/cocostudio/CCBatchNode.h b/cocos/editor-support/cocostudio/CCBatchNode.h index b32aa2a130..8288506201 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.h +++ b/cocos/editor-support/cocostudio/CCBatchNode.h @@ -56,8 +56,8 @@ public: virtual void addChild(cocos2d::Node *pChild, int zOrder) override; virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override; virtual void removeChild(cocos2d::Node* child, bool cleanup) override; - virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Matrix &parentTransform, bool parentTransformUpdated) override; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Matrix &transform, bool transformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; protected: void generateGroupCommand(); diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index 530cc47089..5c0daf2e79 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -72,7 +72,7 @@ Bone::Bone() _displayManager = nullptr; _ignoreMovementBoneData = false; // _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0); - _worldTransform = Matrix::IDENTITY; + _worldTransform = Mat4::IDENTITY; _boneTransformDirty = true; _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; _blendDirty = false; @@ -380,12 +380,12 @@ void Bone::setLocalZOrder(int zOrder) Node::setLocalZOrder(zOrder); } -Matrix Bone::getNodeToArmatureTransform() const +Mat4 Bone::getNodeToArmatureTransform() const { return _worldTransform; } -Matrix Bone::getNodeToWorldTransform() const +Mat4 Bone::getNodeToWorldTransform() const { return TransformConcat(_worldTransform, _armature->getNodeToWorldTransform()); } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 8d20281f39..336c3dedb7 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -154,8 +154,8 @@ public: virtual void setTransformDirty(bool dirty) { _boneTransformDirty = dirty; } virtual bool isTransformDirty() { return _boneTransformDirty; } - virtual cocos2d::Matrix getNodeToArmatureTransform() const; - virtual cocos2d::Matrix getNodeToWorldTransform() const override; + virtual cocos2d::Mat4 getNodeToArmatureTransform() const; + virtual cocos2d::Mat4 getNodeToWorldTransform() const override; cocos2d::Node *getDisplayRenderNode(); DisplayType getDisplayRenderNodeType(); @@ -248,7 +248,7 @@ protected: bool _boneTransformDirty; //! Whether or not transform dirty //! self Transform, use this to change display's state - cocos2d::Matrix _worldTransform; + cocos2d::Mat4 _worldTransform; BaseData *_worldInfo; diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.cpp b/cocos/editor-support/cocostudio/CCColliderDetector.cpp index bcbc82b50d..73e5ad4b18 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.cpp +++ b/cocos/editor-support/cocostudio/CCColliderDetector.cpp @@ -190,12 +190,12 @@ void ColliderDetector::addContourData(ContourData *contourData) #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - std::vector &calculatedVertexList = colliderBody->_calculatedVertexList; + std::vector &calculatedVertexList = colliderBody->_calculatedVertexList; unsigned long num = contourData->vertexList.size(); for (unsigned long i = 0; i < num; i++) { - calculatedVertexList.push_back(Vector2()); + calculatedVertexList.push_back(Vec2()); } #endif } @@ -332,9 +332,9 @@ ColliderFilter *ColliderDetector::getColliderFilter() #endif -Vector2 helpPoint; +Vec2 helpPoint; -void ColliderDetector::updateTransform(Matrix &t) +void ColliderDetector::updateTransform(Mat4 &t) { if (!_active) { @@ -361,10 +361,10 @@ void ColliderDetector::updateTransform(Matrix &t) #endif unsigned long num = contourData->vertexList.size(); - std::vector &vs = contourData->vertexList; + std::vector &vs = contourData->vertexList; #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - std::vector &cvs = colliderBody->_calculatedVertexList; + std::vector &cvs = colliderBody->_calculatedVertexList; #endif for (unsigned long i = 0; i < num; i++) diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.h b/cocos/editor-support/cocostudio/CCColliderDetector.h index 496f905681..91ed2dc26a 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.h +++ b/cocos/editor-support/cocostudio/CCColliderDetector.h @@ -105,7 +105,7 @@ public: virtual void setShape(cpShape *shape) { _shape = shape; } virtual cpShape *getShape() const { return _shape; } #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - virtual const std::vector &getCalculatedVertexList() const { return _calculatedVertexList; } + virtual const std::vector &getCalculatedVertexList() const { return _calculatedVertexList; } #endif private: @@ -117,7 +117,7 @@ private: cpShape *_shape; ColliderFilter *_filter; #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - std::vector _calculatedVertexList; + std::vector _calculatedVertexList; #endif ContourData *_contourData; @@ -155,7 +155,7 @@ public: void removeContourData(ContourData *contourData); void removeAll(); - void updateTransform(cocos2d::Matrix &t); + void updateTransform(cocos2d::Mat4 &t); void setActive(bool active); bool getActive(); diff --git a/cocos/editor-support/cocostudio/CCComRender.cpp b/cocos/editor-support/cocostudio/CCComRender.cpp index 4a26128e39..2037518eee 100644 --- a/cocos/editor-support/cocostudio/CCComRender.cpp +++ b/cocos/editor-support/cocostudio/CCComRender.cpp @@ -137,7 +137,7 @@ bool ComRender::serialize(void* r) else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != std::string::npos) { _render = ParticleSystemQuad::create(filePath.c_str()); - _render->setPosition(Vector2(0.0f, 0.0f)); + _render->setPosition(Vec2(0.0f, 0.0f)); _render->retain(); } else if(strcmp(className, "CCArmature") == 0) diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index de6add4016..a2ab0aecf7 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -1166,7 +1166,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D while (vertexDataXML) { - Vector2 vertex; + Vec2 vertex; vertexDataXML->QueryFloatAttribute(A_X, &vertex.x); vertexDataXML->QueryFloatAttribute(A_Y, &vertex.y); @@ -1631,7 +1631,7 @@ ContourData *DataReaderHelper::decodeContour(const rapidjson::Value& json) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, VERTEX_POINT, i); - Vector2 vertex; + Vec2 vertex; vertex.x = DICTOOL->getFloatValue_json(dic, A_X); vertex.y = DICTOOL->getFloatValue_json(dic, A_Y); diff --git a/cocos/editor-support/cocostudio/CCDatas.cpp b/cocos/editor-support/cocostudio/CCDatas.cpp index 5e97f43519..deeca68471 100644 --- a/cocos/editor-support/cocostudio/CCDatas.cpp +++ b/cocos/editor-support/cocostudio/CCDatas.cpp @@ -389,7 +389,7 @@ bool ContourData::init() return true; } -void ContourData::addVertex(Vector2 &vertex) +void ContourData::addVertex(Vec2 &vertex) { vertexList.push_back(vertex); } diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index bef2714087..84eb57679d 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -502,9 +502,9 @@ public: ~ContourData(void); virtual bool init(); - virtual void addVertex(cocos2d::Vector2 &vertex); + virtual void addVertex(cocos2d::Vec2 &vertex); public: - std::vector vertexList; //! Save contour vertex info, vertex saved in a Vector2 + std::vector vertexList; //! Save contour vertex info, vertex saved in a Vec2 }; diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index 7feec445e0..d995d55c1b 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -93,7 +93,7 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty) break; default: { - Matrix transform = bone->getNodeToArmatureTransform(); + Mat4 transform = bone->getNodeToArmatureTransform(); display->setAdditionalTransform(&transform); } break; @@ -113,12 +113,12 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty) CC_BREAK_IF(!detector->getBody()); #endif - Matrix displayTransform = display->getNodeToParentTransform(); - Vector2 anchorPoint = display->getAnchorPointInPoints(); + Mat4 displayTransform = display->getNodeToParentTransform(); + Vec2 anchorPoint = display->getAnchorPointInPoints(); anchorPoint = PointApplyTransform(anchorPoint, displayTransform); displayTransform.m[12] = anchorPoint.x; displayTransform.m[13] = anchorPoint.y; - Matrix t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform); + Mat4 t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform); detector->updateTransform(t); } while (0); @@ -202,7 +202,7 @@ void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDispla if(textureData) { //! Init display anchorPoint, every Texture have a anchor point - skin->setAnchorPoint(Vector2( textureData->pivotX, textureData->pivotY)); + skin->setAnchorPoint(Vec2( textureData->pivotX, textureData->pivotY)); } diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index dc23678a64..6b8a01c8e8 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -361,7 +361,7 @@ void DisplayManager::initDisplayList(BoneData *boneData) } -bool DisplayManager::containPoint(Vector2 &point) +bool DisplayManager::containPoint(Vec2 &point) { if(!_visible || _displayIndex < 0) { @@ -380,7 +380,7 @@ bool DisplayManager::containPoint(Vector2 &point) * */ - Vector2 outPoint = Vector2(0, 0); + Vec2 outPoint = Vec2(0, 0); Sprite *sprite = (Sprite *)_currentDecoDisplay->getDisplay(); sprite = (Sprite *)sprite->getChildByTag(0); @@ -398,7 +398,7 @@ bool DisplayManager::containPoint(Vector2 &point) bool DisplayManager::containPoint(float x, float y) { - Vector2 p = Vector2(x, y); + Vec2 p = Vec2(x, y); return containPoint(p); } @@ -431,15 +431,15 @@ Rect DisplayManager::getBoundingBox() const } -Vector2 DisplayManager::getAnchorPoint() const +Vec2 DisplayManager::getAnchorPoint() const { - CS_RETURN_IF(!_displayRenderNode) Vector2(0, 0); + CS_RETURN_IF(!_displayRenderNode) Vec2(0, 0); return _displayRenderNode->getAnchorPoint(); } -Vector2 DisplayManager::getAnchorPointInPoints() const +Vec2 DisplayManager::getAnchorPointInPoints() const { - CS_RETURN_IF(!_displayRenderNode) Vector2(0, 0); + CS_RETURN_IF(!_displayRenderNode) Vec2(0, 0); return _displayRenderNode->getAnchorPointInPoints(); } diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.h b/cocos/editor-support/cocostudio/CCDisplayManager.h index 4ae988699e..b4010c4eac 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.h +++ b/cocos/editor-support/cocostudio/CCDisplayManager.h @@ -119,13 +119,13 @@ public: cocos2d::Size getContentSize() const; cocos2d::Rect getBoundingBox() const; - cocos2d::Vector2 getAnchorPoint() const; - cocos2d::Vector2 getAnchorPointInPoints() const; + cocos2d::Vec2 getAnchorPoint() const; + cocos2d::Vec2 getAnchorPointInPoints() const; /** * Check if the position is inside the bone. */ - virtual bool containPoint(cocos2d::Vector2 &_point); + virtual bool containPoint(cocos2d::Vec2 &_point); /** * Check if the position is inside the bone. diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index dc30adc143..abb8396d19 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -238,7 +238,7 @@ void WidgetPropertiesReader::setAnchorPointForWidget(cocos2d::ui::Widget *widget } if (isAnchorPointXExists || isAnchorPointYExists) { - widget->setAnchorPoint(Vector2(anchorPointXInFile, anchorPointYInFile)); + widget->setAnchorPoint(Vec2(anchorPointXInFile, anchorPointYInFile)); } } @@ -396,7 +396,7 @@ void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(Widget*widg widget->setName(widgetName); float x = DICTOOL->getFloatValue_json(options, "x"); float y = DICTOOL->getFloatValue_json(options, "y"); - widget->setPosition(Vector2(x,y)); + widget->setPosition(Vec2(x,y)); bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); if (sx) { @@ -711,7 +711,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(Widget*widg float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Vector2(bgcv1, bgcv2)); + panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2)); int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); @@ -1135,9 +1135,9 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va { if (child->getPositionType() == ui::Widget::PositionType::PERCENT) { - child->setPositionPercent(Vector2(child->getPositionPercent().x + widget->getAnchorPoint().x, child->getPositionPercent().y + widget->getAnchorPoint().y)); + child->setPositionPercent(Vec2(child->getPositionPercent().x + widget->getAnchorPoint().x, child->getPositionPercent().y + widget->getAnchorPoint().y)); } - child->setPosition(Vector2(child->getPositionX() + widget->getAnchorPointInPoints().x, child->getPositionY() + widget->getAnchorPointInPoints().y)); + child->setPosition(Vec2(child->getPositionX() + widget->getAnchorPointInPoints().x, child->getPositionY() + widget->getAnchorPointInPoints().y)); } widget->addChild(child); } @@ -1158,8 +1158,8 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, "sizeType")); widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, "positionType")); - widget->setSizePercent(Vector2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); - widget->setPositionPercent(Vector2(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); + widget->setSizePercent(Vec2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); + widget->setPositionPercent(Vec2(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); float w = DICTOOL->getFloatValue_json(options, "width"); float h = DICTOOL->getFloatValue_json(options, "height"); @@ -1173,7 +1173,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg widget->setName(widgetName); float x = DICTOOL->getFloatValue_json(options, "x"); float y = DICTOOL->getFloatValue_json(options, "y"); - widget->setPosition(Vector2(x,y)); + widget->setPosition(Vec2(x,y)); bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); if (sx) { @@ -1675,7 +1675,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widg float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Vector2(bgcv1, bgcv2)); + panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2)); int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index e5f89be98c..52adc3e656 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -220,7 +220,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d: { float x = DICTOOL->getFloatValue_json(root, "x"); float y = DICTOOL->getFloatValue_json(root, "y"); - node->setPosition(Vector2(x, y)); + node->setPosition(Vec2(x, y)); const bool bVisible = (DICTOOL->getIntValue_json(root, "visible", 1) != 0); node->setVisible(bVisible); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index ea1f678e1d..e1ff9f2521 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -86,7 +86,7 @@ Skin::Skin() , _armature(nullptr) , _displayName("") { - _skinTransform = Matrix::IDENTITY; + _skinTransform = Mat4::IDENTITY; } bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName) @@ -128,7 +128,7 @@ void Skin::setSkinData(const BaseData &var) setScaleY(_skinData.scaleY); setRotationSkewX(CC_RADIANS_TO_DEGREES(_skinData.skewX)); setRotationSkewY(CC_RADIANS_TO_DEGREES(-_skinData.skewY)); - setPosition(Vector2(_skinData.x, _skinData.y)); + setPosition(Vec2(_skinData.x, _skinData.y)); _skinTransform = getNodeToParentTransform(); updateArmatureTransform(); @@ -153,7 +153,7 @@ void Skin::updateTransform() // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !_visible) { - _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vector3(0, 0, 0); + _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0, 0, 0); } else { @@ -201,15 +201,15 @@ void Skin::updateTransform() } } -Matrix Skin::getNodeToWorldTransform() const +Mat4 Skin::getNodeToWorldTransform() const { return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(), _transform); } -Matrix Skin::getNodeToWorldTransformAR() const +Mat4 Skin::getNodeToWorldTransformAR() const { - Matrix displayTransform = _transform; - Vector2 anchorPoint = _anchorPointInPoints; + Mat4 displayTransform = _transform; + Vec2 anchorPoint = _anchorPointInPoints; anchorPoint = PointApplyTransform(anchorPoint, displayTransform); @@ -219,9 +219,9 @@ Matrix Skin::getNodeToWorldTransformAR() const return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(),displayTransform); } -void Skin::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Skin::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { - Matrix mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + Mat4 mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); //TODO implement z order _quadCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, mv); diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index d27ff5fb2c..9bd22850ad 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -51,10 +51,10 @@ public: void updateArmatureTransform(); void updateTransform() override; - cocos2d::Matrix getNodeToWorldTransform() const override; - cocos2d::Matrix getNodeToWorldTransformAR() const; + cocos2d::Mat4 getNodeToWorldTransform() const override; + cocos2d::Mat4 getNodeToWorldTransformAR() const; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Matrix &transform, bool transformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; /** * @js NA @@ -75,7 +75,7 @@ protected: BaseData _skinData; Bone *_bone; Armature *_armature; - cocos2d::Matrix _skinTransform; + cocos2d::Mat4 _skinTransform; std::string _displayName; cocos2d::QuadCommand _quadCommand; // quad command }; diff --git a/cocos/editor-support/cocostudio/CCTransformHelp.cpp b/cocos/editor-support/cocostudio/CCTransformHelp.cpp index 453331521f..b4c2cb8fe3 100644 --- a/cocos/editor-support/cocostudio/CCTransformHelp.cpp +++ b/cocos/editor-support/cocostudio/CCTransformHelp.cpp @@ -32,8 +32,8 @@ namespace cocostudio { AffineTransform TransformHelp::helpMatrix1; AffineTransform TransformHelp::helpMatrix2; -Vector2 TransformHelp::helpPoint1; -Vector2 TransformHelp::helpPoint2; +Vec2 TransformHelp::helpPoint1; +Vec2 TransformHelp::helpPoint2; BaseData helpParentNode; @@ -118,9 +118,9 @@ void TransformHelp::nodeToMatrix(const BaseData &node, AffineTransform &matrix) matrix.ty = node.y; } -void TransformHelp::nodeToMatrix(const BaseData &node, Matrix &matrix) +void TransformHelp::nodeToMatrix(const BaseData &node, Mat4 &matrix) { - matrix = Matrix::IDENTITY; + matrix = Mat4::IDENTITY; if (node.skewX == -node.skewY) { @@ -171,7 +171,7 @@ void TransformHelp::matrixToNode(const AffineTransform &matrix, BaseData &node) node.y = matrix.ty; } -void TransformHelp::matrixToNode(const Matrix &matrix, BaseData &node) +void TransformHelp::matrixToNode(const Mat4 &matrix, BaseData &node) { /* * In as3 language, there is a function called "deltaTransformPoint", it calculate a point used give Transform diff --git a/cocos/editor-support/cocostudio/CCTransformHelp.h b/cocos/editor-support/cocostudio/CCTransformHelp.h index 5e45890ba3..ec93a2ac55 100644 --- a/cocos/editor-support/cocostudio/CCTransformHelp.h +++ b/cocos/editor-support/cocostudio/CCTransformHelp.h @@ -47,9 +47,9 @@ public: static void transformToParentWithoutScale(BaseData &node, const BaseData &parentNode); static void nodeToMatrix(const BaseData &_node, cocos2d::AffineTransform &_matrix); - static void nodeToMatrix(const BaseData &node, cocos2d::Matrix &matrix); + static void nodeToMatrix(const BaseData &node, cocos2d::Mat4 &matrix); static void matrixToNode(const cocos2d::AffineTransform &_matrix, BaseData &_node); - static void matrixToNode(const cocos2d::Matrix &_matrix, BaseData &_node); + static void matrixToNode(const cocos2d::Mat4 &_matrix, BaseData &_node); static void nodeConcat(BaseData &target, BaseData &source); static void nodeSub(BaseData &target, BaseData &source); @@ -57,8 +57,8 @@ public: static cocos2d::AffineTransform helpMatrix1; static cocos2d::AffineTransform helpMatrix2; - static cocos2d::Vector2 helpPoint1; - static cocos2d::Vector2 helpPoint2; + static cocos2d::Vec2 helpPoint1; + static cocos2d::Vec2 helpPoint2; }; } diff --git a/cocos/editor-support/cocostudio/CCUtilMath.cpp b/cocos/editor-support/cocostudio/CCUtilMath.cpp index 37c97fe8db..15c354b8b6 100644 --- a/cocos/editor-support/cocostudio/CCUtilMath.cpp +++ b/cocos/editor-support/cocostudio/CCUtilMath.cpp @@ -29,7 +29,7 @@ using namespace cocos2d; namespace cocostudio { -bool isSpriteContainPoint(Sprite *sprite, Vector2 point, Vector2 &outPoint) +bool isSpriteContainPoint(Sprite *sprite, Vec2 point, Vec2 &outPoint) { outPoint = sprite->convertToNodeSpace(point); @@ -39,17 +39,17 @@ bool isSpriteContainPoint(Sprite *sprite, Vector2 point, Vector2 &outPoint) return r.containsPoint(outPoint); } -bool isSpriteContainPoint(Sprite *sprite, Vector2 point) +bool isSpriteContainPoint(Sprite *sprite, Vec2 point) { - Vector2 p = Vector2(0, 0); + Vec2 p = Vec2(0, 0); return isSpriteContainPoint(sprite, point, p); } -Vector2 bezierTo(float t, Vector2 &point1, Vector2 &point2, Vector2 &point3) +Vec2 bezierTo(float t, Vec2 &point1, Vec2 &point2, Vec2 &point3) { - Vector2 p; + Vec2 p; p.x = pow((1 - t), 2) * point1.x + 2 * t * (1 - t) * point2.x + pow(t, 2) * point3.x; p.y = pow((1 - t), 2) * point1.y + 2 * t * (1 - t) * point2.y + pow(t, 2) * point3.y; @@ -57,9 +57,9 @@ Vector2 bezierTo(float t, Vector2 &point1, Vector2 &point2, Vector2 &point3) return p; } -Vector2 bezierTo(float t, Vector2 &point1, Vector2 &point2, Vector2 &point3, Vector2 &point4) +Vec2 bezierTo(float t, Vec2 &point1, Vec2 &point2, Vec2 &point3, Vec2 &point4) { - Vector2 p; + Vec2 p; p.x = point1.x * pow((1 - t), 3) + 3 * t * point2.x * pow((1 - t), 2) + 3 * point3.x * pow(t, 2) * (1 - t) + point4.x * pow(t, 3); p.y = point1.y * pow((1 - t), 3) + 3 * t * point2.y * pow((1 - t), 2) + 3 * point3.y * pow(t, 2) * (1 - t) + point4.y * pow(t, 3); @@ -67,9 +67,9 @@ Vector2 bezierTo(float t, Vector2 &point1, Vector2 &point2, Vector2 &point3, Vec return p; } -Vector2 circleTo(float t, Vector2 ¢er, float radius, float fromRadian, float radianDif) +Vec2 circleTo(float t, Vec2 ¢er, float radius, float fromRadian, float radianDif) { - Vector2 p; + Vec2 p; p.x = center.x + radius * cos(fromRadian + radianDif * t); p.y = center.y + radius * sin(fromRadian + radianDif * t); diff --git a/cocos/editor-support/cocostudio/CCUtilMath.h b/cocos/editor-support/cocostudio/CCUtilMath.h index 3b1760f0b4..5a4827bf44 100644 --- a/cocos/editor-support/cocostudio/CCUtilMath.h +++ b/cocos/editor-support/cocostudio/CCUtilMath.h @@ -37,18 +37,18 @@ namespace cocostudio { //! hit test function -bool isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Vector2 point); -bool isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Vector2 point, cocos2d::Vector2 &outPoint); +bool isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Vec2 point); +bool isSpriteContainPoint(cocos2d::Sprite *sprite, 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) //! motion curve function -cocos2d::Vector2 bezierTo(float t, cocos2d::Vector2 &point1, cocos2d::Vector2 &point2, cocos2d::Vector2 &point3); -cocos2d::Vector2 bezierTo(float t, cocos2d::Vector2 &point1, cocos2d::Vector2 &point2, cocos2d::Vector2 &point3, cocos2d::Vector2 &point4); +cocos2d::Vec2 bezierTo(float t, cocos2d::Vec2 &point1, cocos2d::Vec2 &point2, cocos2d::Vec2 &point3); +cocos2d::Vec2 bezierTo(float t, cocos2d::Vec2 &point1, cocos2d::Vec2 &point2, cocos2d::Vec2 &point3, cocos2d::Vec2 &point4); -cocos2d::Vector2 circleTo(float t, cocos2d::Vector2 ¢er, float radius, float fromRadian, float radianDif); +cocos2d::Vec2 circleTo(float t, cocos2d::Vec2 ¢er, float radius, float fromRadian, float radianDif); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index 9c1d3b6ef2..926083f0b5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -72,7 +72,7 @@ namespace cocostudio float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Vector2(bgcv1, bgcv2)); + panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2)); int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index ae0b63de28..fb45ed7017 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -46,8 +46,8 @@ namespace cocostudio widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, "sizeType")); widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, "positionType")); - widget->setSizePercent(Vector2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); - widget->setPositionPercent(Vector2(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); + widget->setSizePercent(Vec2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); + widget->setPositionPercent(Vec2(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); /* adapt screen */ float w = 0, h = 0; @@ -80,7 +80,7 @@ namespace cocostudio widget->setName(widgetName); float x = DICTOOL->getFloatValue_json(options, "x"); float y = DICTOOL->getFloatValue_json(options, "y"); - widget->setPosition(Vector2(x,y)); + widget->setPosition(Vec2(x,y)); bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); if (sx) { @@ -213,7 +213,7 @@ namespace cocostudio } if (isAnchorPointXExists || isAnchorPointYExists) { - widget->setAnchorPoint(Vector2(anchorPointXInFile, anchorPointYInFile)); + widget->setAnchorPoint(Vec2(anchorPointXInFile, anchorPointYInFile)); } } } diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index f7c6bcf5d6..16d9c4b8c6 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -125,7 +125,7 @@ void Skeleton::update (float deltaTime) { spSkeleton_update(skeleton, deltaTime * timeScale); } -void Skeleton::draw(cocos2d::Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); @@ -133,7 +133,7 @@ void Skeleton::draw(cocos2d::Renderer *renderer, const Matrix &transform, bool t renderer->addCommand(&_customCommand); } -void Skeleton::onDraw(const Matrix &transform, bool transformUpdated) +void Skeleton::onDraw(const Mat4 &transform, bool transformUpdated) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -202,17 +202,17 @@ void Skeleton::onDraw(const Matrix &transform, bool transformUpdated) // Slots. DrawPrimitives::setDrawColor4B(0, 0, 255, 255); glLineWidth(1); - Vector2 points[4]; + Vec2 points[4]; V3F_C4B_T2F_Quad tmpQuad; for (int i = 0, n = skeleton->slotCount; i < n; i++) { spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; spRegionAttachment_updateQuad(attachment, slot, &tmpQuad); - points[0] = Vector2(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y); - points[1] = Vector2(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y); - points[2] = Vector2(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y); - points[3] = Vector2(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y); + points[0] = Vec2(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y); + points[1] = Vec2(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y); + points[2] = Vec2(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y); + points[3] = Vec2(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y); DrawPrimitives::drawPoly(points, 4, true); } } @@ -224,14 +224,14 @@ void Skeleton::onDraw(const Matrix &transform, bool transformUpdated) spBone *bone = skeleton->bones[i]; float x = bone->data->length * bone->m00 + bone->worldX; float y = bone->data->length * bone->m10 + bone->worldY; - DrawPrimitives::drawLine(Vector2(bone->worldX, bone->worldY), Vector2(x, y)); + DrawPrimitives::drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y)); } // Bone origins. DrawPrimitives::setPointSize(4); DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue. for (int i = 0, n = skeleton->boneCount; i < n; i++) { spBone *bone = skeleton->bones[i]; - DrawPrimitives::drawPoint(Vector2(bone->worldX, bone->worldY)); + DrawPrimitives::drawPoint(Vec2(bone->worldX, bone->worldY)); if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255); } } @@ -271,7 +271,7 @@ Rect Skeleton::getBoundingBox () const { maxX = max(maxX, vertices[VERTEX_X3] * scaleX); maxY = max(maxY, vertices[VERTEX_Y3] * scaleY); } - Vector2 position = getPosition(); + Vec2 position = getPosition(); return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY); } diff --git a/cocos/editor-support/spine/CCSkeleton.h b/cocos/editor-support/spine/CCSkeleton.h index 2ff978ffda..3b44e667df 100644 --- a/cocos/editor-support/spine/CCSkeleton.h +++ b/cocos/editor-support/spine/CCSkeleton.h @@ -67,8 +67,8 @@ public: virtual ~Skeleton (); virtual void update (float deltaTime) override; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Matrix &transform, bool transformUpdated) override; - void onDraw(const cocos2d::Matrix &transform, bool transformUpdated); + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; + void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated); void onEnter() override; void onExit() override; virtual cocos2d::Rect getBoundingBox () const override; diff --git a/cocos/math/CCAffineTransform.cpp b/cocos/math/CCAffineTransform.cpp index f5df4927b1..f47e09e67e 100644 --- a/cocos/math/CCAffineTransform.cpp +++ b/cocos/math/CCAffineTransform.cpp @@ -40,19 +40,19 @@ AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, floa return t; } -Vector2 __CCPointApplyAffineTransform(const Vector2& point, const AffineTransform& t) +Vec2 __CCPointApplyAffineTransform(const Vec2& point, const AffineTransform& t) { - Vector2 p; + Vec2 p; p.x = (float)((double)t.a * point.x + (double)t.c * point.y + t.tx); p.y = (float)((double)t.b * point.x + (double)t.d * point.y + t.ty); return p; } -Vector2 PointApplyTransform(const Vector2& point, const Matrix& transform) +Vec2 PointApplyTransform(const Vec2& point, const Mat4& transform) { - Vector3 vec(point.x, point.y, 0); + Vec3 vec(point.x, point.y, 0); transform.transformPoint(&vec); - return Vector2(vec.x, vec.y); + return Vec2(vec.x, vec.y); } @@ -80,10 +80,10 @@ Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineT float right = rect.getMaxX(); float bottom = rect.getMaxY(); - Vector2 topLeft = PointApplyAffineTransform(Vector2(left, top), anAffineTransform); - Vector2 topRight = PointApplyAffineTransform(Vector2(right, top), anAffineTransform); - Vector2 bottomLeft = PointApplyAffineTransform(Vector2(left, bottom), anAffineTransform); - Vector2 bottomRight = PointApplyAffineTransform(Vector2(right, bottom), anAffineTransform); + Vec2 topLeft = PointApplyAffineTransform(Vec2(left, top), anAffineTransform); + Vec2 topRight = PointApplyAffineTransform(Vec2(right, top), anAffineTransform); + Vec2 bottomLeft = PointApplyAffineTransform(Vec2(left, bottom), anAffineTransform); + Vec2 bottomRight = PointApplyAffineTransform(Vec2(right, bottom), anAffineTransform); float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x)); float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x)); @@ -93,17 +93,17 @@ Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineT return Rect(minX, minY, (maxX - minX), (maxY - minY)); } -Rect RectApplyTransform(const Rect& rect, const Matrix& transform) +Rect RectApplyTransform(const Rect& rect, const Mat4& transform) { float top = rect.getMinY(); float left = rect.getMinX(); float right = rect.getMaxX(); float bottom = rect.getMaxY(); - Vector3 topLeft(left, top, 0); - Vector3 topRight(right, top, 0); - Vector3 bottomLeft(left, bottom, 0); - Vector3 bottomRight(right, bottom, 0); + Vec3 topLeft(left, top, 0); + Vec3 topRight(right, top, 0); + Vec3 bottomLeft(left, bottom, 0); + Vec3 bottomRight(right, bottom, 0); transform.transformPoint(&topLeft); transform.transformPoint(&topRight); transform.transformPoint(&bottomLeft); @@ -151,7 +151,7 @@ AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTra t1.tx * t2.b + t1.ty * t2.d + t2.ty); //ty } -Matrix TransformConcat(const Matrix& t1, const Matrix& t2) +Mat4 TransformConcat(const Mat4& t1, const Mat4& t2) { return t1 * t2; } diff --git a/cocos/math/CCAffineTransform.h b/cocos/math/CCAffineTransform.h index e2f16ef92c..e5a158a946 100644 --- a/cocos/math/CCAffineTransform.h +++ b/cocos/math/CCAffineTransform.h @@ -43,7 +43,7 @@ struct AffineTransform { CC_DLL AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); #define AffineTransformMake __CCAffineTransformMake -CC_DLL Vector2 __CCPointApplyAffineTransform(const Vector2& point, const AffineTransform& t); +CC_DLL Vec2 __CCPointApplyAffineTransform(const Vec2& point, const AffineTransform& t); #define PointApplyAffineTransform __CCPointApplyAffineTransform CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t); @@ -52,8 +52,8 @@ CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform CC_DLL AffineTransform AffineTransformMakeIdentity(); CC_DLL Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform); -CC_DLL Rect RectApplyTransform(const Rect& rect, const Matrix& transform); -CC_DLL Vector2 PointApplyTransform(const Vector2& point, const Matrix& transform); +CC_DLL Rect RectApplyTransform(const Rect& rect, const Mat4& transform); +CC_DLL Vec2 PointApplyTransform(const Vec2& point, const Mat4& transform); CC_DLL AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty); CC_DLL AffineTransform AffineTransformRotate(const AffineTransform& aTransform, float anAngle); @@ -62,7 +62,7 @@ CC_DLL AffineTransform AffineTransformConcat(const AffineTransform& t1, const Af CC_DLL bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2); CC_DLL AffineTransform AffineTransformInvert(const AffineTransform& t); -Matrix TransformConcat(const Matrix& t1, const Matrix& t2); +Mat4 TransformConcat(const Mat4& t1, const Mat4& t2); extern CC_DLL const AffineTransform AffineTransformIdentity; diff --git a/cocos/math/CCGeometry.cpp b/cocos/math/CCGeometry.cpp index 6e2c074a6d..b801f8628d 100644 --- a/cocos/math/CCGeometry.cpp +++ b/cocos/math/CCGeometry.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include #include "base/ccMacros.h" -// implementation of Vector2 +// implementation of Vec2 NS_CC_BEGIN // implementation of Size @@ -45,7 +45,7 @@ Size::Size(const Size& other) : width(other.width), height(other.height) { } -Size::Size(const Vector2& point) : width(point.x), height(point.y) +Size::Size(const Vec2& point) : width(point.x), height(point.y) { } @@ -55,7 +55,7 @@ Size& Size::operator= (const Size& other) return *this; } -Size& Size::operator= (const Vector2& point) +Size& Size::operator= (const Vec2& point) { setSize(point.x, point.y); return *this; @@ -167,7 +167,7 @@ float Rect::getMinY() const return origin.y; } -bool Rect::containsPoint(const Vector2& point) const +bool Rect::containsPoint(const Vec2& point) const { bool bRet = false; diff --git a/cocos/math/CCGeometry.h b/cocos/math/CCGeometry.h index 47be81c1ee..056f6939b9 100644 --- a/cocos/math/CCGeometry.h +++ b/cocos/math/CCGeometry.h @@ -46,9 +46,9 @@ public: float width; float height; public: - operator Vector2() const + operator Vec2() const { - return Vector2(width, height); + return Vec2(width, height); } public: @@ -69,7 +69,7 @@ public: * @js NA * @lua NA */ - explicit Size(const Vector2& point); + explicit Size(const Vec2& point); /** * @js NA * @lua NA @@ -79,7 +79,7 @@ public: * @js NA * @lua NA */ - Size& operator= (const Vector2& point); + Size& operator= (const Vec2& point); /** * @js NA * @lua NA @@ -116,7 +116,7 @@ public: class CC_DLL Rect { public: - Vector2 origin; + Vec2 origin; Size size; public: @@ -174,7 +174,7 @@ public: /** * @js NA */ - bool containsPoint(const Vector2& point) const; + bool containsPoint(const Vec2& point) const; /** * @js NA */ diff --git a/cocos/math/MathUtil.h b/cocos/math/MathUtil.h index 73be6becda..7618650833 100644 --- a/cocos/math/MathUtil.h +++ b/cocos/math/MathUtil.h @@ -32,8 +32,8 @@ NS_CC_MATH_BEGIN */ class MathUtil { - friend class Matrix; - friend class Vector3; + friend class Mat4; + friend class Vec3; public: @@ -82,11 +82,11 @@ private: inline static void transposeMatrix(const float* m, float* dst); - inline static void transformVector4(const float* m, float x, float y, float z, float w, float* dst); + inline static void transformVec4(const float* m, float x, float y, float z, float w, float* dst); - inline static void transformVector4(const float* m, const float* v, float* dst); + inline static void transformVec4(const float* m, const float* v, float* dst); - inline static void crossVector3(const float* v1, const float* v2, float* dst); + inline static void crossVec3(const float* v1, const float* v2, float* dst); MathUtil(); }; diff --git a/cocos/math/MathUtil.inl b/cocos/math/MathUtil.inl index f4be0f98d2..ba19d635e7 100644 --- a/cocos/math/MathUtil.inl +++ b/cocos/math/MathUtil.inl @@ -159,14 +159,14 @@ inline void MathUtil::transposeMatrix(const float* m, float* dst) memcpy(dst, t, MATRIX_SIZE); } -inline void MathUtil::transformVector4(const float* m, float x, float y, float z, float w, float* dst) +inline void MathUtil::transformVec4(const float* m, float x, float y, float z, float w, float* dst) { dst[0] = x * m[0] + y * m[4] + z * m[8] + w * m[12]; dst[1] = x * m[1] + y * m[5] + z * m[9] + w * m[13]; dst[2] = x * m[2] + y * m[6] + z * m[10] + w * m[14]; } -inline void MathUtil::transformVector4(const float* m, const float* v, float* dst) +inline void MathUtil::transformVec4(const float* m, const float* v, float* dst) { // Handle case where v == dst. float x = v[0] * m[0] + v[1] * m[4] + v[2] * m[8] + v[3] * m[12]; @@ -180,7 +180,7 @@ inline void MathUtil::transformVector4(const float* m, const float* v, float* ds dst[3] = w; } -inline void MathUtil::crossVector3(const float* v1, const float* v2, float* dst) +inline void MathUtil::crossVec3(const float* v1, const float* v2, float* dst) { float x = (v1[1] * v2[2]) - (v1[2] * v2[1]); float y = (v1[2] * v2[0]) - (v1[0] * v2[2]); diff --git a/cocos/math/MathUtilNeon.inl b/cocos/math/MathUtilNeon.inl index 8dfa81804a..f9c73498fd 100644 --- a/cocos/math/MathUtilNeon.inl +++ b/cocos/math/MathUtilNeon.inl @@ -177,7 +177,7 @@ inline void MathUtil::transposeMatrix(const float* m, float* dst) ); } -inline void MathUtil::transformVector4(const float* m, float x, float y, float z, float w, float* dst) +inline void MathUtil::transformVec4(const float* m, float x, float y, float z, float w, float* dst) { asm volatile( "vld1.32 {d0[0]}, [%1] \n\t" // V[x] @@ -200,7 +200,7 @@ inline void MathUtil::transformVector4(const float* m, float x, float y, float z ); } -inline void MathUtil::transformVector4(const float* m, const float* v, float* dst) +inline void MathUtil::transformVec4(const float* m, const float* v, float* dst) { asm volatile ( @@ -220,7 +220,7 @@ inline void MathUtil::transformVector4(const float* m, const float* v, float* ds ); } -inline void MathUtil::crossVector3(const float* v1, const float* v2, float* dst) +inline void MathUtil::crossVec3(const float* v1, const float* v2, float* dst) { asm volatile( "vld1.32 {d1[1]}, [%1] \n\t" // diff --git a/cocos/math/Matrix.cpp b/cocos/math/Matrix.cpp index 5f3503fb3d..c904b758f4 100644 --- a/cocos/math/Matrix.cpp +++ b/cocos/math/Matrix.cpp @@ -25,58 +25,58 @@ NS_CC_MATH_BEGIN -Matrix::Matrix() +Mat4::Mat4() { *this = IDENTITY; } -Matrix::Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, +Mat4::Mat4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) { set(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); } -Matrix::Matrix(const float* mat) +Mat4::Mat4(const float* mat) { set(mat); } -Matrix::Matrix(const Matrix& copy) +Mat4::Mat4(const Mat4& copy) { memcpy(m, copy.m, MATRIX_SIZE); } -Matrix::~Matrix() +Mat4::~Mat4() { } -void Matrix::createLookAt(const Vector3& eyePosition, const Vector3& targetPosition, const Vector3& up, Matrix* dst) +void Mat4::createLookAt(const Vec3& eyePosition, const Vec3& targetPosition, const Vec3& up, Mat4* dst) { createLookAt(eyePosition.x, eyePosition.y, eyePosition.z, targetPosition.x, targetPosition.y, targetPosition.z, up.x, up.y, up.z, dst); } -void Matrix::createLookAt(float eyePositionX, float eyePositionY, float eyePositionZ, +void Mat4::createLookAt(float eyePositionX, float eyePositionY, float eyePositionZ, float targetPositionX, float targetPositionY, float targetPositionZ, - float upX, float upY, float upZ, Matrix* dst) + float upX, float upY, float upZ, Mat4* dst) { GP_ASSERT(dst); - Vector3 eye(eyePositionX, eyePositionY, eyePositionZ); - Vector3 target(targetPositionX, targetPositionY, targetPositionZ); - Vector3 up(upX, upY, upZ); + Vec3 eye(eyePositionX, eyePositionY, eyePositionZ); + Vec3 target(targetPositionX, targetPositionY, targetPositionZ); + Vec3 up(upX, upY, upZ); up.normalize(); - Vector3 zaxis; - Vector3::subtract(eye, target, &zaxis); + Vec3 zaxis; + Vec3::subtract(eye, target, &zaxis); zaxis.normalize(); - Vector3 xaxis; - Vector3::cross(up, zaxis, &xaxis); + Vec3 xaxis; + Vec3::cross(up, zaxis, &xaxis); xaxis.normalize(); - Vector3 yaxis; - Vector3::cross(zaxis, xaxis, &yaxis); + Vec3 yaxis; + Vec3::cross(zaxis, xaxis, &yaxis); yaxis.normalize(); dst->m[0] = xaxis.x; @@ -94,14 +94,14 @@ void Matrix::createLookAt(float eyePositionX, float eyePositionY, float eyePosit dst->m[10] = zaxis.z; dst->m[11] = 0.0f; - dst->m[12] = -Vector3::dot(xaxis, eye); - dst->m[13] = -Vector3::dot(yaxis, eye); - dst->m[14] = -Vector3::dot(zaxis, eye); + dst->m[12] = -Vec3::dot(xaxis, eye); + dst->m[13] = -Vec3::dot(yaxis, eye); + dst->m[14] = -Vec3::dot(zaxis, eye); dst->m[15] = 1.0f; } -void Matrix::createPerspective(float fieldOfView, float aspectRatio, - float zNearPlane, float zFarPlane, Matrix* dst) +void Mat4::createPerspective(float fieldOfView, float aspectRatio, + float zNearPlane, float zFarPlane, Mat4* dst) { GP_ASSERT(dst); GP_ASSERT(zFarPlane != zNearPlane); @@ -127,15 +127,15 @@ void Matrix::createPerspective(float fieldOfView, float aspectRatio, dst->m[14] = -2.0f * zFarPlane * zNearPlane * f_n; } -void Matrix::createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Matrix* dst) +void Mat4::createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4* dst) { float halfWidth = width / 2.0f; float halfHeight = height / 2.0f; createOrthographicOffCenter(-halfWidth, halfWidth, -halfHeight, halfHeight, zNearPlane, zFarPlane, dst); } -void Matrix::createOrthographicOffCenter(float left, float right, float bottom, float top, - float zNearPlane, float zFarPlane, Matrix* dst) +void Mat4::createOrthographicOffCenter(float left, float right, float bottom, float top, + float zNearPlane, float zFarPlane, Mat4* dst) { GP_ASSERT(dst); GP_ASSERT(right != left); @@ -153,24 +153,24 @@ void Matrix::createOrthographicOffCenter(float left, float right, float bottom, dst->m[15] = 1; } -void Matrix::createBillboard(const Vector3& objectPosition, const Vector3& cameraPosition, - const Vector3& cameraUpVector, Matrix* dst) +void Mat4::createBillboard(const Vec3& objectPosition, const Vec3& cameraPosition, + const Vec3& cameraUpVector, Mat4* dst) { createBillboardHelper(objectPosition, cameraPosition, cameraUpVector, NULL, dst); } -void Matrix::createBillboard(const Vector3& objectPosition, const Vector3& cameraPosition, - const Vector3& cameraUpVector, const Vector3& cameraForwardVector, - Matrix* dst) +void Mat4::createBillboard(const Vec3& objectPosition, const Vec3& cameraPosition, + const Vec3& cameraUpVector, const Vec3& cameraForwardVector, + Mat4* dst) { createBillboardHelper(objectPosition, cameraPosition, cameraUpVector, &cameraForwardVector, dst); } -void Matrix::createBillboardHelper(const Vector3& objectPosition, const Vector3& cameraPosition, - const Vector3& cameraUpVector, const Vector3* cameraForwardVector, - Matrix* dst) +void Mat4::createBillboardHelper(const Vec3& objectPosition, const Vec3& cameraPosition, + const Vec3& cameraUpVector, const Vec3* cameraForwardVector, + Mat4* dst) { - Vector3 delta(objectPosition, cameraPosition); + Vec3 delta(objectPosition, cameraPosition); bool isSufficientDelta = delta.lengthSquared() > MATH_EPSILON; dst->setIdentity(); @@ -182,10 +182,10 @@ void Matrix::createBillboardHelper(const Vector3& objectPosition, const Vector3& // either a safe default or a sufficient distance between object and camera. if (cameraForwardVector || isSufficientDelta) { - Vector3 target = isSufficientDelta ? cameraPosition : (objectPosition - *cameraForwardVector); + Vec3 target = isSufficientDelta ? cameraPosition : (objectPosition - *cameraForwardVector); // A billboard is the inverse of a lookAt rotation - Matrix lookAt; + Mat4 lookAt; createLookAt(objectPosition, target, cameraUpVector, &lookAt); dst->m[0] = lookAt.m[0]; dst->m[1] = lookAt.m[4]; @@ -199,9 +199,9 @@ void Matrix::createBillboardHelper(const Vector3& objectPosition, const Vector3& } } -// void Matrix::createReflection(const Plane& plane, Matrix* dst) +// void Mat4::createReflection(const Plane& plane, Mat4* dst) // { -// Vector3 normal(plane.getNormal()); +// Vec3 normal(plane.getNormal()); // float k = -2.0f * plane.getDistance(); // dst->setIdentity(); @@ -218,7 +218,7 @@ void Matrix::createBillboardHelper(const Vector3& objectPosition, const Vector3& // dst->m[11] = k * normal.z; // } -void Matrix::createScale(const Vector3& scale, Matrix* dst) +void Mat4::createScale(const Vec3& scale, Mat4* dst) { GP_ASSERT(dst); @@ -229,7 +229,7 @@ void Matrix::createScale(const Vector3& scale, Matrix* dst) dst->m[10] = scale.z; } -void Matrix::createScale(float xScale, float yScale, float zScale, Matrix* dst) +void Mat4::createScale(float xScale, float yScale, float zScale, Mat4* dst) { GP_ASSERT(dst); @@ -241,7 +241,7 @@ void Matrix::createScale(float xScale, float yScale, float zScale, Matrix* dst) } -void Matrix::createRotation(const Quaternion& q, Matrix* dst) +void Mat4::createRotation(const Quaternion& q, Mat4* dst) { GP_ASSERT(dst); @@ -280,7 +280,7 @@ void Matrix::createRotation(const Quaternion& q, Matrix* dst) dst->m[15] = 1.0f; } -void Matrix::createRotation(const Vector3& axis, float angle, Matrix* dst) +void Mat4::createRotation(const Vec3& axis, float angle, Mat4* dst) { GP_ASSERT(dst); @@ -339,7 +339,7 @@ void Matrix::createRotation(const Vector3& axis, float angle, Matrix* dst) dst->m[15] = 1.0f; } -void Matrix::createRotationX(float angle, Matrix* dst) +void Mat4::createRotationX(float angle, Mat4* dst) { GP_ASSERT(dst); @@ -354,7 +354,7 @@ void Matrix::createRotationX(float angle, Matrix* dst) dst->m[10] = c; } -void Matrix::createRotationY(float angle, Matrix* dst) +void Mat4::createRotationY(float angle, Mat4* dst) { GP_ASSERT(dst); @@ -369,7 +369,7 @@ void Matrix::createRotationY(float angle, Matrix* dst) dst->m[10] = c; } -void Matrix::createRotationZ(float angle, Matrix* dst) +void Mat4::createRotationZ(float angle, Mat4* dst) { GP_ASSERT(dst); @@ -384,7 +384,7 @@ void Matrix::createRotationZ(float angle, Matrix* dst) dst->m[5] = c; } -void Matrix::createTranslation(const Vector3& translation, Matrix* dst) +void Mat4::createTranslation(const Vec3& translation, Mat4* dst) { GP_ASSERT(dst); @@ -395,7 +395,7 @@ void Matrix::createTranslation(const Vector3& translation, Matrix* dst) dst->m[14] = translation.z; } -void Matrix::createTranslation(float xTranslation, float yTranslation, float zTranslation, Matrix* dst) +void Mat4::createTranslation(float xTranslation, float yTranslation, float zTranslation, Mat4* dst) { GP_ASSERT(dst); @@ -406,31 +406,31 @@ void Matrix::createTranslation(float xTranslation, float yTranslation, float zTr dst->m[14] = zTranslation; } -void Matrix::add(float scalar) +void Mat4::add(float scalar) { add(scalar, this); } -void Matrix::add(float scalar, Matrix* dst) +void Mat4::add(float scalar, Mat4* dst) { GP_ASSERT(dst); MathUtil::addMatrix(m, scalar, dst->m); } -void Matrix::add(const Matrix& mat) +void Mat4::add(const Mat4& mat) { add(*this, mat, this); } -void Matrix::add(const Matrix& m1, const Matrix& m2, Matrix* dst) +void Mat4::add(const Mat4& m1, const Mat4& m2, Mat4* dst) { GP_ASSERT(dst); MathUtil::addMatrix(m1.m, m2.m, dst->m); } -bool Matrix::decompose(Vector3* scale, Quaternion* rotation, Vector3* translation) const +bool Mat4::decompose(Vec3* scale, Quaternion* rotation, Vec3* translation) const { if (translation) { @@ -446,13 +446,13 @@ bool Matrix::decompose(Vector3* scale, Quaternion* rotation, Vector3* translatio // Extract the scale. // This is simply the length of each axis (row/column) in the matrix. - Vector3 xaxis(m[0], m[1], m[2]); + Vec3 xaxis(m[0], m[1], m[2]); float scaleX = xaxis.length(); - Vector3 yaxis(m[4], m[5], m[6]); + Vec3 yaxis(m[4], m[5], m[6]); float scaleY = yaxis.length(); - Vector3 zaxis(m[8], m[9], m[10]); + Vec3 zaxis(m[8], m[9], m[10]); float scaleZ = zaxis.length(); // Determine if we have a negative scale (true if determinant is less than zero). @@ -538,7 +538,7 @@ bool Matrix::decompose(Vector3* scale, Quaternion* rotation, Vector3* translatio return true; } -float Matrix::determinant() const +float Mat4::determinant() const { float a0 = m[0] * m[5] - m[1] * m[4]; float a1 = m[0] * m[6] - m[2] * m[4]; @@ -557,22 +557,22 @@ float Matrix::determinant() const return (a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0); } -void Matrix::getScale(Vector3* scale) const +void Mat4::getScale(Vec3* scale) const { decompose(scale, NULL, NULL); } -bool Matrix::getRotation(Quaternion* rotation) const +bool Mat4::getRotation(Quaternion* rotation) const { return decompose(NULL, rotation, NULL); } -void Matrix::getTranslation(Vector3* translation) const +void Mat4::getTranslation(Vec3* translation) const { decompose(NULL, NULL, translation); } -void Matrix::getUpVector(Vector3* dst) const +void Mat4::getUpVector(Vec3* dst) const { GP_ASSERT(dst); @@ -581,7 +581,7 @@ void Matrix::getUpVector(Vector3* dst) const dst->z = m[6]; } -void Matrix::getDownVector(Vector3* dst) const +void Mat4::getDownVector(Vec3* dst) const { GP_ASSERT(dst); @@ -590,7 +590,7 @@ void Matrix::getDownVector(Vector3* dst) const dst->z = -m[6]; } -void Matrix::getLeftVector(Vector3* dst) const +void Mat4::getLeftVector(Vec3* dst) const { GP_ASSERT(dst); @@ -599,7 +599,7 @@ void Matrix::getLeftVector(Vector3* dst) const dst->z = -m[2]; } -void Matrix::getRightVector(Vector3* dst) const +void Mat4::getRightVector(Vec3* dst) const { GP_ASSERT(dst); @@ -608,7 +608,7 @@ void Matrix::getRightVector(Vector3* dst) const dst->z = m[2]; } -void Matrix::getForwardVector(Vector3* dst) const +void Mat4::getForwardVector(Vec3* dst) const { GP_ASSERT(dst); @@ -617,7 +617,7 @@ void Matrix::getForwardVector(Vector3* dst) const dst->z = -m[10]; } -void Matrix::getBackVector(Vector3* dst) const +void Mat4::getBackVector(Vec3* dst) const { GP_ASSERT(dst); @@ -626,14 +626,14 @@ void Matrix::getBackVector(Vector3* dst) const dst->z = m[10]; } -Matrix Matrix::getInversed() const +Mat4 Mat4::getInversed() const { - Matrix mat(*this); + Mat4 mat(*this); mat.inverse(); return mat; } -bool Matrix::inverse() +bool Mat4::inverse() { float a0 = m[0] * m[5] - m[1] * m[4]; float a1 = m[0] * m[6] - m[2] * m[4]; @@ -656,7 +656,7 @@ bool Matrix::inverse() return false; // Support the case where m == dst. - Matrix inverse; + Mat4 inverse; inverse.m[0] = m[5] * b5 - m[6] * b4 + m[7] * b3; inverse.m[1] = -m[1] * b5 + m[2] * b4 - m[3] * b3; inverse.m[2] = m[13] * a5 - m[14] * a4 + m[15] * a3; @@ -682,145 +682,145 @@ bool Matrix::inverse() return true; } -bool Matrix::isIdentity() const +bool Mat4::isIdentity() const { return (memcmp(m, &IDENTITY, MATRIX_SIZE) == 0); } -void Matrix::multiply(float scalar) +void Mat4::multiply(float scalar) { multiply(scalar, this); } -void Matrix::multiply(float scalar, Matrix* dst) const +void Mat4::multiply(float scalar, Mat4* dst) const { multiply(*this, scalar, dst); } -void Matrix::multiply(const Matrix& m, float scalar, Matrix* dst) +void Mat4::multiply(const Mat4& m, float scalar, Mat4* dst) { GP_ASSERT(dst); MathUtil::multiplyMatrix(m.m, scalar, dst->m); } -void Matrix::multiply(const Matrix& mat) +void Mat4::multiply(const Mat4& mat) { multiply(*this, mat, this); } -void Matrix::multiply(const Matrix& m1, const Matrix& m2, Matrix* dst) +void Mat4::multiply(const Mat4& m1, const Mat4& m2, Mat4* dst) { GP_ASSERT(dst); MathUtil::multiplyMatrix(m1.m, m2.m, dst->m); } -void Matrix::negate() +void Mat4::negate() { MathUtil::negateMatrix(m, m); } -Matrix Matrix::getNegated() const +Mat4 Mat4::getNegated() const { - Matrix mat(*this); + Mat4 mat(*this); mat.negate(); return mat; } -void Matrix::rotate(const Quaternion& q) +void Mat4::rotate(const Quaternion& q) { rotate(q, this); } -void Matrix::rotate(const Quaternion& q, Matrix* dst) const +void Mat4::rotate(const Quaternion& q, Mat4* dst) const { - Matrix r; + Mat4 r; createRotation(q, &r); multiply(*this, r, dst); } -void Matrix::rotate(const Vector3& axis, float angle) +void Mat4::rotate(const Vec3& axis, float angle) { rotate(axis, angle, this); } -void Matrix::rotate(const Vector3& axis, float angle, Matrix* dst) const +void Mat4::rotate(const Vec3& axis, float angle, Mat4* dst) const { - Matrix r; + Mat4 r; createRotation(axis, angle, &r); multiply(*this, r, dst); } -void Matrix::rotateX(float angle) +void Mat4::rotateX(float angle) { rotateX(angle, this); } -void Matrix::rotateX(float angle, Matrix* dst) const +void Mat4::rotateX(float angle, Mat4* dst) const { - Matrix r; + Mat4 r; createRotationX(angle, &r); multiply(*this, r, dst); } -void Matrix::rotateY(float angle) +void Mat4::rotateY(float angle) { rotateY(angle, this); } -void Matrix::rotateY(float angle, Matrix* dst) const +void Mat4::rotateY(float angle, Mat4* dst) const { - Matrix r; + Mat4 r; createRotationY(angle, &r); multiply(*this, r, dst); } -void Matrix::rotateZ(float angle) +void Mat4::rotateZ(float angle) { rotateZ(angle, this); } -void Matrix::rotateZ(float angle, Matrix* dst) const +void Mat4::rotateZ(float angle, Mat4* dst) const { - Matrix r; + Mat4 r; createRotationZ(angle, &r); multiply(*this, r, dst); } -void Matrix::scale(float value) +void Mat4::scale(float value) { scale(value, this); } -void Matrix::scale(float value, Matrix* dst) const +void Mat4::scale(float value, Mat4* dst) const { scale(value, value, value, dst); } -void Matrix::scale(float xScale, float yScale, float zScale) +void Mat4::scale(float xScale, float yScale, float zScale) { scale(xScale, yScale, zScale, this); } -void Matrix::scale(float xScale, float yScale, float zScale, Matrix* dst) const +void Mat4::scale(float xScale, float yScale, float zScale, Mat4* dst) const { - Matrix s; + Mat4 s; createScale(xScale, yScale, zScale, &s); multiply(*this, s, dst); } -void Matrix::scale(const Vector3& s) +void Mat4::scale(const Vec3& s) { scale(s.x, s.y, s.z, this); } -void Matrix::scale(const Vector3& s, Matrix* dst) const +void Mat4::scale(const Vec3& s, Mat4* dst) const { scale(s.x, s.y, s.z, dst); } -void Matrix::set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, +void Mat4::set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) { m[0] = m11; @@ -841,122 +841,122 @@ void Matrix::set(float m11, float m12, float m13, float m14, float m21, float m2 m[15] = m44; } -void Matrix::set(const float* mat) +void Mat4::set(const float* mat) { GP_ASSERT(mat); memcpy(this->m, mat, MATRIX_SIZE); } -void Matrix::set(const Matrix& mat) +void Mat4::set(const Mat4& mat) { memcpy(this->m, mat.m, MATRIX_SIZE); } -void Matrix::setIdentity() +void Mat4::setIdentity() { memcpy(m, &IDENTITY, MATRIX_SIZE); } -void Matrix::setZero() +void Mat4::setZero() { memset(m, 0, MATRIX_SIZE); } -void Matrix::subtract(const Matrix& mat) +void Mat4::subtract(const Mat4& mat) { subtract(*this, mat, this); } -void Matrix::subtract(const Matrix& m1, const Matrix& m2, Matrix* dst) +void Mat4::subtract(const Mat4& m1, const Mat4& m2, Mat4* dst) { GP_ASSERT(dst); MathUtil::subtractMatrix(m1.m, m2.m, dst->m); } -void Matrix::transformPoint(Vector3* point) const +void Mat4::transformPoint(Vec3* point) const { GP_ASSERT(point); transformVector(point->x, point->y, point->z, 1.0f, point); } -void Matrix::transformPoint(const Vector3& point, Vector3* dst) const +void Mat4::transformPoint(const Vec3& point, Vec3* dst) const { transformVector(point.x, point.y, point.z, 1.0f, dst); } -void Matrix::transformVector(Vector3* vector) const +void Mat4::transformVector(Vec3* vector) const { GP_ASSERT(vector); transformVector(vector->x, vector->y, vector->z, 0.0f, vector); } -void Matrix::transformVector(const Vector3& vector, Vector3* dst) const +void Mat4::transformVector(const Vec3& vector, Vec3* dst) const { transformVector(vector.x, vector.y, vector.z, 0.0f, dst); } -void Matrix::transformVector(float x, float y, float z, float w, Vector3* dst) const +void Mat4::transformVector(float x, float y, float z, float w, Vec3* dst) const { GP_ASSERT(dst); - MathUtil::transformVector4(m, x, y, z, w, (float*)dst); + MathUtil::transformVec4(m, x, y, z, w, (float*)dst); } -void Matrix::transformVector(Vector4* vector) const +void Mat4::transformVector(Vec4* vector) const { GP_ASSERT(vector); transformVector(*vector, vector); } -void Matrix::transformVector(const Vector4& vector, Vector4* dst) const +void Mat4::transformVector(const Vec4& vector, Vec4* dst) const { GP_ASSERT(dst); - MathUtil::transformVector4(m, (const float*) &vector, (float*)dst); + MathUtil::transformVec4(m, (const float*) &vector, (float*)dst); } -void Matrix::translate(float x, float y, float z) +void Mat4::translate(float x, float y, float z) { translate(x, y, z, this); } -void Matrix::translate(float x, float y, float z, Matrix* dst) const +void Mat4::translate(float x, float y, float z, Mat4* dst) const { - Matrix t; + Mat4 t; createTranslation(x, y, z, &t); multiply(*this, t, dst); } -void Matrix::translate(const Vector3& t) +void Mat4::translate(const Vec3& t) { translate(t.x, t.y, t.z, this); } -void Matrix::translate(const Vector3& t, Matrix* dst) const +void Mat4::translate(const Vec3& t, Mat4* dst) const { translate(t.x, t.y, t.z, dst); } -void Matrix::transpose() +void Mat4::transpose() { MathUtil::transposeMatrix(m, m); } -Matrix Matrix::getTransposed() const +Mat4 Mat4::getTransposed() const { - Matrix mat(*this); + Mat4 mat(*this); mat.transpose(); return mat; } -const Matrix Matrix::IDENTITY = Matrix( +const Mat4 Mat4::IDENTITY = Mat4( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); -const Matrix Matrix::ZERO = Matrix( +const Mat4 Mat4::ZERO = Mat4( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/cocos/math/Matrix.h b/cocos/math/Matrix.h index 4ee9f927ee..1513599f53 100644 --- a/cocos/math/Matrix.h +++ b/cocos/math/Matrix.h @@ -18,11 +18,11 @@ This file was modified to fit the cocos2d-x project */ -#ifndef MATRIX_H_ -#define MATRIX_H_ +#ifndef MATH_MAT4_H +#define MATH_MAT4_H -#include "Vector3.h" -#include "Vector4.h" +#include "math/Vector3.h" +#include "math/Vector4.h" NS_CC_MATH_BEGIN @@ -59,7 +59,7 @@ NS_CC_MATH_BEGIN * * @see Transform */ -class Matrix +class Mat4 { public: // //temp add conversion @@ -70,7 +70,7 @@ public: // return result; // } - // Matrix(const kmMat4& mat) + // Mat4(const kmMat4& mat) // { // set(mat.mat); // } @@ -87,7 +87,7 @@ public: * 0 0 1 0 * 0 0 0 1 */ - Matrix(); + Mat4(); /** * Constructs a matrix initialized to the specified value. @@ -109,7 +109,7 @@ public: * @param m43 The third element of the fourth row. * @param m44 The fourth element of the fourth row. */ - Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, + Mat4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44); /** @@ -124,19 +124,19 @@ public: * * @param mat An array containing 16 elements in column-major order. */ - Matrix(const float* mat); + Mat4(const float* mat); /** * Constructs a new matrix by copying the values from the specified matrix. * * @param copy The matrix to copy. */ - Matrix(const Matrix& copy); + Mat4(const Mat4& copy); /** * Destructor. */ - ~Matrix(); + ~Mat4(); /** * Creates a view matrix based on the specified input parameters. @@ -146,7 +146,7 @@ public: * @param up The up vector. * @param dst A matrix to store the result in. */ - static void createLookAt(const Vector3& eyePosition, const Vector3& targetPosition, const Vector3& up, Matrix* dst); + static void createLookAt(const Vec3& eyePosition, const Vec3& targetPosition, const Vec3& up, Mat4* dst); /** * Creates a view matrix based on the specified input parameters. @@ -164,7 +164,7 @@ public: */ static void createLookAt(float eyePositionX, float eyePositionY, float eyePositionZ, float targetCenterX, float targetCenterY, float targetCenterZ, - float upX, float upY, float upZ, Matrix* dst); + float upX, float upY, float upZ, Mat4* dst); /** * Builds a perspective projection matrix based on a field of view and returns by value. @@ -180,7 +180,7 @@ public: * @param zFarPlane The distance to the far view plane. * @param dst A matrix to store the result in. */ - static void createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, Matrix* dst); + static void createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, Mat4* dst); /** * Creates an orthographic projection matrix. @@ -191,7 +191,7 @@ public: * @param zFarPlane The maximum z-value of the view volume. * @param dst A matrix to store the result in. */ - static void createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Matrix* dst); + static void createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4* dst); /** * Creates an orthographic projection matrix. @@ -222,7 +222,7 @@ public: * @param dst A matrix to store the result in. */ static void createOrthographicOffCenter(float left, float right, float bottom, float top, - float zNearPlane, float zFarPlane, Matrix* dst); + float zNearPlane, float zFarPlane, Mat4* dst); /** * Creates a spherical billboard that rotates around a specified object position. @@ -238,8 +238,8 @@ public: * @param cameraUpVector The up vector of the camera. * @param dst A matrix to store the result in. */ - static void createBillboard(const Vector3& objectPosition, const Vector3& cameraPosition, - const Vector3& cameraUpVector, Matrix* dst); + static void createBillboard(const Vec3& objectPosition, const Vec3& cameraPosition, + const Vec3& cameraUpVector, Mat4* dst); /** * Creates a spherical billboard that rotates around a specified object position with @@ -257,17 +257,17 @@ public: * @param cameraForwardVector The forward vector of the camera, used if the positions are too close. * @param dst A matrix to store the result in. */ - static void createBillboard(const Vector3& objectPosition, const Vector3& cameraPosition, - const Vector3& cameraUpVector, const Vector3& cameraForwardVector, - Matrix* dst); + static void createBillboard(const Vec3& objectPosition, const Vec3& cameraPosition, + const Vec3& cameraUpVector, const Vec3& cameraForwardVector, + Mat4* dst); /** - * Fills in an existing Matrix so that it reflects the coordinate system about a specified Plane. + * Fills in an existing Mat4 so that it reflects the coordinate system about a specified Plane. * * @param plane The Plane about which to create a reflection. * @param dst A matrix to store the result in. */ - //static void createReflection(const Plane& plane, Matrix* dst); + //static void createReflection(const Plane& plane, Mat4* dst); /** * Creates a scale matrix. @@ -275,7 +275,7 @@ public: * @param scale The amount to scale. * @param dst A matrix to store the result in. */ - static void createScale(const Vector3& scale, Matrix* dst); + static void createScale(const Vec3& scale, Mat4* dst); /** * Creates a scale matrix. @@ -285,7 +285,7 @@ public: * @param zScale The amount to scale along the z-axis. * @param dst A matrix to store the result in. */ - static void createScale(float xScale, float yScale, float zScale, Matrix* dst); + static void createScale(float xScale, float yScale, float zScale, Mat4* dst); /** * Creates a rotation matrix from the specified quaternion. @@ -293,7 +293,7 @@ public: * @param quat A quaternion describing a 3D orientation. * @param dst A matrix to store the result in. */ - static void createRotation(const Quaternion& quat, Matrix* dst); + static void createRotation(const Quaternion& quat, Mat4* dst); /** * Creates a rotation matrix from the specified axis and angle. @@ -302,7 +302,7 @@ public: * @param angle The angle (in radians). * @param dst A matrix to store the result in. */ - static void createRotation(const Vector3& axis, float angle, Matrix* dst); + static void createRotation(const Vec3& axis, float angle, Mat4* dst); /** * Creates a matrix describing a rotation around the x-axis. @@ -310,7 +310,7 @@ public: * @param angle The angle of rotation (in radians). * @param dst A matrix to store the result in. */ - static void createRotationX(float angle, Matrix* dst); + static void createRotationX(float angle, Mat4* dst); /** * Creates a matrix describing a rotation around the y-axis. @@ -318,7 +318,7 @@ public: * @param angle The angle of rotation (in radians). * @param dst A matrix to store the result in. */ - static void createRotationY(float angle, Matrix* dst); + static void createRotationY(float angle, Mat4* dst); /** * Creates a matrix describing a rotation around the z-axis. @@ -326,7 +326,7 @@ public: * @param angle The angle of rotation (in radians). * @param dst A matrix to store the result in. */ - static void createRotationZ(float angle, Matrix* dst); + static void createRotationZ(float angle, Mat4* dst); /** * Creates a translation matrix. @@ -334,7 +334,7 @@ public: * @param translation The translation. * @param dst A matrix to store the result in. */ - static void createTranslation(const Vector3& translation, Matrix* dst); + static void createTranslation(const Vec3& translation, Mat4* dst); /** * Creates a translation matrix. @@ -344,7 +344,7 @@ public: * @param zTranslation The translation on the z-axis. * @param dst A matrix to store the result in. */ - static void createTranslation(float xTranslation, float yTranslation, float zTranslation, Matrix* dst); + static void createTranslation(float xTranslation, float yTranslation, float zTranslation, Mat4* dst); /** * Adds a scalar value to each component of this matrix. @@ -359,14 +359,14 @@ public: * @param scalar The scalar value to add. * @param dst A matrix to store the result in. */ - void add(float scalar, Matrix* dst); + void add(float scalar, Mat4* dst); /** * Adds the specified matrix to this matrix. * * @param mat The matrix to add. */ - void add(const Matrix& mat); + void add(const Mat4& mat); /** * Adds the specified matrices and stores the result in dst. @@ -375,7 +375,7 @@ public: * @param m2 The second matrix. * @param dst The destination matrix to add to. */ - static void add(const Matrix& m1, const Matrix& m2, Matrix* dst); + static void add(const Mat4& m1, const Mat4& m2, Mat4* dst); /** * Decomposes the scale, rotation and translation components of this matrix. @@ -384,7 +384,7 @@ public: * @param rotation The rotation. * @param translation The translation. */ - bool decompose(Vector3* scale, Quaternion* rotation, Vector3* translation) const; + bool decompose(Vec3* scale, Quaternion* rotation, Vec3* translation) const; /** * Computes the determinant of this matrix. @@ -403,7 +403,7 @@ public: * * @param scale A vector to receive the scale. */ - void getScale(Vector3* scale) const; + void getScale(Vec3* scale) const; /** * Gets the rotational component of this matrix in the specified quaternion. @@ -419,49 +419,49 @@ public: * * @param translation A vector to receive the translation. */ - void getTranslation(Vector3* translation) const; + void getTranslation(Vec3* translation) const; /** * Gets the up vector of this matrix. * * @param dst The destination vector. */ - void getUpVector(Vector3* dst) const; + void getUpVector(Vec3* dst) const; /** * Gets the down vector of this matrix. * * @param dst The destination vector. */ - void getDownVector(Vector3* dst) const; + void getDownVector(Vec3* dst) const; /** * Gets the left vector of this matrix. * * @param dst The destination vector. */ - void getLeftVector(Vector3* dst) const; + void getLeftVector(Vec3* dst) const; /** * Gets the right vector of this matrix. * * @param dst The destination vector. */ - void getRightVector(Vector3* dst) const; + void getRightVector(Vec3* dst) const; /** * Gets the forward vector of this matrix. * * @param dst The destination vector. */ - void getForwardVector(Vector3* dst) const; + void getForwardVector(Vec3* dst) const; /** * Gets the backward vector of this matrix. * * @param dst The destination vector. */ - void getBackVector(Vector3* dst) const; + void getBackVector(Vec3* dst) const; /** * Inverts this matrix. @@ -477,7 +477,7 @@ public: * * @return true if the the matrix can be inverted, false otherwise. */ - Matrix getInversed() const; + Mat4 getInversed() const; /** * Determines if this matrix is equal to the identity matrix. @@ -499,7 +499,7 @@ public: * @param scalar The scalar value. * @param dst A matrix to store the result in. */ - void multiply(float scalar, Matrix* dst) const; + void multiply(float scalar, Mat4* dst) const; /** * Multiplies the components of the specified matrix by a scalar and stores the result in dst. @@ -508,14 +508,14 @@ public: * @param scalar The scalar value. * @param dst A matrix to store the result in. */ - static void multiply(const Matrix& mat, float scalar, Matrix* dst); + static void multiply(const Mat4& mat, float scalar, Mat4* dst); /** * Multiplies this matrix by the specified one. * * @param mat The matrix to multiply. */ - void multiply(const Matrix& mat); + void multiply(const Mat4& mat); /** * Multiplies m1 by m2 and stores the result in dst. @@ -524,7 +524,7 @@ public: * @param m2 The second matrix to multiply. * @param dst A matrix to store the result in. */ - static void multiply(const Matrix& m1, const Matrix& m2, Matrix* dst); + static void multiply(const Mat4& m1, const Mat4& m2, Mat4* dst); /** * Negates this matrix. @@ -536,7 +536,7 @@ public: * * @param dst A matrix to store the result in. */ - Matrix getNegated() const; + Mat4 getNegated() const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -553,7 +553,7 @@ public: * @param q The quaternion to rotate by. * @param dst A matrix to store the result in. */ - void rotate(const Quaternion& q, Matrix* dst) const; + void rotate(const Quaternion& q, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -562,7 +562,7 @@ public: * @param axis The axis to rotate about. * @param angle The angle (in radians). */ - void rotate(const Vector3& axis, float angle); + void rotate(const Vec3& axis, float angle); /** * Post-multiplies this matrix by the matrix corresponding to the specified @@ -572,7 +572,7 @@ public: * @param angle The angle (in radians). * @param dst A matrix to store the result in. */ - void rotate(const Vector3& axis, float angle, Matrix* dst) const; + void rotate(const Vec3& axis, float angle, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -589,7 +589,7 @@ public: * @param angle The angle (in radians). * @param dst A matrix to store the result in. */ - void rotateX(float angle, Matrix* dst) const; + void rotateX(float angle, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -606,7 +606,7 @@ public: * @param angle The angle (in radians). * @param dst A matrix to store the result in. */ - void rotateY(float angle, Matrix* dst) const; + void rotateY(float angle, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -623,7 +623,7 @@ public: * @param angle The angle (in radians). * @param dst A matrix to store the result in. */ - void rotateZ(float angle, Matrix* dst) const; + void rotateZ(float angle, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -640,7 +640,7 @@ public: * @param value The amount to scale along all axes. * @param dst A matrix to store the result in. */ - void scale(float value, Matrix* dst) const; + void scale(float value, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -661,7 +661,7 @@ public: * @param zScale The amount to scale along the z-axis. * @param dst A matrix to store the result in. */ - void scale(float xScale, float yScale, float zScale, Matrix* dst) const; + void scale(float xScale, float yScale, float zScale, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -669,7 +669,7 @@ public: * * @param s The scale values along the x, y and z axes. */ - void scale(const Vector3& s); + void scale(const Vec3& s); /** * Post-multiplies this matrix by the matrix corresponding to the @@ -678,7 +678,7 @@ public: * @param s The scale values along the x, y and z axes. * @param dst A matrix to store the result in. */ - void scale(const Vector3& s, Matrix* dst) const; + void scale(const Vec3& s, Mat4* dst) const; /** * Sets the values of this matrix. @@ -715,7 +715,7 @@ public: * * @param mat The source matrix. */ - void set(const Matrix& mat); + void set(const Mat4& mat); /** * Sets this matrix to the identity matrix. @@ -732,7 +732,7 @@ public: * * @param mat The matrix to subtract. */ - void subtract(const Matrix& mat); + void subtract(const Mat4& mat); /** * Subtracts the specified matrix from the current matrix. @@ -741,7 +741,7 @@ public: * @param m2 The second matrix. * @param dst A matrix to store the result in. */ - static void subtract(const Matrix& m1, const Matrix& m2, Matrix* dst); + static void subtract(const Mat4& m1, const Mat4& m2, Mat4* dst); /** * Transforms the specified point by this matrix. @@ -750,7 +750,7 @@ public: * * @param point The point to transform and also a vector to hold the result in. */ - void transformPoint(Vector3* point) const; + void transformPoint(Vec3* point) const; /** * Transforms the specified point by this matrix, and stores @@ -759,7 +759,7 @@ public: * @param point The point to transform. * @param dst A vector to store the transformed point in. */ - void transformPoint(const Vector3& point, Vector3* dst) const; + void transformPoint(const Vec3& point, Vec3* dst) const; /** * Transforms the specified vector by this matrix by @@ -769,7 +769,7 @@ public: * * @param vector The vector to transform and also a vector to hold the result in. */ - void transformVector(Vector3* vector) const; + void transformVector(Vec3* vector) const; /** * Transforms the specified vector by this matrix by @@ -779,7 +779,7 @@ public: * @param vector The vector to transform. * @param dst A vector to store the transformed vector in. */ - void transformVector(const Vector3& vector, Vector3* dst) const; + void transformVector(const Vec3& vector, Vec3* dst) const; /** * Transforms the specified vector by this matrix. @@ -790,7 +790,7 @@ public: * @param w The vector w-coordinate to transform by. * @param dst A vector to store the transformed point in. */ - void transformVector(float x, float y, float z, float w, Vector3* dst) const; + void transformVector(float x, float y, float z, float w, Vec3* dst) const; /** * Transforms the specified vector by this matrix. @@ -799,7 +799,7 @@ public: * * @param vector The vector to transform. */ - void transformVector(Vector4* vector) const; + void transformVector(Vec4* vector) const; /** * Transforms the specified vector by this matrix. @@ -807,7 +807,7 @@ public: * @param vector The vector to transform. * @param dst A vector to store the transformed point in. */ - void transformVector(const Vector4& vector, Vector4* dst) const; + void transformVector(const Vec4& vector, Vec4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -828,7 +828,7 @@ public: * @param z The amount to translate along the z-axis. * @param dst A matrix to store the result in. */ - void translate(float x, float y, float z, Matrix* dst) const; + void translate(float x, float y, float z, Mat4* dst) const; /** * Post-multiplies this matrix by the matrix corresponding to the @@ -836,7 +836,7 @@ public: * * @param t The translation values along the x, y and z axes. */ - void translate(const Vector3& t); + void translate(const Vec3& t); /** * Post-multiplies this matrix by the matrix corresponding to the @@ -845,7 +845,7 @@ public: * @param t The translation values along the x, y and z axes. * @param dst A matrix to store the result in. */ - void translate(const Vector3& t, Matrix* dst) const; + void translate(const Vec3& t, Mat4* dst) const; /** * Transposes this matrix. @@ -857,7 +857,7 @@ public: * * @param dst A matrix to store the result in. */ - Matrix getTransposed() const; + Mat4 getTransposed() const; /** * Calculates the sum of this matrix with the given matrix. @@ -867,7 +867,7 @@ public: * @param mat The matrix to add. * @return The matrix sum. */ - inline const Matrix operator+(const Matrix& mat) const; + inline const Mat4 operator+(const Mat4& mat) const; /** * Adds the given matrix to this matrix. @@ -875,7 +875,7 @@ public: * @param mat The matrix to add. * @return This matrix, after the addition occurs. */ - inline Matrix& operator+=(const Matrix& mat); + inline Mat4& operator+=(const Mat4& mat); /** * Calculates the difference of this matrix with the given matrix. @@ -885,7 +885,7 @@ public: * @param mat The matrix to subtract. * @return The matrix difference. */ - inline const Matrix operator-(const Matrix& mat) const; + inline const Mat4 operator-(const Mat4& mat) const; /** * Subtracts the given matrix from this matrix. @@ -893,7 +893,7 @@ public: * @param mat The matrix to subtract. * @return This matrix, after the subtraction occurs. */ - inline Matrix& operator-=(const Matrix& mat); + inline Mat4& operator-=(const Mat4& mat); /** * Calculates the negation of this matrix. @@ -902,7 +902,7 @@ public: * * @return The negation of this matrix. */ - inline const Matrix operator-() const; + inline const Mat4 operator-() const; /** * Calculates the matrix product of this matrix with the given matrix. @@ -912,7 +912,7 @@ public: * @param mat The matrix to multiply by. * @return The matrix product. */ - inline const Matrix operator*(const Matrix& mat) const; + inline const Mat4 operator*(const Mat4& mat) const; /** * Right-multiplies this matrix by the given matrix. @@ -920,18 +920,18 @@ public: * @param mat The matrix to multiply by. * @return This matrix, after the multiplication occurs. */ - inline Matrix& operator*=(const Matrix& mat); + inline Mat4& operator*=(const Mat4& mat); /** equals to a matrix full of zeros */ - static const Matrix ZERO; + static const Mat4 ZERO; /** equals to the identity matrix */ - static const Matrix IDENTITY; + static const Mat4 IDENTITY; private: - static void createBillboardHelper(const Vector3& objectPosition, const Vector3& cameraPosition, - const Vector3& cameraUpVector, const Vector3* cameraForwardVector, - Matrix* dst); + static void createBillboardHelper(const Vec3& objectPosition, const Vec3& cameraPosition, + const Vec3& cameraUpVector, const Vec3* cameraForwardVector, + Mat4* dst); }; /** @@ -943,7 +943,7 @@ private: * @param m The matrix to transform by. * @return This vector, after the transformation occurs. */ -inline Vector3& operator*=(Vector3& v, const Matrix& m); +inline Vec3& operator*=(Vec3& v, const Mat4& m); /** * Transforms the given vector by the given matrix. @@ -954,7 +954,7 @@ inline Vector3& operator*=(Vector3& v, const Matrix& m); * @param v The vector to transform. * @return The resulting transformed vector. */ -inline const Vector3 operator*(const Matrix& m, const Vector3& v); +inline const Vec3 operator*(const Mat4& m, const Vec3& v); /** * Transforms the given vector by the given matrix. @@ -965,7 +965,7 @@ inline const Vector3 operator*(const Matrix& m, const Vector3& v); * @param m The matrix to transform by. * @return This vector, after the transformation occurs. */ -inline Vector4& operator*=(Vector4& v, const Matrix& m); +inline Vec4& operator*=(Vec4& v, const Mat4& m); /** * Transforms the given vector by the given matrix. @@ -976,10 +976,10 @@ inline Vector4& operator*=(Vector4& v, const Matrix& m); * @param v The vector to transform. * @return The resulting transformed vector. */ -inline const Vector4 operator*(const Matrix& m, const Vector4& v); +inline const Vec4 operator*(const Mat4& m, const Vec4& v); NS_CC_MATH_END #include "Matrix.inl" -#endif +#endif // MATH_MAT4_H diff --git a/cocos/math/Matrix.inl b/cocos/math/Matrix.inl index 44e305e666..3ae3fc8c2d 100644 --- a/cocos/math/Matrix.inl +++ b/cocos/math/Matrix.inl @@ -22,74 +22,74 @@ NS_CC_MATH_BEGIN -inline const Matrix Matrix::operator+(const Matrix& mat) const +inline const Mat4 Mat4::operator+(const Mat4& mat) const { - Matrix result(*this); + Mat4 result(*this); result.add(mat); return result; } -inline Matrix& Matrix::operator+=(const Matrix& mat) +inline Mat4& Mat4::operator+=(const Mat4& mat) { add(mat); return *this; } -inline const Matrix Matrix::operator-(const Matrix& mat) const +inline const Mat4 Mat4::operator-(const Mat4& mat) const { - Matrix result(*this); + Mat4 result(*this); result.subtract(mat); return result; } -inline Matrix& Matrix::operator-=(const Matrix& mat) +inline Mat4& Mat4::operator-=(const Mat4& mat) { subtract(mat); return *this; } -inline const Matrix Matrix::operator-() const +inline const Mat4 Mat4::operator-() const { - Matrix mat(*this); + Mat4 mat(*this); mat.negate(); return mat; } -inline const Matrix Matrix::operator*(const Matrix& mat) const +inline const Mat4 Mat4::operator*(const Mat4& mat) const { - Matrix result(*this); + Mat4 result(*this); result.multiply(mat); return result; } -inline Matrix& Matrix::operator*=(const Matrix& mat) +inline Mat4& Mat4::operator*=(const Mat4& mat) { multiply(mat); return *this; } -inline Vector3& operator*=(Vector3& v, const Matrix& m) +inline Vec3& operator*=(Vec3& v, const Mat4& m) { m.transformVector(&v); return v; } -inline const Vector3 operator*(const Matrix& m, const Vector3& v) +inline const Vec3 operator*(const Mat4& m, const Vec3& v) { - Vector3 x; + Vec3 x; m.transformVector(v, &x); return x; } -inline Vector4& operator*=(Vector4& v, const Matrix& m) +inline Vec4& operator*=(Vec4& v, const Mat4& m) { m.transformVector(&v); return v; } -inline const Vector4 operator*(const Matrix& m, const Vector4& v) +inline const Vec4 operator*(const Mat4& m, const Vec4& v) { - Vector4 x; + Vec4 x; m.transformVector(v, &x); return x; } diff --git a/cocos/math/Quaternion.cpp b/cocos/math/Quaternion.cpp index da96e294d4..36089ee011 100644 --- a/cocos/math/Quaternion.cpp +++ b/cocos/math/Quaternion.cpp @@ -38,12 +38,12 @@ Quaternion::Quaternion(float* array) set(array); } -Quaternion::Quaternion(const Matrix& m) +Quaternion::Quaternion(const Mat4& m) { set(m); } -Quaternion::Quaternion(const Vector3& axis, float angle) +Quaternion::Quaternion(const Vec3& axis, float angle) { set(axis, angle); } @@ -79,19 +79,19 @@ bool Quaternion::isZero() const return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f; } -void Quaternion::createFromRotationMatrix(const Matrix& m, Quaternion* dst) +void Quaternion::createFromRotationMatrix(const Mat4& m, Quaternion* dst) { m.getRotation(dst); } -void Quaternion::createFromAxisAngle(const Vector3& axis, float angle, Quaternion* dst) +void Quaternion::createFromAxisAngle(const Vec3& axis, float angle, Quaternion* dst) { GP_ASSERT(dst); float halfAngle = angle * 0.5f; float sinHalfAngle = sinf(halfAngle); - Vector3 normal(axis); + Vec3 normal(axis); normal.normalize(); dst->x = normal.x * sinHalfAngle; dst->y = normal.y * sinHalfAngle; @@ -212,12 +212,12 @@ void Quaternion::set(float* array) w = array[3]; } -void Quaternion::set(const Matrix& m) +void Quaternion::set(const Mat4& m) { Quaternion::createFromRotationMatrix(m, this); } -void Quaternion::set(const Vector3& axis, float angle) +void Quaternion::set(const Vec3& axis, float angle) { Quaternion::createFromAxisAngle(axis, angle, this); } @@ -238,7 +238,7 @@ void Quaternion::setIdentity() w = 1.0f; } -float Quaternion::toAxisAngle(Vector3* axis) const +float Quaternion::toAxisAngle(Vec3* axis) const { GP_ASSERT(axis); diff --git a/cocos/math/Quaternion.h b/cocos/math/Quaternion.h index 502b99bf1b..73a7163807 100644 --- a/cocos/math/Quaternion.h +++ b/cocos/math/Quaternion.h @@ -27,7 +27,7 @@ NS_CC_MATH_BEGIN -class Matrix; +class Mat4; /** * Defines a 4-element quaternion that represents the orientation of an object in space. @@ -108,7 +108,7 @@ public: * * @param m The matrix. */ - Quaternion(const Matrix& m); + Quaternion(const Mat4& m); /** * Constructs a quaternion equal to the rotation from the specified axis and angle. @@ -116,7 +116,7 @@ public: * @param axis A vector describing the axis of rotation. * @param angle The angle of rotation (in radians). */ - Quaternion(const Vector3& axis, float angle); + Quaternion(const Vec3& axis, float angle); /** * Constructs a new quaternion that is a copy of the specified one. @@ -165,7 +165,7 @@ public: * @param m The matrix. * @param dst A quaternion to store the conjugate in. */ - static void createFromRotationMatrix(const Matrix& m, Quaternion* dst); + static void createFromRotationMatrix(const Mat4& m, Quaternion* dst); /** * Creates this quaternion equal to the rotation from the specified axis and angle @@ -175,7 +175,7 @@ public: * @param angle The angle of rotation (in radians). * @param dst A quaternion to store the conjugate in. */ - static void createFromAxisAngle(const Vector3& axis, float angle, Quaternion* dst); + static void createFromAxisAngle(const Vec3& axis, float angle, Quaternion* dst); /** * Sets this quaternion to the conjugate of itself. @@ -272,7 +272,7 @@ public: * * @param m The matrix. */ - void set(const Matrix& m); + void set(const Mat4& m); /** * Sets the quaternion equal to the rotation from the specified axis and angle. @@ -280,7 +280,7 @@ public: * @param axis The axis of rotation. * @param angle The angle of rotation (in radians). */ - void set(const Vector3& axis, float angle); + void set(const Vec3& axis, float angle); /** * Sets the elements of this quaternion to a copy of the specified quaternion. @@ -297,11 +297,11 @@ public: /** * Converts this Quaternion4f to axis-angle notation. The axis is normalized. * - * @param e The Vector3f which stores the axis. + * @param e The Vec3f which stores the axis. * * @return The angle (in radians). */ - float toAxisAngle(Vector3* e) const; + float toAxisAngle(Vec3* e) const; /** * Interpolates between two quaternions using linear interpolation. diff --git a/cocos/math/Vector2.cpp b/cocos/math/Vector2.cpp index 3cde513e31..0b0df415cd 100644 --- a/cocos/math/Vector2.cpp +++ b/cocos/math/Vector2.cpp @@ -18,9 +18,9 @@ This file was modified to fit the cocos2d-x project */ -#include "Vector2.h" +#include "math/Vector2.h" +#include "math/MathUtil.h" #include "base/ccMacros.h" -#include "MathUtil.h" NS_CC_MATH_BEGIN @@ -62,63 +62,63 @@ bool isOneDimensionSegmentOverlap(float A, float B, float C, float D, float *S, } // cross procuct of 2 vector. A->B X C->D -float crossProduct2Vector(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D) +float crossProduct2Vector(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D) { return (D.y - C.y) * (B.x - A.x) - (D.x - C.x) * (B.y - A.y); } -Vector2::Vector2() +Vec2::Vec2() : x(0.0f), y(0.0f) { } -Vector2::Vector2(float xx, float yy) +Vec2::Vec2(float xx, float yy) : x(xx), y(yy) { } -Vector2::Vector2(const float* array) +Vec2::Vec2(const float* array) { set(array); } -Vector2::Vector2(const Vector2& p1, const Vector2& p2) +Vec2::Vec2(const Vec2& p1, const Vec2& p2) { set(p1, p2); } -Vector2::Vector2(const Vector2& copy) +Vec2::Vec2(const Vec2& copy) { set(copy); } -Vector2::~Vector2() +Vec2::~Vec2() { } -bool Vector2::isZero() const +bool Vec2::isZero() const { return x == 0.0f && y == 0.0f; } -bool Vector2::isOne() const +bool Vec2::isOne() const { return x == 1.0f && y == 1.0f; } -float Vector2::angle(const Vector2& v1, const Vector2& v2) +float Vec2::angle(const Vec2& v1, const Vec2& v2) { float dz = v1.x * v2.y - v1.y * v2.x; return atan2f(fabsf(dz) + MATH_FLOAT_SMALL, dot(v1, v2)); } -void Vector2::add(const Vector2& v) +void Vec2::add(const Vec2& v) { x += v.x; y += v.y; } -void Vector2::add(const Vector2& v1, const Vector2& v2, Vector2* dst) +void Vec2::add(const Vec2& v1, const Vec2& v2, Vec2* dst) { GP_ASSERT(dst); @@ -126,7 +126,7 @@ void Vector2::add(const Vector2& v1, const Vector2& v2, Vector2* dst) dst->y = v1.y + v2.y; } -void Vector2::clamp(const Vector2& min, const Vector2& max) +void Vec2::clamp(const Vec2& min, const Vec2& max) { GP_ASSERT(!(min.x > max.x || min.y > max.y )); @@ -143,7 +143,7 @@ void Vector2::clamp(const Vector2& min, const Vector2& max) y = max.y; } -void Vector2::clamp(const Vector2& v, const Vector2& min, const Vector2& max, Vector2* dst) +void Vec2::clamp(const Vec2& v, const Vec2& min, const Vec2& max, Vec2* dst) { GP_ASSERT(dst); GP_ASSERT(!(min.x > max.x || min.y > max.y )); @@ -163,7 +163,7 @@ void Vector2::clamp(const Vector2& v, const Vector2& min, const Vector2& max, Ve dst->y = max.y; } -float Vector2::distance(const Vector2& v) const +float Vec2::distance(const Vec2& v) const { float dx = v.x - x; float dy = v.y - y; @@ -171,40 +171,40 @@ float Vector2::distance(const Vector2& v) const return sqrt(dx * dx + dy * dy); } -float Vector2::distanceSquared(const Vector2& v) const +float Vec2::distanceSquared(const Vec2& v) const { float dx = v.x - x; float dy = v.y - y; return (dx * dx + dy * dy); } -float Vector2::dot(const Vector2& v) const +float Vec2::dot(const Vec2& v) const { return (x * v.x + y * v.y); } -float Vector2::dot(const Vector2& v1, const Vector2& v2) +float Vec2::dot(const Vec2& v1, const Vec2& v2) { return (v1.x * v2.x + v1.y * v2.y); } -float Vector2::length() const +float Vec2::length() const { return sqrt(x * x + y * y); } -float Vector2::lengthSquared() const +float Vec2::lengthSquared() const { return (x * x + y * y); } -void Vector2::negate() +void Vec2::negate() { x = -x; y = -y; } -void Vector2::normalize() +void Vec2::normalize() { float n = x * x + y * y; // Already normalized. @@ -221,26 +221,26 @@ void Vector2::normalize() y *= n; } -Vector2 Vector2::getNormalized() const +Vec2 Vec2::getNormalized() const { - Vector2 v(*this); + Vec2 v(*this); v.normalize(); return v; } -void Vector2::scale(float scalar) +void Vec2::scale(float scalar) { x *= scalar; y *= scalar; } -void Vector2::scale(const Vector2& scale) +void Vec2::scale(const Vec2& scale) { x *= scale.x; y *= scale.y; } -void Vector2::rotate(const Vector2& point, float angle) +void Vec2::rotate(const Vec2& point, float angle) { double sinAngle = sin(angle); double cosAngle = cos(angle); @@ -261,13 +261,13 @@ void Vector2::rotate(const Vector2& point, float angle) } } -void Vector2::set(float xx, float yy) +void Vec2::set(float xx, float yy) { this->x = xx; this->y = yy; } -void Vector2::set(const float* array) +void Vec2::set(const float* array) { GP_ASSERT(array); @@ -275,25 +275,25 @@ void Vector2::set(const float* array) y = array[1]; } -void Vector2::set(const Vector2& v) +void Vec2::set(const Vec2& v) { this->x = v.x; this->y = v.y; } -void Vector2::set(const Vector2& p1, const Vector2& p2) +void Vec2::set(const Vec2& p1, const Vec2& p2) { x = p2.x - p1.x; y = p2.y - p1.y; } -void Vector2::subtract(const Vector2& v) +void Vec2::subtract(const Vec2& v) { x -= v.x; y -= v.y; } -void Vector2::subtract(const Vector2& v1, const Vector2& v2, Vector2* dst) +void Vec2::subtract(const Vec2& v1, const Vec2& v2, Vec2* dst) { GP_ASSERT(dst); @@ -301,7 +301,7 @@ void Vector2::subtract(const Vector2& v1, const Vector2& v2, Vector2* dst) dst->y = v1.y - v2.y; } -void Vector2::smooth(const Vector2& target, float elapsedTime, float responseTime) +void Vec2::smooth(const Vec2& target, float elapsedTime, float responseTime) { if (elapsedTime > 0) { @@ -309,19 +309,19 @@ void Vector2::smooth(const Vector2& target, float elapsedTime, float responseTim } } -void Vector2::setPoint(float xx, float yy) +void Vec2::setPoint(float xx, float yy) { this->x = xx; this->y = yy; } -bool Vector2::equals(const Vector2& target) const +bool Vec2::equals(const Vec2& target) const { return (fabs(this->x - target.x) < FLT_EPSILON) && (fabs(this->y - target.y) < FLT_EPSILON); } -bool Vector2::fuzzyEquals(const Vector2& b, float var) const +bool Vec2::fuzzyEquals(const Vec2& b, float var) const { if(x - var <= b.x && b.x <= x + var) if(y - var <= b.y && b.y <= y + var) @@ -329,22 +329,22 @@ bool Vector2::fuzzyEquals(const Vector2& b, float var) const return false; } -float Vector2::getAngle(const Vector2& other) const +float Vec2::getAngle(const Vec2& other) const { - Vector2 a2 = getNormalized(); - Vector2 b2 = other.getNormalized(); + Vec2 a2 = getNormalized(); + Vec2 b2 = other.getNormalized(); float angle = atan2f(a2.cross(b2), a2.dot(b2)); if( fabs(angle) < FLT_EPSILON ) return 0.f; return angle; } -Vector2 Vector2::rotateByAngle(const Vector2& pivot, float angle) const +Vec2 Vec2::rotateByAngle(const Vec2& pivot, float angle) const { - return pivot + (*this - pivot).rotate(Vector2::forAngle(angle)); + return pivot + (*this - pivot).rotate(Vec2::forAngle(angle)); } -bool Vector2::isLineIntersect(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D, +bool Vec2::isLineIntersect(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D, float *S, float *T) { // FAIL: Line undefined @@ -367,8 +367,8 @@ bool Vector2::isLineIntersect(const Vector2& A, const Vector2& B, return true; } -bool Vector2::isLineParallel(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D) +bool Vec2::isLineParallel(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D) { // FAIL: Line undefined if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) @@ -390,8 +390,8 @@ bool Vector2::isLineParallel(const Vector2& A, const Vector2& B, return false; } -bool Vector2::isLineOverlap(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D) +bool Vec2::isLineOverlap(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D) { // FAIL: Line undefined if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) @@ -408,7 +408,7 @@ bool Vector2::isLineOverlap(const Vector2& A, const Vector2& B, return false; } -bool Vector2::isSegmentOverlap(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D, Vector2* S, Vector2* E) +bool Vec2::isSegmentOverlap(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D, Vec2* S, Vec2* E) { if (isLineOverlap(A, B, C, D)) @@ -420,7 +420,7 @@ bool Vector2::isSegmentOverlap(const Vector2& A, const Vector2& B, const Vector2 return false; } -bool Vector2::isSegmentIntersect(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D) +bool Vec2::isSegmentIntersect(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D) { float S, T; @@ -433,34 +433,34 @@ bool Vector2::isSegmentIntersect(const Vector2& A, const Vector2& B, const Vecto return false; } -Vector2 Vector2::getIntersectPoint(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D) +Vec2 Vec2::getIntersectPoint(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D) { float S, T; if (isLineIntersect(A, B, C, D, &S, &T)) { - // Vector2 of intersection - Vector2 P; + // Vec2 of intersection + Vec2 P; P.x = A.x + S * (B.x - A.x); P.y = A.y + S * (B.y - A.y); return P; } - return Vector2::ZERO; + return Vec2::ZERO; } -const Vector2 Vector2::ZERO = Vector2(0.0f, 0.0f); -const Vector2 Vector2::ONE = Vector2(1.0f, 1.0f); -const Vector2 Vector2::UNIT_X = Vector2(1.0f, 0.0f); -const Vector2 Vector2::UNIT_Y = Vector2(0.0f, 1.0f); -const Vector2 Vector2::ANCHOR_MIDDLE = Vector2(0.5f, 0.5f); -const Vector2 Vector2::ANCHOR_BOTTOM_LEFT = Vector2(0.0f, 0.0f); -const Vector2 Vector2::ANCHOR_TOP_LEFT = Vector2(0.0f, 1.0f); -const Vector2 Vector2::ANCHOR_BOTTOM_RIGHT = Vector2(1.0f, 0.0f); -const Vector2 Vector2::ANCHOR_TOP_RIGHT = Vector2(1.0f, 1.0f); -const Vector2 Vector2::ANCHOR_MIDDLE_RIGHT = Vector2(1.0f, 0.5f); -const Vector2 Vector2::ANCHOR_MIDDLE_LEFT = Vector2(0.0f, 0.5f); -const Vector2 Vector2::ANCHOR_MIDDLE_TOP = Vector2(0.5f, 1.0f); -const Vector2 Vector2::ANCHOR_MIDDLE_BOTTOM = Vector2(0.5f, 0.0f); +const Vec2 Vec2::ZERO = Vec2(0.0f, 0.0f); +const Vec2 Vec2::ONE = Vec2(1.0f, 1.0f); +const Vec2 Vec2::UNIT_X = Vec2(1.0f, 0.0f); +const Vec2 Vec2::UNIT_Y = Vec2(0.0f, 1.0f); +const Vec2 Vec2::ANCHOR_MIDDLE = Vec2(0.5f, 0.5f); +const Vec2 Vec2::ANCHOR_BOTTOM_LEFT = Vec2(0.0f, 0.0f); +const Vec2 Vec2::ANCHOR_TOP_LEFT = Vec2(0.0f, 1.0f); +const Vec2 Vec2::ANCHOR_BOTTOM_RIGHT = Vec2(1.0f, 0.0f); +const Vec2 Vec2::ANCHOR_TOP_RIGHT = Vec2(1.0f, 1.0f); +const Vec2 Vec2::ANCHOR_MIDDLE_RIGHT = Vec2(1.0f, 0.5f); +const Vec2 Vec2::ANCHOR_MIDDLE_LEFT = Vec2(0.0f, 0.5f); +const Vec2 Vec2::ANCHOR_MIDDLE_TOP = Vec2(0.5f, 1.0f); +const Vec2 Vec2::ANCHOR_MIDDLE_BOTTOM = Vec2(0.5f, 0.0f); NS_CC_MATH_END diff --git a/cocos/math/Vector2.h b/cocos/math/Vector2.h index 731d19e04e..0b5d9cb9c7 100644 --- a/cocos/math/Vector2.h +++ b/cocos/math/Vector2.h @@ -18,12 +18,13 @@ This file was modified to fit the cocos2d-x project */ -#ifndef VECTOR2_H_ -#define VECTOR2_H_ +#ifndef MATH_VEC2_H +#define MATH_VEC2_H -#include "CCMathBase.h" -#include "base/CCPlatformMacros.h" -#include "base/ccMacros.h" +#include +#include +#include +#include "math/CCMathBase.h" NS_CC_MATH_BEGIN @@ -33,17 +34,17 @@ NS_CC_MATH_BEGIN inline float clampf(float value, float min_inclusive, float max_inclusive) { if (min_inclusive > max_inclusive) { - CC_SWAP(min_inclusive, max_inclusive, float); + std::swap(min_inclusive, max_inclusive); } return value < min_inclusive ? min_inclusive : value < max_inclusive? value : max_inclusive; } -class Matrix; +class Mat4; /** * Defines a 2-element floating point vector. */ -class Vector2 +class Vec2 { public: @@ -60,7 +61,7 @@ public: /** * Constructs a new vector initialized to all zeros. */ - Vector2(); + Vec2(); /** * Constructs a new vector initialized to the specified values. @@ -68,14 +69,14 @@ public: * @param xx The x coordinate. * @param yy The y coordinate. */ - Vector2(float xx, float yy); + Vec2(float xx, float yy); /** * Constructs a new vector from the values in the specified array. * * @param array An array containing the elements of the vector in the order x, y. */ - Vector2(const float* array); + Vec2(const float* array); /** * Constructs a vector that describes the direction between the specified points. @@ -83,19 +84,19 @@ public: * @param p1 The first point. * @param p2 The second point. */ - Vector2(const Vector2& p1, const Vector2& p2); + Vec2(const Vec2& p1, const Vec2& p2); /** * Constructs a new vector that is a copy of the specified vector. * * @param copy The vector to copy. */ - Vector2(const Vector2& copy); + Vec2(const Vec2& copy); /** * Destructor. */ - ~Vector2(); + ~Vec2(); /** * Indicates whether this vector contains all zeros. @@ -119,14 +120,14 @@ public: * * @return The angle between the two vectors (in radians). */ - static float angle(const Vector2& v1, const Vector2& v2); + static float angle(const Vec2& v1, const Vec2& v2); /** * Adds the elements of the specified vector to this one. * * @param v The vector to add. */ - void add(const Vector2& v); + void add(const Vec2& v); /** * Adds the specified vectors and stores the result in dst. @@ -135,7 +136,7 @@ public: * @param v2 The second vector. * @param dst A vector to store the result in. */ - static void add(const Vector2& v1, const Vector2& v2, Vector2* dst); + static void add(const Vec2& v1, const Vec2& v2, Vec2* dst); /** * Clamps this vector within the specified range. @@ -143,7 +144,7 @@ public: * @param min The minimum value. * @param max The maximum value. */ - void clamp(const Vector2& min, const Vector2& max); + void clamp(const Vec2& min, const Vec2& max); /** * Clamps the specified vector within the specified range and returns it in dst. @@ -153,7 +154,7 @@ public: * @param max The maximum value. * @param dst A vector to store the result in. */ - static void clamp(const Vector2& v, const Vector2& min, const Vector2& max, Vector2* dst); + static void clamp(const Vec2& v, const Vec2& min, const Vec2& max, Vec2* dst); /** * Returns the distance between this vector and v. @@ -164,7 +165,7 @@ public: * * @see distanceSquared */ - float distance(const Vector2& v) const; + float distance(const Vec2& v) const; /** * Returns the squared distance between this vector and v. @@ -180,7 +181,7 @@ public: * * @see distance */ - float distanceSquared(const Vector2& v) const; + float distanceSquared(const Vec2& v) const; /** * Returns the dot product of this vector and the specified vector. @@ -189,7 +190,7 @@ public: * * @return The dot product. */ - float dot(const Vector2& v) const; + float dot(const Vec2& v) const; /** * Returns the dot product between the specified vectors. @@ -199,7 +200,7 @@ public: * * @return The dot product between the vectors. */ - static float dot(const Vector2& v1, const Vector2& v2); + static float dot(const Vec2& v1, const Vec2& v2); /** * Computes the length of this vector. @@ -232,7 +233,7 @@ public: /** * Normalizes this vector. * - * This method normalizes this Vector2 so that it is of + * This method normalizes this Vec2 so that it is of * unit length (in other words, the length of the vector * after calling this method will be 1.0f). If the vector * already has unit length or if the length of the vector @@ -251,7 +252,7 @@ public: * * @param dst The destination vector. */ - Vector2 getNormalized() const; + Vec2 getNormalized() const; /** * Scales all elements of this vector by the specified value. @@ -265,7 +266,7 @@ public: * * @param scale The vector to scale by. */ - void scale(const Vector2& scale); + void scale(const Vec2& scale); /** * Rotates this vector by angle (specified in radians) around the given point. @@ -273,7 +274,7 @@ public: * @param point The point to rotate around. * @param angle The angle to rotate by (in radians). */ - void rotate(const Vector2& point, float angle); + void rotate(const Vec2& point, float angle); /** * Sets the elements of this vector to the specified values. @@ -295,7 +296,7 @@ public: * * @param v The vector to copy. */ - void set(const Vector2& v); + void set(const Vec2& v); /** * Sets this vector to the directional vector between the specified points. @@ -303,7 +304,7 @@ public: * @param p1 The first point. * @param p2 The second point. */ - void set(const Vector2& p1, const Vector2& p2); + void set(const Vec2& p1, const Vec2& p2); /** * Subtracts this vector and the specified vector as (this - v) @@ -311,7 +312,7 @@ public: * * @param v The vector to subtract. */ - void subtract(const Vector2& v); + void subtract(const Vec2& v); /** * Subtracts the specified vectors and stores the result in dst. @@ -321,7 +322,7 @@ public: * @param v2 The second vector. * @param dst The destination vector. */ - static void subtract(const Vector2& v1, const Vector2& v2, Vector2* dst); + static void subtract(const Vec2& v1, const Vec2& v2, Vec2* dst); /** * Updates this vector towards the given target using a smoothing function. @@ -334,7 +335,7 @@ public: * @param elapsedTime elapsed time between calls. * @param responseTime response time (in the same units as elapsedTime). */ - void smooth(const Vector2& target, float elapsedTime, float responseTime); + void smooth(const Vec2& target, float elapsedTime, float responseTime); /** * Calculates the sum of this vector with the given vector. @@ -344,7 +345,7 @@ public: * @param v The vector to add. * @return The vector sum. */ - inline const Vector2 operator+(const Vector2& v) const; + inline const Vec2 operator+(const Vec2& v) const; /** * Adds the given vector to this vector. @@ -352,7 +353,7 @@ public: * @param v The vector to add. * @return This vector, after the addition occurs. */ - inline Vector2& operator+=(const Vector2& v); + inline Vec2& operator+=(const Vec2& v); /** * Calculates the sum of this vector with the given vector. @@ -362,7 +363,7 @@ public: * @param v The vector to add. * @return The vector sum. */ - inline const Vector2 operator-(const Vector2& v) const; + inline const Vec2 operator-(const Vec2& v) const; /** * Subtracts the given vector from this vector. @@ -370,7 +371,7 @@ public: * @param v The vector to subtract. * @return This vector, after the subtraction occurs. */ - inline Vector2& operator-=(const Vector2& v); + inline Vec2& operator-=(const Vec2& v); /** * Calculates the negation of this vector. @@ -379,7 +380,7 @@ public: * * @return The negation of this vector. */ - inline const Vector2 operator-() const; + inline const Vec2 operator-() const; /** * Calculates the scalar product of this vector with the given value. @@ -389,7 +390,7 @@ public: * @param s The value to scale by. * @return The scaled vector. */ - inline const Vector2 operator*(float s) const; + inline const Vec2 operator*(float s) const; /** * Scales this vector by the given value. @@ -397,7 +398,7 @@ public: * @param s The value to scale by. * @return This vector, after the scale occurs. */ - inline Vector2& operator*=(float s); + inline Vec2& operator*=(float s); /** * Returns the components of this vector divided by the given constant @@ -407,7 +408,7 @@ public: * @param s the constant to divide this vector with * @return a smaller vector */ - inline const Vector2 operator/(float s) const; + inline const Vec2 operator/(float s) const; /** * Determines if this vector is less than the given vector. @@ -416,7 +417,7 @@ public: * * @return True if this vector is less than the given vector, false otherwise. */ - inline bool operator<(const Vector2& v) const; + inline bool operator<(const Vec2& v) const; /** * Determines if this vector is equal to the given vector. @@ -425,7 +426,7 @@ public: * * @return True if this vector is equal to the given vector, false otherwise. */ - inline bool operator==(const Vector2& v) const; + inline bool operator==(const Vec2& v) const; /** * Determines if this vector is not equal to the given vector. @@ -434,7 +435,7 @@ public: * * @return True if this vector is not equal to the given vector, false otherwise. */ - inline bool operator!=(const Vector2& v) const; + inline bool operator!=(const Vec2& v) const; //code added compatible for Point public: @@ -446,14 +447,14 @@ public: /** * @js NA */ - bool equals(const Vector2& target) const; + bool equals(const Vec2& target) const; /** @returns if points have fuzzy equality which means equal with some degree of variance. @since v2.1.4 * @js NA * @lua NA */ - bool fuzzyEquals(const Vector2& target, float variance) const; + bool fuzzyEquals(const Vec2& target, float variance) const; /** Calculates distance between point an origin @return float @@ -465,7 +466,7 @@ public: return sqrtf(x*x + y*y); }; - /** Calculates the square length of a Vector2 (not calling sqrt() ) + /** Calculates the square length of a Vec2 (not calling sqrt() ) @return float @since v2.1.4 * @js NA @@ -481,7 +482,7 @@ public: * @js NA * @lua NA */ - inline float getDistanceSq(const Vector2& other) const { + inline float getDistanceSq(const Vec2& other) const { return (*this - other).getLengthSq(); }; @@ -491,7 +492,7 @@ public: * @js NA * @lua NA */ - inline float getDistance(const Vector2& other) const { + inline float getDistance(const Vec2& other) const { return (*this - other).getLength(); }; @@ -509,7 +510,7 @@ public: * @js NA * @lua NA */ - float getAngle(const Vector2& other) const; + float getAngle(const Vec2& other) const; /** Calculates cross product of two points. @return float @@ -517,29 +518,29 @@ public: * @js NA * @lua NA */ - inline float cross(const Vector2& other) const { + inline float cross(const Vec2& other) const { return x*other.y - y*other.x; }; /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 - @return Vector2 + @return Vec2 @since v2.1.4 * @js NA * @lua NA */ - inline Vector2 getPerp() const { - return Vector2(-y, x); + inline Vec2 getPerp() const { + return Vec2(-y, x); }; /** Calculates midpoint between two points. - @return Vector2 + @return Vec2 @since v3.0 * @js NA * @lua NA */ - inline Vector2 getMidpoint(const Vector2& other) const + inline Vec2 getMidpoint(const Vec2& other) const { - return Vector2((x + other.x) / 2.0f, (y + other.y) / 2.0f); + return Vec2((x + other.x) / 2.0f, (y + other.y) / 2.0f); } /** Clamp a point between from and to. @@ -547,9 +548,9 @@ public: * @js NA * @lua NA */ - inline Vector2 getClampPoint(const Vector2& min_inclusive, const Vector2& max_inclusive) const + inline Vec2 getClampPoint(const Vec2& min_inclusive, const Vec2& max_inclusive) const { - return Vector2(clampf(x,min_inclusive.x,max_inclusive.x), clampf(y, min_inclusive.y, max_inclusive.y)); + return Vec2(clampf(x,min_inclusive.x,max_inclusive.x), clampf(y, min_inclusive.y, max_inclusive.y)); } /** Run a math operation function on each point component @@ -561,51 +562,51 @@ public: * @js NA * @lua NA */ - inline Vector2 compOp(std::function function) const + inline Vec2 compOp(std::function function) const { - return Vector2(function(x), function(y)); + return Vec2(function(x), function(y)); } /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 - @return Vector2 + @return Vec2 @since v2.1.4 * @js NA * @lua NA */ - inline Vector2 getRPerp() const { - return Vector2(y, -x); + inline Vec2 getRPerp() const { + return Vec2(y, -x); }; /** Calculates the projection of this over other. - @return Vector2 + @return Vec2 @since v2.1.4 * @js NA * @lua NA */ - inline Vector2 project(const Vector2& other) const { + inline Vec2 project(const Vec2& other) const { return other * (dot(other)/other.dot(other)); }; /** Complex multiplication of two points ("rotates" two points). - @return Vector2 vector with an angle of this.getAngle() + other.getAngle(), + @return Vec2 vector with an angle of this.getAngle() + other.getAngle(), and a length of this.getLength() * other.getLength(). @since v2.1.4 * @js NA * @lua NA */ - inline Vector2 rotate(const Vector2& other) const { - return Vector2(x*other.x - y*other.y, x*other.y + y*other.x); + inline Vec2 rotate(const Vec2& other) const { + return Vec2(x*other.x - y*other.y, x*other.y + y*other.x); }; /** Unrotates two points. - @return Vector2 vector with an angle of this.getAngle() - other.getAngle(), + @return Vec2 vector with an angle of this.getAngle() - other.getAngle(), and a length of this.getLength() * other.getLength(). @since v2.1.4 * @js NA * @lua NA */ - inline Vector2 unrotate(const Vector2& other) const { - return Vector2(x*other.x + y*other.y, y*other.x - x*other.y); + inline Vec2 unrotate(const Vec2& other) const { + return Vec2(x*other.x + y*other.y, y*other.x - x*other.y); }; /** Linear Interpolation between two points a and b @@ -617,7 +618,7 @@ public: * @js NA * @lua NA */ - inline Vector2 lerp(const Vector2& other, float alpha) const { + inline Vec2 lerp(const Vec2& other, float alpha) const { return *this * (1.f - alpha) + other * alpha; }; @@ -629,15 +630,15 @@ public: * @js NA * @lua NA */ - Vector2 rotateByAngle(const Vector2& pivot, float angle) const; + Vec2 rotateByAngle(const Vec2& pivot, float angle) const; /** * @js NA * @lua NA */ - static inline Vector2 forAngle(const float a) + static inline Vec2 forAngle(const float a) { - return Vector2(cosf(a), sinf(a)); + return Vec2(cosf(a), sinf(a)); } /** A general line-line intersection test @@ -657,8 +658,8 @@ public: * @js NA * @lua NA */ - static bool isLineIntersect(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D, + static bool isLineIntersect(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D, float *S = nullptr, float *T = nullptr); /** @@ -667,8 +668,8 @@ public: * @js NA * @lua NA */ - static bool isLineOverlap(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D); + static bool isLineOverlap(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D); /** returns true if Line A-B parallel with segment C-D @@ -676,8 +677,8 @@ public: * @js NA * @lua NA */ - static bool isLineParallel(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D); + static bool isLineParallel(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D); /** returns true if Segment A-B overlap with segment C-D @@ -685,9 +686,9 @@ public: * @js NA * @lua NA */ - static bool isSegmentOverlap(const Vector2& A, const Vector2& B, - const Vector2& C, const Vector2& D, - Vector2* S = nullptr, Vector2* E = nullptr); + static bool isSegmentOverlap(const Vec2& A, const Vec2& B, + const Vec2& C, const Vec2& D, + Vec2* S = nullptr, Vec2* E = nullptr); /** returns true if Segment A-B intersects with segment C-D @@ -695,7 +696,7 @@ public: * @js NA * @lua NA */ - static bool isSegmentIntersect(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D); + static bool isSegmentIntersect(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D); /** returns the intersection point of line A-B, C-D @@ -703,34 +704,34 @@ public: * @js NA * @lua NA */ - static Vector2 getIntersectPoint(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& D); + static Vec2 getIntersectPoint(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D); - /** equals to Vector2(0,0) */ - static const Vector2 ZERO; - /** equals to Vector2(1,1) */ - static const Vector2 ONE; - /** equals to Vector2(1,0) */ - static const Vector2 UNIT_X; - /** equals to Vector2(0,1) */ - static const Vector2 UNIT_Y; - /** equals to Vector2(0.5, 0.5) */ - static const Vector2 ANCHOR_MIDDLE; - /** equals to Vector2(0, 0) */ - static const Vector2 ANCHOR_BOTTOM_LEFT; - /** equals to Vector2(0, 1) */ - static const Vector2 ANCHOR_TOP_LEFT; - /** equals to Vector2(1, 0) */ - static const Vector2 ANCHOR_BOTTOM_RIGHT; - /** equals to Vector2(1, 1) */ - static const Vector2 ANCHOR_TOP_RIGHT; - /** equals to Vector2(1, 0.5) */ - static const Vector2 ANCHOR_MIDDLE_RIGHT; - /** equals to Vector2(0, 0.5) */ - static const Vector2 ANCHOR_MIDDLE_LEFT; - /** equals to Vector2(0.5, 1) */ - static const Vector2 ANCHOR_MIDDLE_TOP; - /** equals to Vector2(0.5, 0) */ - static const Vector2 ANCHOR_MIDDLE_BOTTOM; + /** equals to Vec2(0,0) */ + static const Vec2 ZERO; + /** equals to Vec2(1,1) */ + static const Vec2 ONE; + /** equals to Vec2(1,0) */ + static const Vec2 UNIT_X; + /** equals to Vec2(0,1) */ + static const Vec2 UNIT_Y; + /** equals to Vec2(0.5, 0.5) */ + static const Vec2 ANCHOR_MIDDLE; + /** equals to Vec2(0, 0) */ + static const Vec2 ANCHOR_BOTTOM_LEFT; + /** equals to Vec2(0, 1) */ + static const Vec2 ANCHOR_TOP_LEFT; + /** equals to Vec2(1, 0) */ + static const Vec2 ANCHOR_BOTTOM_RIGHT; + /** equals to Vec2(1, 1) */ + static const Vec2 ANCHOR_TOP_RIGHT; + /** equals to Vec2(1, 0.5) */ + static const Vec2 ANCHOR_MIDDLE_RIGHT; + /** equals to Vec2(0, 0.5) */ + static const Vec2 ANCHOR_MIDDLE_LEFT; + /** equals to Vec2(0.5, 1) */ + static const Vec2 ANCHOR_MIDDLE_TOP; + /** equals to Vec2(0.5, 0) */ + static const Vec2 ANCHOR_MIDDLE_BOTTOM; }; /** @@ -740,12 +741,12 @@ public: * @param v The vector to scale. * @return The scaled vector. */ -inline const Vector2 operator*(float x, const Vector2& v); +inline const Vec2 operator*(float x, const Vec2& v); -typedef Vector2 Point2; +typedef Vec2 Point2; NS_CC_MATH_END #include "Vector2.inl" -#endif +#endif // MATH_VEC2_H diff --git a/cocos/math/Vector2.inl b/cocos/math/Vector2.inl index 5576b976cc..9108765efc 100644 --- a/cocos/math/Vector2.inl +++ b/cocos/math/Vector2.inl @@ -22,58 +22,58 @@ NS_CC_MATH_BEGIN -inline const Vector2 Vector2::operator+(const Vector2& v) const +inline const Vec2 Vec2::operator+(const Vec2& v) const { - Vector2 result(*this); + Vec2 result(*this); result.add(v); return result; } -inline Vector2& Vector2::operator+=(const Vector2& v) +inline Vec2& Vec2::operator+=(const Vec2& v) { add(v); return *this; } -inline const Vector2 Vector2::operator-(const Vector2& v) const +inline const Vec2 Vec2::operator-(const Vec2& v) const { - Vector2 result(*this); + Vec2 result(*this); result.subtract(v); return result; } -inline Vector2& Vector2::operator-=(const Vector2& v) +inline Vec2& Vec2::operator-=(const Vec2& v) { subtract(v); return *this; } -inline const Vector2 Vector2::operator-() const +inline const Vec2 Vec2::operator-() const { - Vector2 result(*this); + Vec2 result(*this); result.negate(); return result; } -inline const Vector2 Vector2::operator*(float s) const +inline const Vec2 Vec2::operator*(float s) const { - Vector2 result(*this); + Vec2 result(*this); result.scale(s); return result; } -inline Vector2& Vector2::operator*=(float s) +inline Vec2& Vec2::operator*=(float s) { scale(s); return *this; } -inline const Vector2 Vector2::operator/(const float s) const +inline const Vec2 Vec2::operator/(const float s) const { - return Vector2(this->x / s, this->y / s); + return Vec2(this->x / s, this->y / s); } -inline bool Vector2::operator<(const Vector2& v) const +inline bool Vec2::operator<(const Vec2& v) const { if (x == v.x) { @@ -82,19 +82,19 @@ inline bool Vector2::operator<(const Vector2& v) const return x < v.x; } -inline bool Vector2::operator==(const Vector2& v) const +inline bool Vec2::operator==(const Vec2& v) const { return x==v.x && y==v.y; } -inline bool Vector2::operator!=(const Vector2& v) const +inline bool Vec2::operator!=(const Vec2& v) const { return x!=v.x || y!=v.y; } -inline const Vector2 operator*(float x, const Vector2& v) +inline const Vec2 operator*(float x, const Vec2& v) { - Vector2 result(v); + Vec2 result(v); result.scale(x); return result; } diff --git a/cocos/math/Vector3.cpp b/cocos/math/Vector3.cpp index 96656e62fc..766aa822e3 100644 --- a/cocos/math/Vector3.cpp +++ b/cocos/math/Vector3.cpp @@ -24,32 +24,32 @@ NS_CC_MATH_BEGIN -Vector3::Vector3() +Vec3::Vec3() : x(0.0f), y(0.0f), z(0.0f) { } -Vector3::Vector3(float xx, float yy, float zz) +Vec3::Vec3(float xx, float yy, float zz) : x(xx), y(yy), z(zz) { } -Vector3::Vector3(const float* array) +Vec3::Vec3(const float* array) { set(array); } -Vector3::Vector3(const Vector3& p1, const Vector3& p2) +Vec3::Vec3(const Vec3& p1, const Vec3& p2) { set(p1, p2); } -Vector3::Vector3(const Vector3& copy) +Vec3::Vec3(const Vec3& copy) { set(copy); } -Vector3 Vector3::fromColor(unsigned int color) +Vec3 Vec3::fromColor(unsigned int color) { float components[3]; int componentIndex = 0; @@ -60,25 +60,25 @@ Vector3 Vector3::fromColor(unsigned int color) components[componentIndex++] = static_cast(component) / 255.0f; } - Vector3 value(components); + Vec3 value(components); return value; } -Vector3::~Vector3() +Vec3::~Vec3() { } -bool Vector3::isZero() const +bool Vec3::isZero() const { return x == 0.0f && y == 0.0f && z == 0.0f; } -bool Vector3::isOne() const +bool Vec3::isOne() const { return x == 1.0f && y == 1.0f && z == 1.0f; } -float Vector3::angle(const Vector3& v1, const Vector3& v2) +float Vec3::angle(const Vec3& v1, const Vec3& v2) { float dx = v1.y * v2.z - v1.z * v2.y; float dy = v1.z * v2.x - v1.x * v2.z; @@ -87,14 +87,14 @@ float Vector3::angle(const Vector3& v1, const Vector3& v2) return atan2f(sqrt(dx * dx + dy * dy + dz * dz) + MATH_FLOAT_SMALL, dot(v1, v2)); } -void Vector3::add(const Vector3& v) +void Vec3::add(const Vec3& v) { x += v.x; y += v.y; z += v.z; } -void Vector3::add(const Vector3& v1, const Vector3& v2, Vector3* dst) +void Vec3::add(const Vec3& v1, const Vec3& v2, Vec3* dst) { GP_ASSERT(dst); @@ -103,7 +103,7 @@ void Vector3::add(const Vector3& v1, const Vector3& v2, Vector3* dst) dst->z = v1.z + v2.z; } -void Vector3::clamp(const Vector3& min, const Vector3& max) +void Vec3::clamp(const Vec3& min, const Vec3& max) { GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z)); @@ -126,7 +126,7 @@ void Vector3::clamp(const Vector3& min, const Vector3& max) z = max.z; } -void Vector3::clamp(const Vector3& v, const Vector3& min, const Vector3& max, Vector3* dst) +void Vec3::clamp(const Vec3& v, const Vec3& min, const Vec3& max, Vec3* dst) { GP_ASSERT(dst); GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z)); @@ -153,22 +153,22 @@ void Vector3::clamp(const Vector3& v, const Vector3& min, const Vector3& max, Ve dst->z = max.z; } -void Vector3::cross(const Vector3& v) +void Vec3::cross(const Vec3& v) { cross(*this, v, this); } -void Vector3::cross(const Vector3& v1, const Vector3& v2, Vector3* dst) +void Vec3::cross(const Vec3& v1, const Vec3& v2, Vec3* dst) { GP_ASSERT(dst); - // NOTE: This code assumes Vector3 struct members are contiguous floats in memory. + // NOTE: This code assumes Vec3 struct members are contiguous floats in memory. // We might want to revisit this (and other areas of code that make this assumption) // later to guarantee 100% safety/compatibility. - MathUtil::crossVector3(&v1.x, &v2.x, &dst->x); + MathUtil::crossVec3(&v1.x, &v2.x, &dst->x); } -float Vector3::distance(const Vector3& v) const +float Vec3::distance(const Vec3& v) const { float dx = v.x - x; float dy = v.y - y; @@ -177,7 +177,7 @@ float Vector3::distance(const Vector3& v) const return sqrt(dx * dx + dy * dy + dz * dz); } -float Vector3::distanceSquared(const Vector3& v) const +float Vec3::distanceSquared(const Vec3& v) const { float dx = v.x - x; float dy = v.y - y; @@ -186,34 +186,34 @@ float Vector3::distanceSquared(const Vector3& v) const return (dx * dx + dy * dy + dz * dz); } -float Vector3::dot(const Vector3& v) const +float Vec3::dot(const Vec3& v) const { return (x * v.x + y * v.y + z * v.z); } -float Vector3::dot(const Vector3& v1, const Vector3& v2) +float Vec3::dot(const Vec3& v1, const Vec3& v2) { return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z); } -float Vector3::length() const +float Vec3::length() const { return sqrt(x * x + y * y + z * z); } -float Vector3::lengthSquared() const +float Vec3::lengthSquared() const { return (x * x + y * y + z * z); } -void Vector3::negate() +void Vec3::negate() { x = -x; y = -y; z = -z; } -void Vector3::normalize() +void Vec3::normalize() { float n = x * x + y * y + z * z; // Already normalized. @@ -231,28 +231,28 @@ void Vector3::normalize() z *= n; } -Vector3 Vector3::getNormalized() const +Vec3 Vec3::getNormalized() const { - Vector3 v(*this); + Vec3 v(*this); v.normalize(); return v; } -void Vector3::scale(float scalar) +void Vec3::scale(float scalar) { x *= scalar; y *= scalar; z *= scalar; } -void Vector3::set(float xx, float yy, float zz) +void Vec3::set(float xx, float yy, float zz) { this->x = xx; this->y = yy; this->z = zz; } -void Vector3::set(const float* array) +void Vec3::set(const float* array) { GP_ASSERT(array); @@ -261,28 +261,28 @@ void Vector3::set(const float* array) z = array[2]; } -void Vector3::set(const Vector3& v) +void Vec3::set(const Vec3& v) { this->x = v.x; this->y = v.y; this->z = v.z; } -void Vector3::set(const Vector3& p1, const Vector3& p2) +void Vec3::set(const Vec3& p1, const Vec3& p2) { x = p2.x - p1.x; y = p2.y - p1.y; z = p2.z - p1.z; } -void Vector3::subtract(const Vector3& v) +void Vec3::subtract(const Vec3& v) { x -= v.x; y -= v.y; z -= v.z; } -void Vector3::subtract(const Vector3& v1, const Vector3& v2, Vector3* dst) +void Vec3::subtract(const Vec3& v1, const Vec3& v2, Vec3* dst) { GP_ASSERT(dst); @@ -291,7 +291,7 @@ void Vector3::subtract(const Vector3& v1, const Vector3& v2, Vector3* dst) dst->z = v1.z - v2.z; } -void Vector3::smooth(const Vector3& target, float elapsedTime, float responseTime) +void Vec3::smooth(const Vec3& target, float elapsedTime, float responseTime) { if (elapsedTime > 0) { @@ -299,10 +299,10 @@ void Vector3::smooth(const Vector3& target, float elapsedTime, float responseTim } } -const Vector3 Vector3::ZERO = Vector3(0.0f, 0.0f, 0.0f); -const Vector3 Vector3::ONE = Vector3(1.0f, 1.0f, 1.0f); -const Vector3 Vector3::UNIT_X = Vector3(1.0f, 0.0f, 0.0f); -const Vector3 Vector3::UNIT_Y = Vector3(0.0f, 1.0f, 0.0f); -const Vector3 Vector3::UNIT_Z = Vector3(0.0f, 0.0f, 1.0f); +const Vec3 Vec3::ZERO = Vec3(0.0f, 0.0f, 0.0f); +const Vec3 Vec3::ONE = Vec3(1.0f, 1.0f, 1.0f); +const Vec3 Vec3::UNIT_X = Vec3(1.0f, 0.0f, 0.0f); +const Vec3 Vec3::UNIT_Y = Vec3(0.0f, 1.0f, 0.0f); +const Vec3 Vec3::UNIT_Z = Vec3(0.0f, 0.0f, 1.0f); NS_CC_MATH_END diff --git a/cocos/math/Vector3.h b/cocos/math/Vector3.h index 0e1f0a5969..2ebfa8fd88 100644 --- a/cocos/math/Vector3.h +++ b/cocos/math/Vector3.h @@ -18,14 +18,14 @@ This file was modified to fit the cocos2d-x project */ -#ifndef VECTOR3_H_ -#define VECTOR3_H_ +#ifndef MATH_VEC3_H +#define MATH_VEC3_H -#include "CCMathBase.h" +#include "math/CCMathBase.h" NS_CC_MATH_BEGIN -class Matrix; +class Mat4; class Quaternion; /** @@ -37,7 +37,7 @@ class Quaternion; * the magnitude of the vector intact. When used as a point, * the elements of the vector represent a position in 3D space. */ -class Vector3 +class Vec3 { public: @@ -59,7 +59,7 @@ public: /** * Constructs a new vector initialized to all zeros. */ - Vector3(); + Vec3(); /** * Constructs a new vector initialized to the specified values. @@ -68,14 +68,14 @@ public: * @param yy The y coordinate. * @param zz The z coordinate. */ - Vector3(float xx, float yy, float zz); + Vec3(float xx, float yy, float zz); /** * Constructs a new vector from the values in the specified array. * * @param array An array containing the elements of the vector in the order x, y, z. */ - Vector3(const float* array); + Vec3(const float* array); /** * Constructs a vector that describes the direction between the specified points. @@ -83,14 +83,14 @@ public: * @param p1 The first point. * @param p2 The second point. */ - Vector3(const Vector3& p1, const Vector3& p2); + Vec3(const Vec3& p1, const Vec3& p2); /** * Constructs a new vector that is a copy of the specified vector. * * @param copy The vector to copy. */ - Vector3(const Vector3& copy); + Vec3(const Vec3& copy); /** * Creates a new vector from an integer interpreted as an RGB value. @@ -100,12 +100,12 @@ public: * * @return A vector corresponding to the interpreted RGB color. */ - static Vector3 fromColor(unsigned int color); + static Vec3 fromColor(unsigned int color); /** * Destructor. */ - ~Vector3(); + ~Vec3(); /** * Indicates whether this vector contains all zeros. @@ -129,7 +129,7 @@ public: * * @return The angle between the two vectors (in radians). */ - static float angle(const Vector3& v1, const Vector3& v2); + static float angle(const Vec3& v1, const Vec3& v2); /** @@ -137,7 +137,7 @@ public: * * @param v The vector to add. */ - void add(const Vector3& v); + void add(const Vec3& v); /** * Adds the specified vectors and stores the result in dst. @@ -146,7 +146,7 @@ public: * @param v2 The second vector. * @param dst A vector to store the result in. */ - static void add(const Vector3& v1, const Vector3& v2, Vector3* dst); + static void add(const Vec3& v1, const Vec3& v2, Vec3* dst); /** * Clamps this vector within the specified range. @@ -154,7 +154,7 @@ public: * @param min The minimum value. * @param max The maximum value. */ - void clamp(const Vector3& min, const Vector3& max); + void clamp(const Vec3& min, const Vec3& max); /** * Clamps the specified vector within the specified range and returns it in dst. @@ -164,14 +164,14 @@ public: * @param max The maximum value. * @param dst A vector to store the result in. */ - static void clamp(const Vector3& v, const Vector3& min, const Vector3& max, Vector3* dst); + static void clamp(const Vec3& v, const Vec3& min, const Vec3& max, Vec3* dst); /** * Sets this vector to the cross product between itself and the specified vector. * * @param v The vector to compute the cross product with. */ - void cross(const Vector3& v); + void cross(const Vec3& v); /** * Computes the cross product of the specified vectors and stores the result in dst. @@ -180,7 +180,7 @@ public: * @param v2 The second vector. * @param dst A vector to store the result in. */ - static void cross(const Vector3& v1, const Vector3& v2, Vector3* dst); + static void cross(const Vec3& v1, const Vec3& v2, Vec3* dst); /** * Returns the distance between this vector and v. @@ -191,7 +191,7 @@ public: * * @see distanceSquared */ - float distance(const Vector3& v) const; + float distance(const Vec3& v) const; /** * Returns the squared distance between this vector and v. @@ -207,7 +207,7 @@ public: * * @see distance */ - float distanceSquared(const Vector3& v) const; + float distanceSquared(const Vec3& v) const; /** * Returns the dot product of this vector and the specified vector. @@ -216,7 +216,7 @@ public: * * @return The dot product. */ - float dot(const Vector3& v) const; + float dot(const Vec3& v) const; /** * Returns the dot product between the specified vectors. @@ -226,7 +226,7 @@ public: * * @return The dot product between the vectors. */ - static float dot(const Vector3& v1, const Vector3& v2); + static float dot(const Vec3& v1, const Vec3& v2); /** * Computes the length of this vector. @@ -259,7 +259,7 @@ public: /** * Normalizes this vector. * - * This method normalizes this Vector3 so that it is of + * This method normalizes this Vect3 so that it is of * unit length (in other words, the length of the vector * after calling this method will be 1.0f). If the vector * already has unit length or if the length of the vector @@ -278,7 +278,7 @@ public: * * @param dst The destination vector. */ - Vector3 getNormalized() const; + Vec3 getNormalized() const; /** * Scales all elements of this vector by the specified value. @@ -308,12 +308,12 @@ public: * * @param v The vector to copy. */ - void set(const Vector3& v); + void set(const Vec3& v); /** * Sets this vector to the directional vector between the specified points. */ - void set(const Vector3& p1, const Vector3& p2); + void set(const Vec3& p1, const Vec3& p2); /** * Subtracts this vector and the specified vector as (this - v) @@ -321,7 +321,7 @@ public: * * @param v The vector to subtract. */ - void subtract(const Vector3& v); + void subtract(const Vec3& v); /** * Subtracts the specified vectors and stores the result in dst. @@ -331,7 +331,7 @@ public: * @param v2 The second vector. * @param dst The destination vector. */ - static void subtract(const Vector3& v1, const Vector3& v2, Vector3* dst); + static void subtract(const Vec3& v1, const Vec3& v2, Vec3* dst); /** * Updates this vector towards the given target using a smoothing function. @@ -344,7 +344,7 @@ public: * @param elapsedTime elapsed time between calls. * @param responseTime response time (in the same units as elapsedTime). */ - void smooth(const Vector3& target, float elapsedTime, float responseTime); + void smooth(const Vec3& target, float elapsedTime, float responseTime); /** * Calculates the sum of this vector with the given vector. @@ -354,7 +354,7 @@ public: * @param v The vector to add. * @return The vector sum. */ - inline const Vector3 operator+(const Vector3& v) const; + inline const Vec3 operator+(const Vec3& v) const; /** * Adds the given vector to this vector. @@ -362,7 +362,7 @@ public: * @param v The vector to add. * @return This vector, after the addition occurs. */ - inline Vector3& operator+=(const Vector3& v); + inline Vec3& operator+=(const Vec3& v); /** * Calculates the difference of this vector with the given vector. @@ -372,7 +372,7 @@ public: * @param v The vector to subtract. * @return The vector difference. */ - inline const Vector3 operator-(const Vector3& v) const; + inline const Vec3 operator-(const Vec3& v) const; /** * Subtracts the given vector from this vector. @@ -380,7 +380,7 @@ public: * @param v The vector to subtract. * @return This vector, after the subtraction occurs. */ - inline Vector3& operator-=(const Vector3& v); + inline Vec3& operator-=(const Vec3& v); /** * Calculates the negation of this vector. @@ -389,7 +389,7 @@ public: * * @return The negation of this vector. */ - inline const Vector3 operator-() const; + inline const Vec3 operator-() const; /** * Calculates the scalar product of this vector with the given value. @@ -399,7 +399,7 @@ public: * @param s The value to scale by. * @return The scaled vector. */ - inline const Vector3 operator*(float s) const; + inline const Vec3 operator*(float s) const; /** * Scales this vector by the given value. @@ -407,7 +407,7 @@ public: * @param s The value to scale by. * @return This vector, after the scale occurs. */ - inline Vector3& operator*=(float s); + inline Vec3& operator*=(float s); /** * Returns the components of this vector divided by the given constant @@ -417,7 +417,7 @@ public: * @param s the constant to divide this vector with * @return a smaller vector */ - inline const Vector3 operator/(float s) const; + inline const Vec3 operator/(float s) const; /** * Determines if this vector is less than the given vector. @@ -426,7 +426,7 @@ public: * * @return True if this vector is less than the given vector, false otherwise. */ - inline bool operator<(const Vector3& v) const; + inline bool operator<(const Vec3& v) const; /** * Determines if this vector is equal to the given vector. @@ -435,7 +435,7 @@ public: * * @return True if this vector is equal to the given vector, false otherwise. */ - inline bool operator==(const Vector3& v) const; + inline bool operator==(const Vec3& v) const; /** * Determines if this vector is not equal to the given vector. @@ -444,18 +444,18 @@ public: * * @return True if this vector is not equal to the given vector, false otherwise. */ - inline bool operator!=(const Vector3& v) const; + inline bool operator!=(const Vec3& v) const; - /** equals to Vector3(0,0,0) */ - static const Vector3 ZERO; - /** equals to Vector3(1,1,1) */ - static const Vector3 ONE; - /** equals to Vector3(1,0,0) */ - static const Vector3 UNIT_X; - /** equals to Vector3(0,1,0) */ - static const Vector3 UNIT_Y; - /** equals to Vector3(0,0,1) */ - static const Vector3 UNIT_Z; + /** equals to Vec3(0,0,0) */ + static const Vec3 ZERO; + /** equals to Vec3(1,1,1) */ + static const Vec3 ONE; + /** equals to Vec3(1,0,0) */ + static const Vec3 UNIT_X; + /** equals to Vec3(0,1,0) */ + static const Vec3 UNIT_Y; + /** equals to Vec3(0,0,1) */ + static const Vec3 UNIT_Z; }; /** @@ -465,12 +465,12 @@ public: * @param v The vector to scale. * @return The scaled vector. */ -inline const Vector3 operator*(float x, const Vector3& v); +inline const Vec3 operator*(float x, const Vec3& v); -typedef Vector3 Point3; +typedef Vec3 Point3; NS_CC_MATH_END #include "Vector3.inl" -#endif +#endif // MATH_VEC3_H diff --git a/cocos/math/Vector3.inl b/cocos/math/Vector3.inl index 07de9320b6..8bd30d61c0 100644 --- a/cocos/math/Vector3.inl +++ b/cocos/math/Vector3.inl @@ -23,58 +23,58 @@ NS_CC_MATH_BEGIN -inline const Vector3 Vector3::operator+(const Vector3& v) const +inline const Vec3 Vec3::operator+(const Vec3& v) const { - Vector3 result(*this); + Vec3 result(*this); result.add(v); return result; } -inline Vector3& Vector3::operator+=(const Vector3& v) +inline Vec3& Vec3::operator+=(const Vec3& v) { add(v); return *this; } -inline const Vector3 Vector3::operator-(const Vector3& v) const +inline const Vec3 Vec3::operator-(const Vec3& v) const { - Vector3 result(*this); + Vec3 result(*this); result.subtract(v); return result; } -inline Vector3& Vector3::operator-=(const Vector3& v) +inline Vec3& Vec3::operator-=(const Vec3& v) { subtract(v); return *this; } -inline const Vector3 Vector3::operator-() const +inline const Vec3 Vec3::operator-() const { - Vector3 result(*this); + Vec3 result(*this); result.negate(); return result; } -inline const Vector3 Vector3::operator*(float s) const +inline const Vec3 Vec3::operator*(float s) const { - Vector3 result(*this); + Vec3 result(*this); result.scale(s); return result; } -inline Vector3& Vector3::operator*=(float s) +inline Vec3& Vec3::operator*=(float s) { scale(s); return *this; } -inline const Vector3 Vector3::operator/(const float s) const +inline const Vec3 Vec3::operator/(const float s) const { - return Vector3(this->x / s, this->y / s, this->z / s); + return Vec3(this->x / s, this->y / s, this->z / s); } -inline bool Vector3::operator<(const Vector3& v) const +inline bool Vec3::operator<(const Vec3& v) const { if (x == v.x) { @@ -87,19 +87,19 @@ inline bool Vector3::operator<(const Vector3& v) const return x < v.x; } -inline bool Vector3::operator==(const Vector3& v) const +inline bool Vec3::operator==(const Vec3& v) const { return x==v.x && y==v.y && z==v.z; } -inline bool Vector3::operator!=(const Vector3& v) const +inline bool Vec3::operator!=(const Vec3& v) const { return x!=v.x || y!=v.y || z!=v.z; } -inline const Vector3 operator*(float x, const Vector3& v) +inline const Vec3 operator*(float x, const Vec3& v) { - Vector3 result(v); + Vec3 result(v); result.scale(x); return result; } diff --git a/cocos/math/Vector4.cpp b/cocos/math/Vector4.cpp index 7abeb10979..3c8f8223c1 100644 --- a/cocos/math/Vector4.cpp +++ b/cocos/math/Vector4.cpp @@ -24,32 +24,32 @@ NS_CC_MATH_BEGIN -Vector4::Vector4() +Vec4::Vec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) { } -Vector4::Vector4(float xx, float yy, float zz, float ww) +Vec4::Vec4(float xx, float yy, float zz, float ww) : x(xx), y(yy), z(zz), w(ww) { } -Vector4::Vector4(const float* src) +Vec4::Vec4(const float* src) { set(src); } -Vector4::Vector4(const Vector4& p1, const Vector4& p2) +Vec4::Vec4(const Vec4& p1, const Vec4& p2) { set(p1, p2); } -Vector4::Vector4(const Vector4& copy) +Vec4::Vec4(const Vec4& copy) { set(copy); } -Vector4 Vector4::fromColor(unsigned int color) +Vec4 Vec4::fromColor(unsigned int color) { float components[4]; int componentIndex = 0; @@ -60,25 +60,25 @@ Vector4 Vector4::fromColor(unsigned int color) components[componentIndex++] = static_cast(component) / 255.0f; } - Vector4 value(components); + Vec4 value(components); return value; } -Vector4::~Vector4() +Vec4::~Vec4() { } -bool Vector4::isZero() const +bool Vec4::isZero() const { return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f; } -bool Vector4::isOne() const +bool Vec4::isOne() const { return x == 1.0f && y == 1.0f && z == 1.0f && w == 1.0f; } -float Vector4::angle(const Vector4& v1, const Vector4& v2) +float Vec4::angle(const Vec4& v1, const Vec4& v2) { float dx = v1.w * v2.x - v1.x * v2.w - v1.y * v2.z + v1.z * v2.y; float dy = v1.w * v2.y - v1.y * v2.w - v1.z * v2.x + v1.x * v2.z; @@ -87,7 +87,7 @@ float Vector4::angle(const Vector4& v1, const Vector4& v2) return atan2f(sqrt(dx * dx + dy * dy + dz * dz) + MATH_FLOAT_SMALL, dot(v1, v2)); } -void Vector4::add(const Vector4& v) +void Vec4::add(const Vec4& v) { x += v.x; y += v.y; @@ -95,7 +95,7 @@ void Vector4::add(const Vector4& v) w += v.w; } -void Vector4::add(const Vector4& v1, const Vector4& v2, Vector4* dst) +void Vec4::add(const Vec4& v1, const Vec4& v2, Vec4* dst) { GP_ASSERT(dst); @@ -105,7 +105,7 @@ void Vector4::add(const Vector4& v1, const Vector4& v2, Vector4* dst) dst->w = v1.w + v2.w; } -void Vector4::clamp(const Vector4& min, const Vector4& max) +void Vec4::clamp(const Vec4& min, const Vec4& max) { GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); @@ -134,7 +134,7 @@ void Vector4::clamp(const Vector4& min, const Vector4& max) w = max.w; } -void Vector4::clamp(const Vector4& v, const Vector4& min, const Vector4& max, Vector4* dst) +void Vec4::clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst) { GP_ASSERT(dst); GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); @@ -168,7 +168,7 @@ void Vector4::clamp(const Vector4& v, const Vector4& min, const Vector4& max, Ve dst->w = max.w; } -float Vector4::distance(const Vector4& v) const +float Vec4::distance(const Vec4& v) const { float dx = v.x - x; float dy = v.y - y; @@ -178,7 +178,7 @@ float Vector4::distance(const Vector4& v) const return sqrt(dx * dx + dy * dy + dz * dz + dw * dw); } -float Vector4::distanceSquared(const Vector4& v) const +float Vec4::distanceSquared(const Vec4& v) const { float dx = v.x - x; float dy = v.y - y; @@ -188,28 +188,28 @@ float Vector4::distanceSquared(const Vector4& v) const return (dx * dx + dy * dy + dz * dz + dw * dw); } -float Vector4::dot(const Vector4& v) const +float Vec4::dot(const Vec4& v) const { return (x * v.x + y * v.y + z * v.z + w * v.w); } -float Vector4::dot(const Vector4& v1, const Vector4& v2) +float Vec4::dot(const Vec4& v1, const Vec4& v2) { return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w); } -float Vector4::length() const +float Vec4::length() const { return sqrt(x * x + y * y + z * z + w * w); } -float Vector4::lengthSquared() const +float Vec4::lengthSquared() const { return (x * x + y * y + z * z + w * w); } -void Vector4::negate() +void Vec4::negate() { x = -x; y = -y; @@ -217,7 +217,7 @@ void Vector4::negate() w = -w; } -void Vector4::normalize() +void Vec4::normalize() { float n = x * x + y * y + z * z + w * w; // Already normalized. @@ -236,14 +236,14 @@ void Vector4::normalize() w *= n; } -Vector4 Vector4::getNormalized() const +Vec4 Vec4::getNormalized() const { - Vector4 v(*this); + Vec4 v(*this); v.normalize(); return v; } -void Vector4::scale(float scalar) +void Vec4::scale(float scalar) { x *= scalar; y *= scalar; @@ -251,7 +251,7 @@ void Vector4::scale(float scalar) w *= scalar; } -void Vector4::set(float xx, float yy, float zz, float ww) +void Vec4::set(float xx, float yy, float zz, float ww) { this->x = xx; this->y = yy; @@ -259,7 +259,7 @@ void Vector4::set(float xx, float yy, float zz, float ww) this->w = ww; } -void Vector4::set(const float* array) +void Vec4::set(const float* array) { GP_ASSERT(array); @@ -269,7 +269,7 @@ void Vector4::set(const float* array) w = array[3]; } -void Vector4::set(const Vector4& v) +void Vec4::set(const Vec4& v) { this->x = v.x; this->y = v.y; @@ -277,7 +277,7 @@ void Vector4::set(const Vector4& v) this->w = v.w; } -void Vector4::set(const Vector4& p1, const Vector4& p2) +void Vec4::set(const Vec4& p1, const Vec4& p2) { x = p2.x - p1.x; y = p2.y - p1.y; @@ -285,7 +285,7 @@ void Vector4::set(const Vector4& p1, const Vector4& p2) w = p2.w - p1.w; } -void Vector4::subtract(const Vector4& v) +void Vec4::subtract(const Vec4& v) { x -= v.x; y -= v.y; @@ -293,7 +293,7 @@ void Vector4::subtract(const Vector4& v) w -= v.w; } -void Vector4::subtract(const Vector4& v1, const Vector4& v2, Vector4* dst) +void Vec4::subtract(const Vec4& v1, const Vec4& v2, Vec4* dst) { GP_ASSERT(dst); @@ -303,11 +303,11 @@ void Vector4::subtract(const Vector4& v1, const Vector4& v2, Vector4* dst) dst->w = v1.w - v2.w; } -const Vector4 Vector4::ZERO = Vector4(0.0f, 0.0f, 0.0f, 0.0f); -const Vector4 Vector4::ONE = Vector4(1.0f, 1.0f, 1.0f, 1.0f); -const Vector4 Vector4::UNIT_X = Vector4(1.0f, 0.0f, 0.0f, 0.0f); -const Vector4 Vector4::UNIT_Y = Vector4(0.0f, 1.0f, 0.0f, 0.0f); -const Vector4 Vector4::UNIT_Z = Vector4(0.0f, 0.0f, 1.0f, 0.0f); -const Vector4 Vector4::UNIT_W = Vector4(0.0f, 0.0f, 0.0f, 1.0f); +const Vec4 Vec4::ZERO = Vec4(0.0f, 0.0f, 0.0f, 0.0f); +const Vec4 Vec4::ONE = Vec4(1.0f, 1.0f, 1.0f, 1.0f); +const Vec4 Vec4::UNIT_X = Vec4(1.0f, 0.0f, 0.0f, 0.0f); +const Vec4 Vec4::UNIT_Y = Vec4(0.0f, 1.0f, 0.0f, 0.0f); +const Vec4 Vec4::UNIT_Z = Vec4(0.0f, 0.0f, 1.0f, 0.0f); +const Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f); NS_CC_MATH_END diff --git a/cocos/math/Vector4.h b/cocos/math/Vector4.h index 616ae3094a..ce12686b92 100644 --- a/cocos/math/Vector4.h +++ b/cocos/math/Vector4.h @@ -18,19 +18,19 @@ This file was modified to fit the cocos2d-x project */ -#ifndef VECTOR4_H_ -#define VECTOR4_H_ +#ifndef MATH_VEC4_H +#define MATH_VEC4_H -#include "CCMathBase.h" +#include "math/CCMathBase.h" NS_CC_MATH_BEGIN -class Matrix; +class Mat4; /** * Defines 4-element floating point vector. */ -class Vector4 +class Vec4 { public: @@ -57,7 +57,7 @@ public: /** * Constructs a new vector initialized to all zeros. */ - Vector4(); + Vec4(); /** * Constructs a new vector initialized to the specified values. @@ -67,14 +67,14 @@ public: * @param zz The z coordinate. * @param ww The w coordinate. */ - Vector4(float xx, float yy, float zz, float ww); + Vec4(float xx, float yy, float zz, float ww); /** * Constructs a new vector from the values in the specified array. * * @param array An array containing the elements of the vector in the order x, y, z, w. */ - Vector4(const float* array); + Vec4(const float* array); /** * Constructs a vector that describes the direction between the specified points. @@ -82,7 +82,7 @@ public: * @param p1 The first point. * @param p2 The second point. */ - Vector4(const Vector4& p1, const Vector4& p2); + Vec4(const Vec4& p1, const Vec4& p2); /** * Constructor. @@ -91,7 +91,7 @@ public: * * @param copy The vector to copy. */ - Vector4(const Vector4& copy); + Vec4(const Vec4& copy); /** * Creates a new vector from an integer interpreted as an RGBA value. @@ -101,12 +101,12 @@ public: * * @return A vector corresponding to the interpreted RGBA color. */ - static Vector4 fromColor(unsigned int color); + static Vec4 fromColor(unsigned int color); /** * Destructor. */ - ~Vector4(); + ~Vec4(); /** * Indicates whether this vector contains all zeros. @@ -130,14 +130,14 @@ public: * * @return The angle between the two vectors (in radians). */ - static float angle(const Vector4& v1, const Vector4& v2); + static float angle(const Vec4& v1, const Vec4& v2); /** * Adds the elements of the specified vector to this one. * * @param v The vector to add. */ - void add(const Vector4& v); + void add(const Vec4& v); /** * Adds the specified vectors and stores the result in dst. @@ -146,7 +146,7 @@ public: * @param v2 The second vector. * @param dst A vector to store the result in. */ - static void add(const Vector4& v1, const Vector4& v2, Vector4* dst); + static void add(const Vec4& v1, const Vec4& v2, Vec4* dst); /** * Clamps this vector within the specified range. @@ -154,7 +154,7 @@ public: * @param min The minimum value. * @param max The maximum value. */ - void clamp(const Vector4& min, const Vector4& max); + void clamp(const Vec4& min, const Vec4& max); /** * Clamps the specified vector within the specified range and returns it in dst. @@ -164,7 +164,7 @@ public: * @param max The maximum value. * @param dst A vector to store the result in. */ - static void clamp(const Vector4& v, const Vector4& min, const Vector4& max, Vector4* dst); + static void clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst); /** * Returns the distance between this vector and v. @@ -175,7 +175,7 @@ public: * * @see distanceSquared */ - float distance(const Vector4& v) const; + float distance(const Vec4& v) const; /** * Returns the squared distance between this vector and v. @@ -191,7 +191,7 @@ public: * * @see distance */ - float distanceSquared(const Vector4& v) const; + float distanceSquared(const Vec4& v) const; /** * Returns the dot product of this vector and the specified vector. @@ -200,7 +200,7 @@ public: * * @return The dot product. */ - float dot(const Vector4& v) const; + float dot(const Vec4& v) const; /** * Returns the dot product between the specified vectors. @@ -210,7 +210,7 @@ public: * * @return The dot product between the vectors. */ - static float dot(const Vector4& v1, const Vector4& v2); + static float dot(const Vec4& v1, const Vec4& v2); /** * Computes the length of this vector. @@ -243,7 +243,7 @@ public: /** * Normalizes this vector. * - * This method normalizes this Vector4 so that it is of + * This method normalizes this Vec4 so that it is of * unit length (in other words, the length of the vector * after calling this method will be 1.0f). If the vector * already has unit length or if the length of the vector @@ -262,7 +262,7 @@ public: * * @param dst The destination vector. */ - Vector4 getNormalized() const; + Vec4 getNormalized() const; /** * Scales all elements of this vector by the specified value. @@ -293,7 +293,7 @@ public: * * @param v The vector to copy. */ - void set(const Vector4& v); + void set(const Vec4& v); /** * Sets this vector to the directional vector between the specified points. @@ -301,7 +301,7 @@ public: * @param p1 The first point. * @param p2 The second point. */ - void set(const Vector4& p1, const Vector4& p2); + void set(const Vec4& p1, const Vec4& p2); /** * Subtracts this vector and the specified vector as (this - v) @@ -309,7 +309,7 @@ public: * * @param v The vector to subtract. */ - void subtract(const Vector4& v); + void subtract(const Vec4& v); /** * Subtracts the specified vectors and stores the result in dst. @@ -319,7 +319,7 @@ public: * @param v2 The second vector. * @param dst The destination vector. */ - static void subtract(const Vector4& v1, const Vector4& v2, Vector4* dst); + static void subtract(const Vec4& v1, const Vec4& v2, Vec4* dst); /** * Calculates the sum of this vector with the given vector. @@ -329,7 +329,7 @@ public: * @param v The vector to add. * @return The vector sum. */ - inline const Vector4 operator+(const Vector4& v) const; + inline const Vec4 operator+(const Vec4& v) const; /** * Adds the given vector to this vector. @@ -337,7 +337,7 @@ public: * @param v The vector to add. * @return This vector, after the addition occurs. */ - inline Vector4& operator+=(const Vector4& v); + inline Vec4& operator+=(const Vec4& v); /** * Calculates the sum of this vector with the given vector. @@ -347,7 +347,7 @@ public: * @param v The vector to add. * @return The vector sum. */ - inline const Vector4 operator-(const Vector4& v) const; + inline const Vec4 operator-(const Vec4& v) const; /** * Subtracts the given vector from this vector. @@ -355,7 +355,7 @@ public: * @param v The vector to subtract. * @return This vector, after the subtraction occurs. */ - inline Vector4& operator-=(const Vector4& v); + inline Vec4& operator-=(const Vec4& v); /** * Calculates the negation of this vector. @@ -364,7 +364,7 @@ public: * * @return The negation of this vector. */ - inline const Vector4 operator-() const; + inline const Vec4 operator-() const; /** * Calculates the scalar product of this vector with the given value. @@ -374,7 +374,7 @@ public: * @param s The value to scale by. * @return The scaled vector. */ - inline const Vector4 operator*(float s) const; + inline const Vec4 operator*(float s) const; /** * Scales this vector by the given value. @@ -382,7 +382,7 @@ public: * @param s The value to scale by. * @return This vector, after the scale occurs. */ - inline Vector4& operator*=(float s); + inline Vec4& operator*=(float s); /** * Returns the components of this vector divided by the given constant @@ -392,7 +392,7 @@ public: * @param s the constant to divide this vector with * @return a smaller vector */ - inline const Vector4 operator/(float s) const; + inline const Vec4 operator/(float s) const; /** * Determines if this vector is less than the given vector. @@ -401,7 +401,7 @@ public: * * @return True if this vector is less than the given vector, false otherwise. */ - inline bool operator<(const Vector4& v) const; + inline bool operator<(const Vec4& v) const; /** * Determines if this vector is equal to the given vector. @@ -410,7 +410,7 @@ public: * * @return True if this vector is equal to the given vector, false otherwise. */ - inline bool operator==(const Vector4& v) const; + inline bool operator==(const Vec4& v) const; /** * Determines if this vector is not equal to the given vector. @@ -419,20 +419,20 @@ public: * * @return True if this vector is not equal to the given vector, false otherwise. */ - inline bool operator!=(const Vector4& v) const; + inline bool operator!=(const Vec4& v) const; - /** equals to Vector4(0,0,0,0) */ - static const Vector4 ZERO; - /** equals to Vector4(1,1,1,1) */ - static const Vector4 ONE; - /** equals to Vector4(1,0,0,0) */ - static const Vector4 UNIT_X; - /** equals to Vector4(0,1,0,0) */ - static const Vector4 UNIT_Y; - /** equals to Vector4(0,0,1,0) */ - static const Vector4 UNIT_Z; - /** equals to Vector4(0,0,0,1) */ - static const Vector4 UNIT_W; + /** equals to Vec4(0,0,0,0) */ + static const Vec4 ZERO; + /** equals to Vec4(1,1,1,1) */ + static const Vec4 ONE; + /** equals to Vec4(1,0,0,0) */ + static const Vec4 UNIT_X; + /** equals to Vec4(0,1,0,0) */ + static const Vec4 UNIT_Y; + /** equals to Vec4(0,0,1,0) */ + static const Vec4 UNIT_Z; + /** equals to Vec4(0,0,0,1) */ + static const Vec4 UNIT_W; }; /** @@ -442,10 +442,10 @@ public: * @param v The vector to scale. * @return The scaled vector. */ -inline const Vector4 operator*(float x, const Vector4& v); +inline const Vec4 operator*(float x, const Vec4& v); NS_CC_MATH_END #include "Vector4.inl" -#endif +#endif // MATH_VEC4_H diff --git a/cocos/math/Vector4.inl b/cocos/math/Vector4.inl index 98b51f4b34..9bdd7a9920 100644 --- a/cocos/math/Vector4.inl +++ b/cocos/math/Vector4.inl @@ -23,58 +23,58 @@ NS_CC_MATH_BEGIN -inline const Vector4 Vector4::operator+(const Vector4& v) const +inline const Vec4 Vec4::operator+(const Vec4& v) const { - Vector4 result(*this); + Vec4 result(*this); result.add(v); return result; } -inline Vector4& Vector4::operator+=(const Vector4& v) +inline Vec4& Vec4::operator+=(const Vec4& v) { add(v); return *this; } -inline const Vector4 Vector4::operator-(const Vector4& v) const +inline const Vec4 Vec4::operator-(const Vec4& v) const { - Vector4 result(*this); + Vec4 result(*this); result.subtract(v); return result; } -inline Vector4& Vector4::operator-=(const Vector4& v) +inline Vec4& Vec4::operator-=(const Vec4& v) { subtract(v); return *this; } -inline const Vector4 Vector4::operator-() const +inline const Vec4 Vec4::operator-() const { - Vector4 result(*this); + Vec4 result(*this); result.negate(); return result; } -inline const Vector4 Vector4::operator*(float s) const +inline const Vec4 Vec4::operator*(float s) const { - Vector4 result(*this); + Vec4 result(*this); result.scale(s); return result; } -inline Vector4& Vector4::operator*=(float s) +inline Vec4& Vec4::operator*=(float s) { scale(s); return *this; } -inline const Vector4 Vector4::operator/(const float s) const +inline const Vec4 Vec4::operator/(const float s) const { - return Vector4(this->x / s, this->y / s, this->z / s, this->w / s); + return Vec4(this->x / s, this->y / s, this->z / s, this->w / s); } -inline bool Vector4::operator<(const Vector4& v) const +inline bool Vec4::operator<(const Vec4& v) const { if (x == v.x) { @@ -94,19 +94,19 @@ inline bool Vector4::operator<(const Vector4& v) const return x < v.x; } -inline bool Vector4::operator==(const Vector4& v) const +inline bool Vec4::operator==(const Vec4& v) const { return x==v.x && y==v.y && z==v.z && w==v.w; } -inline bool Vector4::operator!=(const Vector4& v) const +inline bool Vec4::operator!=(const Vec4& v) const { return x!=v.x || y!=v.y || z!=v.z || w!=v.w; } -inline const Vector4 operator*(float x, const Vector4& v) +inline const Vec4 operator*(float x, const Vec4& v) { - Vector4 result(v); + Vec4 result(v); result.scale(x); return result; } diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 46f1306a4c..477d177a78 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -145,7 +145,7 @@ PhysicsBody* PhysicsBody::create(float mass, float moment) } -PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& material, const Vector2& offset) +PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& material, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -159,7 +159,7 @@ PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& mate return nullptr; } -PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& material, const Vector2& offset) +PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& material, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -173,7 +173,7 @@ PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& mat return nullptr; } -PhysicsBody* PhysicsBody::createPolygon(const Vector2* points, int count, const PhysicsMaterial& material, const Vector2& offset) +PhysicsBody* PhysicsBody::createPolygon(const Vec2* points, int count, const PhysicsMaterial& material, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -187,7 +187,7 @@ PhysicsBody* PhysicsBody::createPolygon(const Vector2* points, int count, const return nullptr; } -PhysicsBody* PhysicsBody::createEdgeSegment(const Vector2& a, const Vector2& b, const PhysicsMaterial& material, float border/* = 1*/) +PhysicsBody* PhysicsBody::createEdgeSegment(const Vec2& a, const Vec2& b, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -202,7 +202,7 @@ PhysicsBody* PhysicsBody::createEdgeSegment(const Vector2& a, const Vector2& b, return nullptr; } -PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Vector2& offset) +PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -218,7 +218,7 @@ PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& return nullptr; } -PhysicsBody* PhysicsBody::createEdgePolygon(const Vector2* points, int count, const PhysicsMaterial& material, float border/* = 1*/) +PhysicsBody* PhysicsBody::createEdgePolygon(const Vec2* points, int count, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -234,7 +234,7 @@ PhysicsBody* PhysicsBody::createEdgePolygon(const Vector2* points, int count, co return nullptr; } -PhysicsBody* PhysicsBody::createEdgeChain(const Vector2* points, int count, const PhysicsMaterial& material, float border/* = 1*/) +PhysicsBody* PhysicsBody::createEdgeChain(const Vec2* points, int count, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) @@ -345,7 +345,7 @@ void PhysicsBody::setGravityEnable(bool enable) } } -void PhysicsBody::setPosition(Vector2 position) +void PhysicsBody::setPosition(Vec2 position) { cpBodySetPos(_info->getBody(), PhysicsHelper::point2cpv(position + _positionOffset)); } @@ -355,7 +355,7 @@ void PhysicsBody::setRotation(float rotation) cpBodySetAngle(_info->getBody(), -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f))); } -Vector2 PhysicsBody::getPosition() const +Vec2 PhysicsBody::getPosition() const { cpVect vec = cpBodyGetPos(_info->getBody()); return PhysicsHelper::cpv2point(vec) - _positionOffset; @@ -402,10 +402,10 @@ PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/* void PhysicsBody::applyForce(const Vect& force) { - applyForce(force, Vector2::ZERO); + applyForce(force, Vec2::ZERO); } -void PhysicsBody::applyForce(const Vect& force, const Vector2& offset) +void PhysicsBody::applyForce(const Vect& force, const Vec2& offset) { if (_dynamic && _mass != PHYSICS_INFINITY) { @@ -426,10 +426,10 @@ void PhysicsBody::resetForces() void PhysicsBody::applyImpulse(const Vect& impulse) { - applyImpulse(impulse, Vector2()); + applyImpulse(impulse, Vec2()); } -void PhysicsBody::applyImpulse(const Vect& impulse, const Vector2& offset) +void PhysicsBody::applyImpulse(const Vect& impulse, const Vec2& offset) { cpBodyApplyImpulse(_info->getBody(), PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset)); } @@ -563,7 +563,7 @@ void PhysicsBody::addMoment(float moment) } } -void PhysicsBody::setVelocity(const Vector2& velocity) +void PhysicsBody::setVelocity(const Vec2& velocity) { if (!_dynamic) { @@ -574,17 +574,17 @@ void PhysicsBody::setVelocity(const Vector2& velocity) cpBodySetVel(_info->getBody(), PhysicsHelper::point2cpv(velocity)); } -Vector2 PhysicsBody::getVelocity() +Vec2 PhysicsBody::getVelocity() { return PhysicsHelper::cpv2point(cpBodyGetVel(_info->getBody())); } -Vector2 PhysicsBody::getVelocityAtLocalPoint(const Vector2& point) +Vec2 PhysicsBody::getVelocityAtLocalPoint(const Vec2& point) { return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_info->getBody(), PhysicsHelper::point2cpv(point))); } -Vector2 PhysicsBody::getVelocityAtWorldPoint(const Vector2& point) +Vec2 PhysicsBody::getVelocityAtWorldPoint(const Vec2& point) { return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_info->getBody(), PhysicsHelper::point2cpv(point))); } @@ -766,7 +766,7 @@ void PhysicsBody::update(float delta) Node* parent = _node->getParent(); Scene* scene = &_world->getScene(); - Vector2 position = parent != scene ? parent->convertToNodeSpace(scene->convertToWorldSpace(getPosition())) : getPosition(); + Vec2 position = parent != scene ? parent->convertToNodeSpace(scene->convertToWorldSpace(getPosition())) : getPosition(); float rotation = getRotation(); for (; parent != scene; parent = parent->getParent()) { @@ -828,17 +828,17 @@ void PhysicsBody::setGroup(int group) } } -void PhysicsBody::setPositionOffset(const Vector2& position) +void PhysicsBody::setPositionOffset(const Vec2& position) { if (!_positionOffset.equals(position)) { - Vector2 pos = getPosition(); + Vec2 pos = getPosition(); _positionOffset = position; setPosition(pos); } } -Vector2 PhysicsBody::getPositionOffset() const +Vec2 PhysicsBody::getPositionOffset() const { return _positionOffset; } @@ -858,12 +858,12 @@ float PhysicsBody::getRotationOffset() const return _rotationOffset; } -Vector2 PhysicsBody::world2Local(const Vector2& point) +Vec2 PhysicsBody::world2Local(const Vec2& point) { return PhysicsHelper::cpv2point(cpBodyWorld2Local(_info->getBody(), PhysicsHelper::point2cpv(point))); } -Vector2 PhysicsBody::local2World(const Vector2& point) +Vec2 PhysicsBody::local2World(const Vec2& point) { return PhysicsHelper::cpv2point(cpBodyLocal2World(_info->getBody(), PhysicsHelper::point2cpv(point))); } diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index e23bdd59ad..148c103b81 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -41,7 +41,7 @@ class PhysicsWorld; class PhysicsJoint; class PhysicsBodyInfo; -typedef Vector2 Vect; +typedef Vec2 Vect; const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT(0.1f, 0.5f, 0.5f); @@ -63,23 +63,23 @@ public: /** create a body with mass and moment. */ static PhysicsBody* create(float mass, float moment); /** Create a body contains a circle shape. */ - static PhysicsBody* createCircle(float radius, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + static PhysicsBody* createCircle(float radius, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); /** Create a body contains a box shape. */ - static PhysicsBody* createBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + static PhysicsBody* createBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); /** * @brief Create a body contains a polygon shape. - * points is an array of Vector2 structs defining a convex hull with a clockwise winding. + * points is an array of Vec2 structs defining a convex hull with a clockwise winding. */ - static PhysicsBody* createPolygon(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + static PhysicsBody* createPolygon(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); /** Create a body contains a EdgeSegment shape. */ - static PhysicsBody* createEdgeSegment(const Vector2& a, const Vector2& b, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); + static PhysicsBody* createEdgeSegment(const Vec2& a, const Vec2& b, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); /** Create a body contains a EdgeBox shape. */ - static PhysicsBody* createEdgeBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1, const Vector2& offset = Vector2::ZERO); + static PhysicsBody* createEdgeBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1, const Vec2& offset = Vec2::ZERO); /** Create a body contains a EdgePolygon shape. */ - static PhysicsBody* createEdgePolygon(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); + static PhysicsBody* createEdgePolygon(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); /** Create a body contains a EdgeChain shape. */ - static PhysicsBody* createEdgeChain(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); + static PhysicsBody* createEdgeChain(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); /* * @brief add a shape to body @@ -111,26 +111,26 @@ public: /** Applies a immediate force to body. */ virtual void applyForce(const Vect& force); /** Applies a immediate force to body. */ - virtual void applyForce(const Vect& force, const Vector2& offset); + virtual void applyForce(const Vect& force, const Vec2& offset); /** reset all the force applied to body. */ virtual void resetForces(); /** Applies a continuous force to body. */ virtual void applyImpulse(const Vect& impulse); /** Applies a continuous force to body. */ - virtual void applyImpulse(const Vect& impulse, const Vector2& offset); + virtual void applyImpulse(const Vect& impulse, const Vec2& offset); /** Applies a torque force to body. */ virtual void applyTorque(float torque); /** set the velocity of a body */ virtual void setVelocity(const Vect& velocity); /** get the velocity of a body */ - virtual Vector2 getVelocity(); + virtual Vec2 getVelocity(); /** set the angular velocity of a body */ virtual void setAngularVelocity(float velocity); /** get the angular velocity of a body at a local point */ - virtual Vector2 getVelocityAtLocalPoint(const Vector2& point); + virtual Vec2 getVelocityAtLocalPoint(const Vec2& point); /** get the angular velocity of a body at a world point */ - virtual Vector2 getVelocityAtWorldPoint(const Vector2& point); + virtual Vec2 getVelocityAtWorldPoint(const Vec2& point); /** get the angular velocity of a body */ virtual float getAngularVelocity(); /** set the max of velocity */ @@ -188,14 +188,14 @@ public: inline int getGroup() const { return _group; } /** get the body position. */ - Vector2 getPosition() const; + Vec2 getPosition() const; /** get the body rotation. */ float getRotation() const; /** set body position offset, it's the position witch relative to node */ - void setPositionOffset(const Vector2& position); + void setPositionOffset(const Vec2& position); /** get body position offset. */ - Vector2 getPositionOffset() const; + Vec2 getPositionOffset() const; /** set body rotation offset, it's the rotation witch relative to node */ void setRotationOffset(float rotation); /** set the body rotation offset */ @@ -293,15 +293,15 @@ public: inline void setTag(int tag) { _tag = tag; } /** convert the world point to local */ - Vector2 world2Local(const Vector2& point); + Vec2 world2Local(const Vec2& point); /** convert the local point to world */ - Vector2 local2World(const Vector2& point); + Vec2 local2World(const Vec2& point); protected: bool init(); - virtual void setPosition(Vector2 position); + virtual void setPosition(Vec2 position); virtual void setRotation(float rotation); void update(float delta); @@ -342,7 +342,7 @@ protected: bool _positionResetTag; /// To avoid reset the body position when body invoke Node::setPosition(). bool _rotationResetTag; /// To avoid reset the body rotation when body invoke Node::setRotation(). - Vector2 _positionOffset; + Vec2 _positionOffset; float _rotationOffset; friend class PhysicsWorld; diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index b8b52b9831..77d09087c0 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -106,7 +106,7 @@ void PhysicsContact::generateContactData() _contactData->points[i] = PhysicsHelper::cpv2point(cpArbiterGetPoint(arb, i)); } - _contactData->normal = _contactData->count > 0 ? PhysicsHelper::cpv2point(cpArbiterGetNormal(arb, 0)) : Vector2::ZERO; + _contactData->normal = _contactData->count > 0 ? PhysicsHelper::cpv2point(cpArbiterGetNormal(arb, 0)) : Vec2::ZERO; } // PhysicsContactPreSolve implementation @@ -129,7 +129,7 @@ float PhysicsContactPreSolve::getFriction() const return static_cast(_contactInfo)->u; } -Vector2 PhysicsContactPreSolve::getSurfaceVelocity() const +Vec2 PhysicsContactPreSolve::getSurfaceVelocity() const { return PhysicsHelper::cpv2point(static_cast(_contactInfo)->surface_vr); } @@ -176,7 +176,7 @@ float PhysicsContactPostSolve::getFriction() const return static_cast(_contactInfo)->u; } -Vector2 PhysicsContactPostSolve::getSurfaceVelocity() const +Vec2 PhysicsContactPostSolve::getSurfaceVelocity() const { return PhysicsHelper::cpv2point(static_cast(_contactInfo)->surface_vr); } diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index 44f120d034..b67510cf9e 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -42,14 +42,14 @@ class PhysicsWorld; class PhysicsContactInfo; -typedef Vector2 Vect; +typedef Vec2 Vect; typedef struct PhysicsContactData { static const int POINT_MAX = 4; - Vector2 points[POINT_MAX]; + Vec2 points[POINT_MAX]; int count; - Vector2 normal; + Vec2 normal; PhysicsContactData() : count(0) @@ -137,7 +137,7 @@ public: /** get friction between two bodies*/ float getFriction() const; /** get surface velocity between two bodies*/ - Vector2 getSurfaceVelocity() const; + Vec2 getSurfaceVelocity() const; /** set the restitution*/ void setRestitution(float restitution); /** set the friction*/ @@ -168,7 +168,7 @@ public: /** get friction between two bodies*/ float getFriction() const; /** get surface velocity between two bodies*/ - Vector2 getSurfaceVelocity() const; + Vec2 getSurfaceVelocity() const; private: PhysicsContactPostSolve(void* contactInfo); diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 5a5aaec1ae..bb5eb31766 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -162,7 +162,7 @@ float PhysicsJoint::getMaxForce() const return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce); } -PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr) +PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr) { PhysicsJointFixed* joint = new PhysicsJointFixed(); @@ -175,7 +175,7 @@ PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, return nullptr; } -bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr) +bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr) { do { @@ -203,7 +203,7 @@ bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anch return false; } -PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr) +PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr) { PhysicsJointPin* joint = new PhysicsJointPin(); @@ -216,7 +216,7 @@ PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, cons return nullptr; } -bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Vector2& anchr) +bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Vec2& anchr) { do { @@ -234,7 +234,7 @@ bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Vector2& anchr) return false; } -PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float min, float max) +PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float min, float max) { PhysicsJointLimit* joint = new PhysicsJointLimit(); @@ -247,12 +247,12 @@ PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, return nullptr; } -PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2) +PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2) { return construct(a, b, anchr1, anchr2, 0, b->local2World(anchr1).getDistance(a->local2World(anchr2))); } -bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float min, float max) +bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float min, float max) { do { @@ -294,27 +294,27 @@ void PhysicsJointLimit::setMax(float max) cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); } -Vector2 PhysicsJointLimit::getAnchr1() const +Vec2 PhysicsJointLimit::getAnchr1() const { return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_info->getJoints().front())); } -void PhysicsJointLimit::setAnchr1(const Vector2& anchr) +void PhysicsJointLimit::setAnchr1(const Vec2& anchr) { cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } -Vector2 PhysicsJointLimit::getAnchr2() const +Vec2 PhysicsJointLimit::getAnchr2() const { return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_info->getJoints().front())); } -void PhysicsJointLimit::setAnchr2(const Vector2& anchr) +void PhysicsJointLimit::setAnchr2(const Vec2& anchr) { cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } -PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2) +PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2) { PhysicsJointDistance* joint = new PhysicsJointDistance(); @@ -327,7 +327,7 @@ PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBod return nullptr; } -bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2) +bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2) { do { @@ -358,7 +358,7 @@ void PhysicsJointDistance::setDistance(float distance) cpPinJointSetDist(_info->getJoints().front(), PhysicsHelper::float2cpfloat(distance)); } -PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float stiffness, float damping) +PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float stiffness, float damping) { PhysicsJointSpring* joint = new PhysicsJointSpring(); @@ -371,7 +371,7 @@ PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b return nullptr; } -bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float stiffness, float damping) +bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float stiffness, float damping) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); @@ -394,22 +394,22 @@ bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anc return false; } -Vector2 PhysicsJointSpring::getAnchr1() const +Vec2 PhysicsJointSpring::getAnchr1() const { return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_info->getJoints().front())); } -void PhysicsJointSpring::setAnchr1(const Vector2& anchr) +void PhysicsJointSpring::setAnchr1(const Vec2& anchr) { cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } -Vector2 PhysicsJointSpring::getAnchr2() const +Vec2 PhysicsJointSpring::getAnchr2() const { return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_info->getJoints().front())); } -void PhysicsJointSpring::setAnchr2(const Vector2& anchr) +void PhysicsJointSpring::setAnchr2(const Vec2& anchr) { cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } @@ -444,7 +444,7 @@ void PhysicsJointSpring::setDamping(float damping) cpDampedSpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); } -PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& grooveA, const Vector2& grooveB, const Vector2& anchr2) +PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr2) { PhysicsJointGroove* joint = new PhysicsJointGroove(); @@ -457,7 +457,7 @@ PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b return nullptr; } -bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Vector2& grooveA, const Vector2& grooveB, const Vector2& anchr2) +bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr2) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); @@ -478,32 +478,32 @@ bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Vector2& gro return false; } -Vector2 PhysicsJointGroove::getGrooveA() const +Vec2 PhysicsJointGroove::getGrooveA() const { return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front())); } -void PhysicsJointGroove::setGrooveA(const Vector2& grooveA) +void PhysicsJointGroove::setGrooveA(const Vec2& grooveA) { cpGrooveJointSetGrooveA(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveA)); } -Vector2 PhysicsJointGroove::getGrooveB() const +Vec2 PhysicsJointGroove::getGrooveB() const { return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_info->getJoints().front())); } -void PhysicsJointGroove::setGrooveB(const Vector2& grooveB) +void PhysicsJointGroove::setGrooveB(const Vec2& grooveB) { cpGrooveJointSetGrooveB(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveB)); } -Vector2 PhysicsJointGroove::getAnchr2() const +Vec2 PhysicsJointGroove::getAnchr2() const { return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_info->getJoints().front())); } -void PhysicsJointGroove::setAnchr2(const Vector2& anchr2) +void PhysicsJointGroove::setAnchr2(const Vec2& anchr2) { cpGrooveJointSetAnchr2(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr2)); } diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index 085990c884..e892b29032 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -100,10 +100,10 @@ protected: class PhysicsJointFixed : public PhysicsJoint { public: - static PhysicsJointFixed* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr); + static PhysicsJointFixed* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr); + bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr); protected: PhysicsJointFixed() {} @@ -116,20 +116,20 @@ protected: class PhysicsJointLimit : public PhysicsJoint { public: - static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2); - static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float min, float max); + static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2); + static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float min, float max); - Vector2 getAnchr1() const; - void setAnchr1(const Vector2& anchr1); - Vector2 getAnchr2() const; - void setAnchr2(const Vector2& anchr2); + Vec2 getAnchr1() const; + void setAnchr1(const Vec2& anchr1); + Vec2 getAnchr2() const; + void setAnchr2(const Vec2& anchr2); float getMin() const; void setMin(float min); float getMax() const; void setMax(float max); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float min, float max); + bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float min, float max); protected: PhysicsJointLimit() {} @@ -142,10 +142,10 @@ protected: class PhysicsJointPin : public PhysicsJoint { public: - static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr); + static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr); + bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr); protected: PhysicsJointPin() {} @@ -156,13 +156,13 @@ protected: class PhysicsJointDistance : public PhysicsJoint { public: - static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2); + static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2); float getDistance() const; void setDistance(float distance); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2); + bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2); protected: PhysicsJointDistance() {} @@ -173,11 +173,11 @@ protected: class PhysicsJointSpring : public PhysicsJoint { public: - static PhysicsJointSpring* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float stiffness, float damping); - Vector2 getAnchr1() const; - void setAnchr1(const Vector2& anchr1); - Vector2 getAnchr2() const; - void setAnchr2(const Vector2& anchr2); + static PhysicsJointSpring* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float stiffness, float damping); + Vec2 getAnchr1() const; + void setAnchr1(const Vec2& anchr1); + Vec2 getAnchr2() const; + void setAnchr2(const Vec2& anchr2); float getRestLength() const; void setRestLength(float restLength); float getStiffness() const; @@ -186,7 +186,7 @@ public: void setDamping(float damping); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float stiffness, float damping); + bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float stiffness, float damping); protected: PhysicsJointSpring() {} @@ -197,17 +197,17 @@ protected: class PhysicsJointGroove : public PhysicsJoint { public: - static PhysicsJointGroove* construct(PhysicsBody* a, PhysicsBody* b, const Vector2& grooveA, const Vector2& grooveB, const Vector2& anchr2); + static PhysicsJointGroove* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr2); - Vector2 getGrooveA() const; - void setGrooveA(const Vector2& grooveA); - Vector2 getGrooveB() const; - void setGrooveB(const Vector2& grooveB); - Vector2 getAnchr2() const; - void setAnchr2(const Vector2& anchr2); + Vec2 getGrooveA() const; + void setGrooveA(const Vec2& grooveA); + Vec2 getGrooveB() const; + void setGrooveB(const Vec2& grooveB); + Vec2 getAnchr2() const; + void setAnchr2(const Vec2& anchr2); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Vector2& grooveA, const Vector2& grooveB, const Vector2& anchr); + bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr); protected: PhysicsJointGroove() {} diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index 60171cbec0..d4e74c92e7 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -229,14 +229,14 @@ void PhysicsShape::setFriction(float friction) } -void PhysicsShape::recenterPoints(Vector2* points, int count, const Vector2& center) +void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center) { cpVect* cpvs = new cpVect[count]; cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); PhysicsHelper::cpvs2points(cpvs, points, count); delete[] cpvs; - if (center != Vector2::ZERO) + if (center != Vec2::ZERO) { for (int i = 0; i < count; ++i) { @@ -245,7 +245,7 @@ void PhysicsShape::recenterPoints(Vector2* points, int count, const Vector2& cen } } -Vector2 PhysicsShape::getPolyonCenter(const Vector2* points, int count) +Vec2 PhysicsShape::getPolyonCenter(const Vec2* points, int count) { cpVect* cpvs = new cpVect[count]; cpVect center = cpCentroidForPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); @@ -279,7 +279,7 @@ void PhysicsShape::setBody(PhysicsBody *body) } // PhysicsShapeCircle -PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(0, 0)*/) +PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset/* = Vec2(0, 0)*/) { PhysicsShapeCircle* shape = new PhysicsShapeCircle(); if (shape && shape->init(radius, material, offset)) @@ -292,7 +292,7 @@ PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, const PhysicsMateri return nullptr; } -bool PhysicsShapeCircle::init(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset /*= Vector2(0, 0)*/) +bool PhysicsShapeCircle::init(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset /*= Vec2(0, 0)*/) { do { @@ -320,7 +320,7 @@ float PhysicsShapeCircle::calculateArea(float radius) return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, radius)); } -float PhysicsShapeCircle::calculateMoment(float mass, float radius, const Vector2& offset) +float PhysicsShapeCircle::calculateMoment(float mass, float radius, const Vec2& offset) { return mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(mass), @@ -350,13 +350,13 @@ float PhysicsShapeCircle::getRadius() const return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_info->getShapes().front())); } -Vector2 PhysicsShapeCircle::getOffset() +Vec2 PhysicsShapeCircle::getOffset() { return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_info->getShapes().front())); } // PhysicsShapeEdgeSegment -PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(const Vector2& a, const Vector2& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) +PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(const Vec2& a, const Vec2& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { PhysicsShapeEdgeSegment* shape = new PhysicsShapeEdgeSegment(); if (shape && shape->init(a, b, material, border)) @@ -369,7 +369,7 @@ PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(const Vector2& a, const return nullptr; } -bool PhysicsShapeEdgeSegment::init(const Vector2& a, const Vector2& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) +bool PhysicsShapeEdgeSegment::init(const Vec2& a, const Vec2& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { do { @@ -397,23 +397,23 @@ bool PhysicsShapeEdgeSegment::init(const Vector2& a, const Vector2& b, const Phy return false; } -Vector2 PhysicsShapeEdgeSegment::getPointA() const +Vec2 PhysicsShapeEdgeSegment::getPointA() const { return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->ta); } -Vector2 PhysicsShapeEdgeSegment::getPointB() const +Vec2 PhysicsShapeEdgeSegment::getPointB() const { return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->tb); } -Vector2 PhysicsShapeEdgeSegment::getCenter() +Vec2 PhysicsShapeEdgeSegment::getCenter() { return _center; } // PhysicsShapeBox -PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(0, 0)*/) +PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset/* = Vec2(0, 0)*/) { PhysicsShapeBox* shape = new PhysicsShapeBox(); if (shape && shape->init(size, material, offset)) @@ -426,7 +426,7 @@ PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial return nullptr; } -bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset /*= Vector2(0, 0)*/) +bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset /*= Vec2(0, 0)*/) { do { @@ -467,7 +467,7 @@ float PhysicsShapeBox::calculateArea(const Size& size) return PhysicsHelper::cpfloat2float(cpAreaForPoly(4, vec)); } -float PhysicsShapeBox::calculateMoment(float mass, const Size& size, const Vector2& offset) +float PhysicsShapeBox::calculateMoment(float mass, const Size& size, const Vec2& offset) { cpVect wh = PhysicsHelper::size2cpv(size); cpVect vec[4] = @@ -495,7 +495,7 @@ float PhysicsShapeBox::calculateDefaultMoment() : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); } -void PhysicsShapeBox::getPoints(Vector2* points) const +void PhysicsShapeBox::getPoints(Vec2* points) const { cpShape* shape = _info->getShapes().front(); PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts); @@ -509,7 +509,7 @@ Size PhysicsShapeBox::getSize() const } // PhysicsShapePolygon -PhysicsShapePolygon* PhysicsShapePolygon::create(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(0, 0)*/) +PhysicsShapePolygon* PhysicsShapePolygon::create(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset/* = Vec2(0, 0)*/) { PhysicsShapePolygon* shape = new PhysicsShapePolygon(); if (shape && shape->init(points, count, material, offset)) @@ -522,7 +522,7 @@ PhysicsShapePolygon* PhysicsShapePolygon::create(const Vector2* points, int coun return nullptr; } -bool PhysicsShapePolygon::init(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(0, 0)*/) +bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset/* = Vec2(0, 0)*/) { do { @@ -550,7 +550,7 @@ bool PhysicsShapePolygon::init(const Vector2* points, int count, const PhysicsMa return false; } -float PhysicsShapePolygon::calculateArea(const Vector2* points, int count) +float PhysicsShapePolygon::calculateArea(const Vec2* points, int count) { cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); @@ -560,7 +560,7 @@ float PhysicsShapePolygon::calculateArea(const Vector2* points, int count) return area; } -float PhysicsShapePolygon::calculateMoment(float mass, const Vector2* points, int count, const Vector2& offset) +float PhysicsShapePolygon::calculateMoment(float mass, const Vec2* points, int count, const Vec2& offset) { cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); @@ -584,12 +584,12 @@ float PhysicsShapePolygon::calculateDefaultMoment() : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); } -Vector2 PhysicsShapePolygon::getPoint(int i) const +Vec2 PhysicsShapePolygon::getPoint(int i) const { return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_info->getShapes().front(), i)); } -void PhysicsShapePolygon::getPoints(Vector2* outPoints) const +void PhysicsShapePolygon::getPoints(Vec2* outPoints) const { cpShape* shape = _info->getShapes().front(); PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, outPoints, ((cpPolyShape*)shape)->numVerts); @@ -600,13 +600,13 @@ int PhysicsShapePolygon::getPointsCount() const return ((cpPolyShape*)_info->getShapes().front())->numVerts; } -Vector2 PhysicsShapePolygon::getCenter() +Vec2 PhysicsShapePolygon::getCenter() { return _center; } // PhysicsShapeEdgeBox -PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vector2& offset/* = Vector2(0, 0)*/) +PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vec2& offset/* = Vec2(0, 0)*/) { PhysicsShapeEdgeBox* shape = new PhysicsShapeEdgeBox(); if (shape && shape->init(size, material, border, offset)) @@ -619,17 +619,17 @@ PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const Physics return nullptr; } -bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vector2& offset/*= Vector2(0, 0)*/) +bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vec2& offset/*= Vec2(0, 0)*/) { do { CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX)); cpVect vec[4] = {}; - vec[0] = PhysicsHelper::point2cpv(Vector2(-size.width/2+offset.x, -size.height/2+offset.y)); - vec[1] = PhysicsHelper::point2cpv(Vector2(+size.width/2+offset.x, -size.height/2+offset.y)); - vec[2] = PhysicsHelper::point2cpv(Vector2(+size.width/2+offset.x, +size.height/2+offset.y)); - vec[3] = PhysicsHelper::point2cpv(Vector2(-size.width/2+offset.x, +size.height/2+offset.y)); + vec[0] = PhysicsHelper::point2cpv(Vec2(-size.width/2+offset.x, -size.height/2+offset.y)); + vec[1] = PhysicsHelper::point2cpv(Vec2(+size.width/2+offset.x, -size.height/2+offset.y)); + vec[2] = PhysicsHelper::point2cpv(Vec2(+size.width/2+offset.x, +size.height/2+offset.y)); + vec[3] = PhysicsHelper::point2cpv(Vec2(-size.width/2+offset.x, +size.height/2+offset.y)); int i = 0; for (; i < 4; ++i) @@ -653,7 +653,7 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material return false; } -void PhysicsShapeEdgeBox::getPoints(cocos2d::Vector2 *outPoints) const +void PhysicsShapeEdgeBox::getPoints(cocos2d::Vec2 *outPoints) const { int i = 0; for(auto shape : _info->getShapes()) @@ -663,7 +663,7 @@ void PhysicsShapeEdgeBox::getPoints(cocos2d::Vector2 *outPoints) const } // PhysicsShapeEdgeBox -PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) +PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { PhysicsShapeEdgePolygon* shape = new PhysicsShapeEdgePolygon(); if (shape && shape->init(points, count, material, border)) @@ -676,7 +676,7 @@ PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Vector2* points, return nullptr; } -bool PhysicsShapeEdgePolygon::init(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) +bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { cpVect* vec = nullptr; do @@ -714,12 +714,12 @@ bool PhysicsShapeEdgePolygon::init(const Vector2* points, int count, const Physi return false; } -Vector2 PhysicsShapeEdgePolygon::getCenter() +Vec2 PhysicsShapeEdgePolygon::getCenter() { return _center; } -void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vector2 *outPoints) const +void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vec2 *outPoints) const { int i = 0; for(auto shape : _info->getShapes()) @@ -734,7 +734,7 @@ int PhysicsShapeEdgePolygon::getPointsCount() const } // PhysicsShapeEdgeChain -PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) +PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { PhysicsShapeEdgeChain* shape = new PhysicsShapeEdgeChain(); if (shape && shape->init(points, count, material, border)) @@ -747,7 +747,7 @@ PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Vector2* points, int return nullptr; } -bool PhysicsShapeEdgeChain::init(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) +bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { cpVect* vec = nullptr; do @@ -784,12 +784,12 @@ bool PhysicsShapeEdgeChain::init(const Vector2* points, int count, const Physics return false; } -Vector2 PhysicsShapeEdgeChain::getCenter() +Vec2 PhysicsShapeEdgeChain::getCenter() { return _center; } -void PhysicsShapeEdgeChain::getPoints(Vector2* outPoints) const +void PhysicsShapeEdgeChain::getPoints(Vec2* outPoints) const { int i = 0; for(auto shape : _info->getShapes()) @@ -818,7 +818,7 @@ void PhysicsShape::setGroup(int group) _group = group; } -bool PhysicsShape::containsPoint(const Vector2& point) const +bool PhysicsShape::containsPoint(const Vec2& point) const { for (auto shape : _info->getShapes()) { diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index f8a4f4e988..e677692fc0 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -107,16 +107,16 @@ public: /** Calculate the default moment value */ virtual float calculateDefaultMoment() { return 0.0f; } /** Get offset */ - virtual Vector2 getOffset() { return Vector2::ZERO; } + virtual Vec2 getOffset() { return Vec2::ZERO; } /** Get center of this shape */ - virtual Vector2 getCenter() { return getOffset(); } + virtual Vec2 getCenter() { return getOffset(); } /** Test point is in shape or not */ - bool containsPoint(const Vector2& point) const; + bool containsPoint(const Vec2& point) const; /** move the points to the center */ - static void recenterPoints(Vector2* points, int count, const Vector2& center = Vector2::ZERO); + static void recenterPoints(Vec2* points, int count, const Vec2& center = Vec2::ZERO); /** get center of the polyon points */ - static Vector2 getPolyonCenter(const Vector2* points, int count); + static Vec2 getPolyonCenter(const Vec2* points, int count); /** * A mask that defines which categories this physics body belongs to. @@ -184,16 +184,16 @@ protected: class PhysicsShapeCircle : public PhysicsShape { public: - static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vector2& offset = Vector2(0, 0)); + static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2(0, 0)); static float calculateArea(float radius); - static float calculateMoment(float mass, float radius, const Vector2& offset = Vector2::ZERO); + static float calculateMoment(float mass, float radius, const Vec2& offset = Vec2::ZERO); virtual float calculateDefaultMoment() override; float getRadius() const; - virtual Vector2 getOffset() override; + virtual Vec2 getOffset() override; protected: - bool init(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + bool init(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); virtual float calculateArea() override; protected: @@ -205,19 +205,19 @@ protected: class PhysicsShapeBox : public PhysicsShape { public: - static PhysicsShapeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + static PhysicsShapeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); static float calculateArea(const Size& size); - static float calculateMoment(float mass, const Size& size, const Vector2& offset = Vector2::ZERO); + static float calculateMoment(float mass, const Size& size, const Vec2& offset = Vec2::ZERO); virtual float calculateDefaultMoment() override; - void getPoints(Vector2* outPoints) const; + void getPoints(Vec2* outPoints) const; int getPointsCount() const { return 4; } Size getSize() const; - virtual Vector2 getOffset() override { return _offset; } + virtual Vec2 getOffset() override { return _offset; } protected: - bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); virtual float calculateArea() override; protected: @@ -225,25 +225,25 @@ protected: virtual ~PhysicsShapeBox(); protected: - Vector2 _offset; + Vec2 _offset; }; /** A polygon shape */ class PhysicsShapePolygon : public PhysicsShape { public: - static PhysicsShapePolygon* create(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); - static float calculateArea(const Vector2* points, int count); - static float calculateMoment(float mass, const Vector2* points, int count, const Vector2& offset = Vector2::ZERO); + static PhysicsShapePolygon* create(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); + static float calculateArea(const Vec2* points, int count); + static float calculateMoment(float mass, const Vec2* points, int count, const Vec2& offset = Vec2::ZERO); float calculateDefaultMoment() override; - Vector2 getPoint(int i) const; - void getPoints(Vector2* outPoints) const; + Vec2 getPoint(int i) const; + void getPoints(Vec2* outPoints) const; int getPointsCount() const; - virtual Vector2 getCenter() override; + virtual Vec2 getCenter() override; protected: - bool init(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vector2& offset = Vector2::ZERO); + bool init(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO); float calculateArea() override; protected: @@ -251,28 +251,28 @@ protected: virtual ~PhysicsShapePolygon(); protected: - Vector2 _center; + Vec2 _center; }; /** A segment shape */ class PhysicsShapeEdgeSegment : public PhysicsShape { public: - static PhysicsShapeEdgeSegment* create(const Vector2& a, const Vector2& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + static PhysicsShapeEdgeSegment* create(const Vec2& a, const Vec2& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - Vector2 getPointA() const; - Vector2 getPointB() const; - virtual Vector2 getCenter() override; + Vec2 getPointA() const; + Vec2 getPointB() const; + virtual Vec2 getCenter() override; protected: - bool init(const Vector2& a, const Vector2& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + bool init(const Vec2& a, const Vec2& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); protected: PhysicsShapeEdgeSegment(); virtual ~PhysicsShapeEdgeSegment(); protected: - Vector2 _center; + Vec2 _center; friend class PhysicsBody; }; @@ -281,20 +281,20 @@ protected: class PhysicsShapeEdgeBox : public PhysicsShape { public: - static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Vector2& offset = Vector2::ZERO); - virtual Vector2 getOffset() override { return _offset; } - void getPoints(Vector2* outPoints) const; + static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Vec2& offset = Vec2::ZERO); + virtual Vec2 getOffset() override { return _offset; } + void getPoints(Vec2* outPoints) const; int getPointsCount() const { return 4; } protected: - bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Vector2& offset = Vector2::ZERO); + bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Vec2& offset = Vec2::ZERO); protected: PhysicsShapeEdgeBox(); virtual ~PhysicsShapeEdgeBox(); protected: - Vector2 _offset; + Vec2 _offset; friend class PhysicsBody; }; @@ -303,13 +303,13 @@ protected: class PhysicsShapeEdgePolygon : public PhysicsShape { public: - static PhysicsShapeEdgePolygon* create(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - virtual Vector2 getCenter() override; - void getPoints(Vector2* outPoints) const; + static PhysicsShapeEdgePolygon* create(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + virtual Vec2 getCenter() override; + void getPoints(Vec2* outPoints) const; int getPointsCount() const; protected: - bool init(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + bool init(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); protected: PhysicsShapeEdgePolygon(); @@ -318,27 +318,27 @@ protected: friend class PhysicsBody; protected: - Vector2 _center; + Vec2 _center; }; /** a chain shape */ class PhysicsShapeEdgeChain : public PhysicsShape { public: - static PhysicsShapeEdgeChain* create(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - virtual Vector2 getCenter() override; - void getPoints(Vector2* outPoints) const; + static PhysicsShapeEdgeChain* create(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + virtual Vec2 getCenter() override; + void getPoints(Vec2* outPoints) const; int getPointsCount() const; protected: - bool init(const Vector2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + bool init(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); protected: PhysicsShapeEdgeChain(); virtual ~PhysicsShapeEdgeChain(); protected: - Vector2 _center; + Vec2 _center; friend class PhysicsBody; }; diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 2420b59297..f62a715b63 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -66,8 +66,8 @@ namespace { PhysicsWorld* world; PhysicsRayCastCallbackFunc func; - Vector2 p1; - Vector2 p2; + Vec2 p1; + Vec2 p2; void* data; }RayCastCallbackInfo; @@ -153,8 +153,8 @@ void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect it->second->getShape(), info->p1, info->p2, - Vector2(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t), - Vector2(n.x, n.y), + Vec2(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t), + Vec2(n.x, n.y), (float)t, }; @@ -334,7 +334,7 @@ void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) _scene->getEventDispatcher()->dispatchEvent(&contact); } -void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vector2& point1, const Vector2& point2, void* data) +void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1, const Vec2& point2, void* data) { CCASSERT(func != nullptr, "func shouldn't be nullptr"); @@ -371,7 +371,7 @@ void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect } } -void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vector2& point, void* data) +void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& point, void* data) { CCASSERT(func != nullptr, "func shouldn't be nullptr"); @@ -390,7 +390,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vector2& } } -Vector PhysicsWorld::getShapes(const Vector2& point) const +Vector PhysicsWorld::getShapes(const Vec2& point) const { Vector arr; cpSpaceNearestPointQuery(this->_info->getSpace(), @@ -404,7 +404,7 @@ Vector PhysicsWorld::getShapes(const Vector2& point) const return arr; } -PhysicsShape* PhysicsWorld::getShape(const Vector2& point) const +PhysicsShape* PhysicsWorld::getShape(const Vec2& point) const { cpShape* shape = cpSpaceNearestPointQueryNearest(this->_info->getSpace(), PhysicsHelper::point2cpv(point), @@ -905,7 +905,7 @@ void PhysicsWorld::update(float delta) } PhysicsWorld::PhysicsWorld() -: _gravity(Vector2(0.0f, -98.0f)) +: _gravity(Vec2(0.0f, -98.0f)) , _speed(1.0f) , _updateRate(1) , _updateRateCount(0) @@ -965,16 +965,16 @@ void PhysicsDebugDraw::drawShape(PhysicsShape& shape) case CP_CIRCLE_SHAPE: { float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(subShape)); - Vector2 centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape))) + Vec2 centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape))) + PhysicsHelper::cpv2point(cpCircleShapeGetOffset(subShape)); static const int CIRCLE_SEG_NUM = 12; - Vector2 seg[CIRCLE_SEG_NUM] = {}; + Vec2 seg[CIRCLE_SEG_NUM] = {}; for (int i = 0; i < CIRCLE_SEG_NUM; ++i) { float angle = (float)i * M_PI / (float)CIRCLE_SEG_NUM * 2.0f; - Vector2 d(radius * cosf(angle), radius * sinf(angle)); + Vec2 d(radius * cosf(angle), radius * sinf(angle)); seg[i] = centre + d; } _drawNode->drawPolygon(seg, CIRCLE_SEG_NUM, fillColor, 1, outlineColor); @@ -992,7 +992,7 @@ void PhysicsDebugDraw::drawShape(PhysicsShape& shape) { cpPolyShape* poly = (cpPolyShape*)subShape; int num = poly->numVerts; - Vector2* seg = new Vector2[num]; + Vec2* seg = new Vec2[num]; PhysicsHelper::cpvs2points(poly->tVerts, seg, num); diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 3c7d80b9d4..e091017426 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -42,7 +42,7 @@ class PhysicsWorldInfo; class PhysicsShape; class PhysicsContact; -typedef Vector2 Vect; +typedef Vec2 Vect; class Node; class Sprite; @@ -55,9 +55,9 @@ class PhysicsWorld; typedef struct PhysicsRayCastInfo { PhysicsShape* shape; - Vector2 start; - Vector2 end; //< in lua, it's name is "ended" - Vector2 contact; + Vec2 start; + Vec2 end; //< in lua, it's name is "ended" + Vec2 contact; Vect normal; float fraction; void* data; @@ -105,15 +105,15 @@ public: virtual void removeAllBodies(); /** Searches for physics shapes that intersects the ray. */ - void rayCast(PhysicsRayCastCallbackFunc func, const Vector2& start, const Vector2& end, void* data); + void rayCast(PhysicsRayCastCallbackFunc func, const Vec2& start, const Vec2& end, void* data); /** Searches for physics shapes that contains in the rect. */ void queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect, void* data); /** Searches for physics shapes that contains the point. */ - void queryPoint(PhysicsQueryPointCallbackFunc func, const Vector2& point, void* data); + void queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& point, void* data); /** Get phsyics shapes that contains the point. */ - Vector getShapes(const Vector2& point) const; + Vector getShapes(const Vec2& point) const; /** return physics shape that contains the point. */ - PhysicsShape* getShape(const Vector2& point) const; + PhysicsShape* getShape(const Vec2& point) const; /** Get all the bodys that in the physics world. */ const Vector& getAllBodies() const; /** Get body by tag */ diff --git a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h index 8a3ffcdef1..fde230ad1f 100644 --- a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h @@ -37,8 +37,8 @@ NS_CC_BEGIN class PhysicsHelper { public: - static Vector2 cpv2point(const cpVect& vec) { return Vector2(vec.x, vec.y); } - static cpVect point2cpv(const Vector2& point) { return cpv(point.x, point.y); } + static Vec2 cpv2point(const cpVect& vec) { return Vec2(vec.x, vec.y); } + static cpVect point2cpv(const Vec2& point) { return cpv(point.x, point.y); } static Size cpv2size(const cpVect& vec) { return Size(vec.x, vec.y); } static cpVect size2cpv(const Size& size) { return cpv(size.width, size.height); } static float cpfloat2float(cpFloat f) { return f; } @@ -46,7 +46,7 @@ public: static cpBB rect2cpbb(const Rect& rect) { return cpBBNew(rect.origin.x, rect.origin.y, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); } static Rect cpbb2rect(const cpBB& bb) { return Rect(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b); } - static Vector2* cpvs2points(const cpVect* cpvs, Vector2* out, int count) + static Vec2* cpvs2points(const cpVect* cpvs, Vec2* out, int count) { for (int i = 0; i < count; ++i) { @@ -56,7 +56,7 @@ public: return out; } - static cpVect* points2cpvs(const Vector2* points, cpVect* out, int count) + static cpVect* points2cpvs(const Vec2* points, cpVect* out, int count) { for (int i = 0; i < count; ++i) { diff --git a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h index 87ce0fdacd..f5e885b86d 100644 --- a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h @@ -33,7 +33,7 @@ #include "base/CCPlatformMacros.h" #include "math/CCGeometry.h" NS_CC_BEGIN -typedef Vector2 Vect; +typedef Vec2 Vect; class PhysicsBodyInfo; class PhysicsJointInfo; class PhysicsShapeInfo; diff --git a/cocos/renderer/CCBatchCommand.cpp b/cocos/renderer/CCBatchCommand.cpp index ce7dd90a6c..8cd92c148d 100644 --- a/cocos/renderer/CCBatchCommand.cpp +++ b/cocos/renderer/CCBatchCommand.cpp @@ -39,7 +39,7 @@ BatchCommand::BatchCommand() _shader = nullptr; } -void BatchCommand::init(float globalOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Matrix& modelViewTransform) +void BatchCommand::init(float globalOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Mat4& modelViewTransform) { CCASSERT(shader, "shader cannot be nill"); CCASSERT(textureAtlas, "textureAtlas cannot be nill"); diff --git a/cocos/renderer/CCBatchCommand.h b/cocos/renderer/CCBatchCommand.h index ed3e9abcd1..d5920b369b 100644 --- a/cocos/renderer/CCBatchCommand.h +++ b/cocos/renderer/CCBatchCommand.h @@ -40,7 +40,7 @@ public: BatchCommand(); ~BatchCommand(); - void init(float depth, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Matrix& modelViewTransform); + void init(float depth, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Mat4& modelViewTransform); void execute(); @@ -54,7 +54,7 @@ protected: TextureAtlas *_textureAtlas; // ModelView transform - Matrix _mv; + Mat4 _mv; }; NS_CC_END diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index 4fb7b16895..fb4d42e334 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -808,15 +808,15 @@ void GLProgram::setUniformsForBuiltins() Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix matrixMV; + Mat4 matrixMV; matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); setUniformsForBuiltins(matrixMV); } -void GLProgram::setUniformsForBuiltins(const Matrix &matrixMV) +void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV) { - Matrix matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + Mat4 matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); if(_flags.usesP) setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_P_MATRIX], matrixP.m, 1); @@ -825,7 +825,7 @@ void GLProgram::setUniformsForBuiltins(const Matrix &matrixMV) setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MV_MATRIX], matrixMV.m, 1); if(_flags.usesMVP) { - Matrix matrixMVP = matrixP * matrixMV; + Mat4 matrixMVP = matrixP * matrixMV; setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MVP_MATRIX], matrixMVP.m, 1); } diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index fe403872d9..d77847e5a4 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -274,7 +274,7 @@ public: /** will update the builtin uniforms if they are different than the previous call for this same shader program. */ void setUniformsForBuiltins(); - void setUniformsForBuiltins(const Matrix &modelView); + void setUniformsForBuiltins(const Mat4 &modelView); // Attribute diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index d1965dd256..6f7f05e88e 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -141,28 +141,28 @@ void UniformValue::setInt(int value) _useCallback = false; } -void UniformValue::setVec2(const Vector2& value) +void UniformValue::setVec2(const Vec2& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC2, ""); memcpy(_value.v2Value, &value, sizeof(_value.v2Value)); _useCallback = false; } -void UniformValue::setVec3(const Vector3& value) +void UniformValue::setVec3(const Vec3& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC3, ""); memcpy(_value.v3Value, &value, sizeof(_value.v3Value)); _useCallback = false; } -void UniformValue::setVec4(const Vector4& value) +void UniformValue::setVec4(const Vec4& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC4, ""); memcpy(_value.v4Value, &value, sizeof(_value.v4Value)); _useCallback = false; } -void UniformValue::setMat4(const Matrix& value) +void UniformValue::setMat4(const Mat4& value) { CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); memcpy(_value.matrixValue, &value, sizeof(_value.matrixValue)); @@ -305,7 +305,7 @@ void GLProgramState::resetGLProgram() _textureUnitIndex = 1; } -void GLProgramState::apply(const Matrix& modelView) +void GLProgramState::apply(const Mat4& modelView) { CCASSERT(_glprogram, "invalid glprogram"); @@ -413,7 +413,7 @@ void GLProgramState::setUniformInt(const std::string &uniformName, int value) CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } -void GLProgramState::setUniformVec2(const std::string &uniformName, const Vector2& value) +void GLProgramState::setUniformVec2(const std::string &uniformName, const Vec2& value) { auto v = getUniformValue(uniformName); if (v) @@ -422,7 +422,7 @@ void GLProgramState::setUniformVec2(const std::string &uniformName, const Vector CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } -void GLProgramState::setUniformVec3(const std::string &uniformName, const Vector3& value) +void GLProgramState::setUniformVec3(const std::string &uniformName, const Vec3& value) { auto v = getUniformValue(uniformName); if (v) @@ -431,7 +431,7 @@ void GLProgramState::setUniformVec3(const std::string &uniformName, const Vector CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } -void GLProgramState::setUniformVec4(const std::string &uniformName, const Vector4& value) +void GLProgramState::setUniformVec4(const std::string &uniformName, const Vec4& value) { auto v = getUniformValue(uniformName); if (v) @@ -440,7 +440,7 @@ void GLProgramState::setUniformVec4(const std::string &uniformName, const Vector CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } -void GLProgramState::setUniformMat4(const std::string &uniformName, const Matrix& value) +void GLProgramState::setUniformMat4(const std::string &uniformName, const Mat4& value) { auto v = getUniformValue(uniformName); if (v) diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index 5a71bc7f53..fb117a9eed 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -56,10 +56,10 @@ public: void setFloat(float value); void setInt(int value); - void setVec2(const Vector2& value); - void setVec3(const Vector3& value); - void setVec4(const Vector4& value); - void setMat4(const Matrix& value); + void setVec2(const Vec2& value); + void setVec3(const Vec3& value); + void setVec4(const Vec4& value); + void setMat4(const Mat4& value); void setCallback(const std::function &callback); void setTexture(GLuint textureId, GLuint activeTexture); @@ -155,7 +155,7 @@ public: /** gets-or-creates an instance of GLProgramState for a given GLProgramName */ static GLProgramState* getOrCreateWithGLProgramName(const std::string &glProgramName ); - void apply(const Matrix& modelView); + void apply(const Mat4& modelView); void setGLProgram(GLProgram* glprogram); GLProgram* getGLProgram() const { return _glprogram; } @@ -170,10 +170,10 @@ public: ssize_t getUniformCount() const { return _uniforms.size(); } void setUniformInt(const std::string &uniformName, int value); void setUniformFloat(const std::string &uniformName, float value); - void setUniformVec2(const std::string &uniformName, const Vector2& value); - void setUniformVec3(const std::string &uniformName, const Vector3& value); - void setUniformVec4(const std::string &uniformName, const Vector4& value); - void setUniformMat4(const std::string &uniformName, const Matrix& value); + void setUniformVec2(const std::string &uniformName, const Vec2& value); + void setUniformVec3(const std::string &uniformName, const Vec3& value); + void setUniformVec4(const std::string &uniformName, const Vec4& value); + void setUniformMat4(const std::string &uniformName, const Mat4& value); void setUniformCallback(const std::string &uniformName, const std::function &callback); void setUniformTexture(const std::string &uniformName, Texture2D *texture); void setUniformTexture(const std::string &uniformName, GLuint textureId); diff --git a/cocos/renderer/CCQuadCommand.cpp b/cocos/renderer/CCQuadCommand.cpp index 9eb8cc19cb..1aae065718 100644 --- a/cocos/renderer/CCQuadCommand.cpp +++ b/cocos/renderer/CCQuadCommand.cpp @@ -43,7 +43,7 @@ QuadCommand::QuadCommand() _type = RenderCommand::Type::QUAD_COMMAND; } -void QuadCommand::init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const Matrix &mv) +void QuadCommand::init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const Mat4 &mv) { CCASSERT(glProgramState, "Invalid GLProgramState"); CCASSERT(glProgramState->getVertexAttribsFlags() == 0, "No custom attributes are supported in QuadCommand"); diff --git a/cocos/renderer/CCQuadCommand.h b/cocos/renderer/CCQuadCommand.h index c838f2bc32..8f3d3622f1 100644 --- a/cocos/renderer/CCQuadCommand.h +++ b/cocos/renderer/CCQuadCommand.h @@ -43,7 +43,7 @@ public: /** Initializes the command with a globalZOrder, a texture ID, a `GLProgram`, a blending function, a pointer to quads, * quantity of quads, and the Model View transform to be used for the quads */ void init(float globalOrder, GLuint texutreID, GLProgramState* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, - const Matrix& mv); + const Mat4& mv); void useMaterial() const; @@ -54,7 +54,7 @@ public: inline ssize_t getQuadCount() const { return _quadsCount; } inline GLProgramState* getGLProgramState() const { return _glProgramState; } inline BlendFunc getBlendType() const { return _blendType; } - inline const Matrix& getModelView() const { return _mv; } + inline const Mat4& getModelView() const { return _mv; } protected: @@ -66,7 +66,7 @@ protected: BlendFunc _blendType; V3F_C4B_T2F_Quad* _quads; ssize_t _quadsCount; - Matrix _mv; + Mat4 _mv; }; NS_CC_END diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 5246f6efb5..f090b2e941 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -371,7 +371,7 @@ void Renderer::clean() _lastMaterialID = 0; } -void Renderer::convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Matrix& modelView) +void Renderer::convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Mat4& modelView) { // kmMat4 matrixP, mvp; // kmGLGetMatrix(KM_GL_PROJECTION, &matrixP); @@ -379,16 +379,16 @@ void Renderer::convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quanti for(ssize_t i=0; ibl.vertices; + Vec3 *vec1 = (Vec3*)&q->bl.vertices; modelView.transformPoint(vec1); - Vector3 *vec2 = (Vector3*)&q->br.vertices; + Vec3 *vec2 = (Vec3*)&q->br.vertices; modelView.transformPoint(vec2); - Vector3 *vec3 = (Vector3*)&q->tr.vertices; + Vec3 *vec3 = (Vec3*)&q->tr.vertices; modelView.transformPoint(vec3); - Vector3 *vec4 = (Vector3*)&q->tl.vertices; + Vec3 *vec4 = (Vec3*)&q->tl.vertices; modelView.transformPoint(vec4); } } @@ -505,7 +505,7 @@ void Renderer::flush() // helpers -bool Renderer::checkVisibility(const Matrix &transform, const Size &size) +bool Renderer::checkVisibility(const Mat4 &transform, const Size &size) { // half size of the screen Size screen_half = Director::getInstance()->getWinSize(); @@ -515,7 +515,7 @@ bool Renderer::checkVisibility(const Matrix &transform, const Size &size) float hSizeX = size.width/2; float hSizeY = size.height/2; - Vector4 v4world, v4local; + Vec4 v4world, v4local; v4local.set(hSizeX, hSizeY, 0, 1); transform.transformVector(v4local, &v4world); diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index 94c9da4794..cadb5acd4e 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -115,7 +115,7 @@ public: inline GroupCommandManager* getGroupCommandManager() const { return _groupCommandManager; }; /** returns whether or not a rectangle is visible or not */ - bool checkVisibility(const Matrix& transform, const Size& size); + bool checkVisibility(const Mat4& transform, const Size& size); protected: @@ -133,7 +133,7 @@ protected: void visitRenderQueue(const RenderQueue& queue); - void convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Matrix& modelView); + void convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Mat4& modelView); std::stack _commandGroupStack; diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 28426f2430..b28e1ed4aa 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -1557,7 +1557,7 @@ int lua_cocos2dx_Touch_getPreviousLocationInView(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPreviousLocationInView(); + cocos2d::Vec2 ret = cobj->getPreviousLocationInView(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1601,7 +1601,7 @@ int lua_cocos2dx_Touch_getLocation(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getLocation(); + cocos2d::Vec2 ret = cobj->getLocation(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1645,7 +1645,7 @@ int lua_cocos2dx_Touch_getDelta(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getDelta(); + cocos2d::Vec2 ret = cobj->getDelta(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1689,7 +1689,7 @@ int lua_cocos2dx_Touch_getStartLocationInView(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getStartLocationInView(); + cocos2d::Vec2 ret = cobj->getStartLocationInView(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1733,7 +1733,7 @@ int lua_cocos2dx_Touch_getStartLocation(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getStartLocation(); + cocos2d::Vec2 ret = cobj->getStartLocation(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1873,7 +1873,7 @@ int lua_cocos2dx_Touch_getLocationInView(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getLocationInView(); + cocos2d::Vec2 ret = cobj->getLocationInView(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1917,7 +1917,7 @@ int lua_cocos2dx_Touch_getPreviousLocation(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPreviousLocation(); + cocos2d::Vec2 ret = cobj->getPreviousLocation(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -3357,7 +3357,7 @@ int lua_cocos2dx_Texture2D_drawAtPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -4156,12 +4156,12 @@ int lua_cocos2dx_Node_convertToWorldSpaceAR(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertToWorldSpaceAR(arg0); + cocos2d::Vec2 ret = cobj->convertToWorldSpaceAR(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4702,7 +4702,7 @@ int lua_cocos2dx_Node_getNodeToWorldTransform(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Matrix ret = cobj->getNodeToWorldTransform(); + cocos2d::Mat4 ret = cobj->getNodeToWorldTransform(); matrix_to_luaval(tolua_S, ret); return 1; } @@ -4746,8 +4746,8 @@ int lua_cocos2dx_Node_getPosition3D(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector3 ret = cobj->getPosition3D(); - vector3_to_luaval(tolua_S, ret); + cocos2d::Vec3 ret = cobj->getPosition3D(); + Vec3_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPosition3D",argc, 0); @@ -4847,12 +4847,12 @@ int lua_cocos2dx_Node_convertToWorldSpace(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertToWorldSpace(arg0); + cocos2d::Vec2 ret = cobj->convertToWorldSpace(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5123,7 +5123,7 @@ int lua_cocos2dx_Node_convertTouchToNodeSpace(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.Touch",&arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertTouchToNodeSpace(arg0); + cocos2d::Vec2 ret = cobj->convertTouchToNodeSpace(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5350,8 +5350,8 @@ int lua_cocos2dx_Node_getRotation3D(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector3 ret = cobj->getRotation3D(); - vector3_to_luaval(tolua_S, ret); + cocos2d::Vec3 ret = cobj->getRotation3D(); + Vec3_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotation3D",argc, 0); @@ -5394,7 +5394,7 @@ int lua_cocos2dx_Node_getNodeToParentTransform(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Matrix& ret = cobj->getNodeToParentTransform(); + const cocos2d::Mat4& ret = cobj->getNodeToParentTransform(); matrix_to_luaval(tolua_S, ret); return 1; } @@ -5441,7 +5441,7 @@ int lua_cocos2dx_Node_convertTouchToNodeSpaceAR(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.Touch",&arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertTouchToNodeSpaceAR(arg0); + cocos2d::Vec2 ret = cobj->convertTouchToNodeSpaceAR(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5483,12 +5483,12 @@ int lua_cocos2dx_Node_convertToNodeSpace(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertToNodeSpace(arg0); + cocos2d::Vec2 ret = cobj->convertToNodeSpace(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5627,7 +5627,7 @@ int lua_cocos2dx_Node_setPosition(lua_State* tolua_S) ok = true; do{ if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if (!ok) { break; } @@ -5907,9 +5907,9 @@ int lua_cocos2dx_Node_setRotation3D(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector3 arg0; + cocos2d::Vec3 arg0; - ok &= luaval_to_vector3(tolua_S, 2, &arg0); + ok &= luaval_to_Vec3(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setRotation3D(arg0); @@ -5999,7 +5999,7 @@ int lua_cocos2dx_Node_setNodeToParentTransform(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Matrix arg0; + cocos2d::Mat4 arg0; ok &= luaval_to_matrix(tolua_S, 2, &arg0); if(!ok) @@ -6047,7 +6047,7 @@ int lua_cocos2dx_Node_getAnchorPoint(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getAnchorPoint(); + const cocos2d::Vec2& ret = cobj->getAnchorPoint(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6264,12 +6264,12 @@ int lua_cocos2dx_Node_convertToNodeSpaceAR(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertToNodeSpaceAR(arg0); + cocos2d::Vec2 ret = cobj->convertToNodeSpaceAR(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6448,7 +6448,7 @@ int lua_cocos2dx_Node_getAnchorPointInPoints(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getAnchorPointInPoints(); + const cocos2d::Vec2& ret = cobj->getAnchorPointInPoints(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6855,8 +6855,8 @@ int lua_cocos2dx_Node_setAdditionalTransform(lua_State* tolua_S) ok = true; do{ if (argc == 1) { - cocos2d::Matrix* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Matrix",&arg0); + cocos2d::Mat4* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Matrix",&arg0); if (!ok) { break; } cobj->setAdditionalTransform(arg0); @@ -7683,7 +7683,7 @@ int lua_cocos2dx_Node_getParentToNodeTransform(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Matrix& ret = cobj->getParentToNodeTransform(); + const cocos2d::Mat4& ret = cobj->getParentToNodeTransform(); matrix_to_luaval(tolua_S, ret); return 1; } @@ -8553,7 +8553,7 @@ int lua_cocos2dx_Node_draw(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.Renderer",&arg0); if (!ok) { break; } - cocos2d::Matrix arg1; + cocos2d::Mat4 arg1; ok &= luaval_to_matrix(tolua_S, 3, &arg1); if (!ok) { break; } @@ -8699,9 +8699,9 @@ int lua_cocos2dx_Node_setPosition3D(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector3 arg0; + cocos2d::Vec3 arg0; - ok &= luaval_to_vector3(tolua_S, 2, &arg0); + ok &= luaval_to_Vec3(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPosition3D(arg0); @@ -8836,7 +8836,7 @@ int lua_cocos2dx_Node_getWorldToNodeTransform(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Matrix ret = cobj->getWorldToNodeTransform(); + cocos2d::Mat4 ret = cobj->getWorldToNodeTransform(); matrix_to_luaval(tolua_S, ret); return 1; } @@ -10612,7 +10612,7 @@ int lua_cocos2dx_Director_loadMatrix(lua_State* tolua_S) if (argc == 2) { cocos2d::MATRIX_STACK_TYPE arg0; - cocos2d::Matrix arg1; + cocos2d::Mat4 arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); @@ -10838,7 +10838,7 @@ int lua_cocos2dx_Director_getVisibleOrigin(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getVisibleOrigin(); + cocos2d::Vec2 ret = cobj->getVisibleOrigin(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -11057,12 +11057,12 @@ int lua_cocos2dx_Director_convertToUI(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertToUI(arg0); + cocos2d::Vec2 ret = cobj->convertToUI(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -11722,12 +11722,12 @@ int lua_cocos2dx_Director_convertToGL(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->convertToGL(arg0); + cocos2d::Vec2 ret = cobj->convertToGL(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -12040,7 +12040,7 @@ int lua_cocos2dx_Director_getMatrix(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; - cocos2d::Matrix ret = cobj->getMatrix(arg0); + cocos2d::Mat4 ret = cobj->getMatrix(arg0); matrix_to_luaval(tolua_S, ret); return 1; } @@ -12711,7 +12711,7 @@ int lua_cocos2dx_Director_multiplyMatrix(lua_State* tolua_S) if (argc == 2) { cocos2d::MATRIX_STACK_TYPE arg0; - cocos2d::Matrix arg1; + cocos2d::Mat4 arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); @@ -16299,7 +16299,7 @@ int lua_cocos2dx_SpriteFrame_initWithTexture(lua_State* tolua_S) ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 5, &arg3); if (!ok) { break; } @@ -16501,7 +16501,7 @@ int lua_cocos2dx_SpriteFrame_setOffsetInPixels(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -16727,7 +16727,7 @@ int lua_cocos2dx_SpriteFrame_setOffset(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -16775,7 +16775,7 @@ int lua_cocos2dx_SpriteFrame_getOffset(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getOffset(); + const cocos2d::Vec2& ret = cobj->getOffset(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -16868,7 +16868,7 @@ int lua_cocos2dx_SpriteFrame_initWithTextureFilename(lua_State* tolua_S) ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 5, &arg3); if (!ok) { break; } @@ -16984,7 +16984,7 @@ int lua_cocos2dx_SpriteFrame_getOffsetInPixels(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getOffsetInPixels(); + const cocos2d::Vec2& ret = cobj->getOffsetInPixels(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -17069,7 +17069,7 @@ int lua_cocos2dx_SpriteFrame_create(lua_State* tolua_S) bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Size arg4; @@ -17132,7 +17132,7 @@ int lua_cocos2dx_SpriteFrame_createWithTexture(lua_State* tolua_S) bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Size arg4; @@ -19002,8 +19002,8 @@ int lua_cocos2dx_RotateBy_create(lua_State* tolua_S) double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } - cocos2d::Vector3 arg1; - ok &= luaval_to_vector3(tolua_S, 3, &arg1); + cocos2d::Vec3 arg1; + ok &= luaval_to_Vec3(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1); object_to_luaval(tolua_S, "cc.RotateBy",(cocos2d::RotateBy*)ret); @@ -19057,7 +19057,7 @@ int lua_cocos2dx_MoveBy_create(lua_State* tolua_S) if (argc == 2) { double arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); if(!ok) @@ -19112,7 +19112,7 @@ int lua_cocos2dx_MoveTo_create(lua_State* tolua_S) if (argc == 2) { double arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); if(!ok) @@ -19281,7 +19281,7 @@ int lua_cocos2dx_JumpBy_create(lua_State* tolua_S) if (argc == 4) { double arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; double arg2; int arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); @@ -19340,7 +19340,7 @@ int lua_cocos2dx_JumpTo_create(lua_State* tolua_S) if (argc == 4) { double arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; double arg2; int arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); @@ -20438,8 +20438,8 @@ int lua_cocos2dx_ActionCamera_setEye(lua_State* tolua_S) ok = true; do{ if (argc == 1) { - cocos2d::Vector3 arg0; - ok &= luaval_to_vector3(tolua_S, 2, &arg0); + cocos2d::Vec3 arg0; + ok &= luaval_to_Vec3(tolua_S, 2, &arg0); if (!ok) { break; } cobj->setEye(arg0); @@ -20487,8 +20487,8 @@ int lua_cocos2dx_ActionCamera_getEye(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector3& ret = cobj->getEye(); - vector3_to_luaval(tolua_S, ret); + const cocos2d::Vec3& ret = cobj->getEye(); + Vec3_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEye",argc, 0); @@ -20529,9 +20529,9 @@ int lua_cocos2dx_ActionCamera_setUp(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector3 arg0; + cocos2d::Vec3 arg0; - ok &= luaval_to_vector3(tolua_S, 2, &arg0); + ok &= luaval_to_Vec3(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setUp(arg0); @@ -20577,8 +20577,8 @@ int lua_cocos2dx_ActionCamera_getCenter(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector3& ret = cobj->getCenter(); - vector3_to_luaval(tolua_S, ret); + const cocos2d::Vec3& ret = cobj->getCenter(); + Vec3_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCenter",argc, 0); @@ -20619,9 +20619,9 @@ int lua_cocos2dx_ActionCamera_setCenter(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector3 arg0; + cocos2d::Vec3 arg0; - ok &= luaval_to_vector3(tolua_S, 2, &arg0); + ok &= luaval_to_Vec3(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCenter(arg0); @@ -20667,8 +20667,8 @@ int lua_cocos2dx_ActionCamera_getUp(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector3& ret = cobj->getUp(); - vector3_to_luaval(tolua_S, ret); + const cocos2d::Vec3& ret = cobj->getUp(); + Vec3_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUp",argc, 0); @@ -24065,7 +24065,7 @@ int lua_cocos2dx_Place_create(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; @@ -24929,7 +24929,7 @@ int lua_cocos2dx_Lens3D_setPosition(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -25069,7 +25069,7 @@ int lua_cocos2dx_Lens3D_getPosition(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getPosition(); + const cocos2d::Vec2& ret = cobj->getPosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -25146,7 +25146,7 @@ int lua_cocos2dx_Lens3D_create(lua_State* tolua_S) { double arg0; cocos2d::Size arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); @@ -25399,7 +25399,7 @@ int lua_cocos2dx_Ripple3D_setPosition(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -25447,7 +25447,7 @@ int lua_cocos2dx_Ripple3D_getPosition(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getPosition(); + const cocos2d::Vec2& ret = cobj->getPosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -25480,7 +25480,7 @@ int lua_cocos2dx_Ripple3D_create(lua_State* tolua_S) { double arg0; cocos2d::Size arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; double arg3; unsigned int arg4; double arg5; @@ -26287,7 +26287,7 @@ int lua_cocos2dx_Twirl_setPosition(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -26335,7 +26335,7 @@ int lua_cocos2dx_Twirl_getPosition(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getPosition(); + const cocos2d::Vec2& ret = cobj->getPosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -26368,7 +26368,7 @@ int lua_cocos2dx_Twirl_create(lua_State* tolua_S) { double arg0; cocos2d::Size arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; unsigned int arg3; double arg4; ok &= luaval_to_number(tolua_S, 2,&arg0); @@ -26729,7 +26729,7 @@ int lua_cocos2dx_ShuffleTiles_placeTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; cocos2d::Tile* arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -26934,7 +26934,7 @@ int lua_cocos2dx_FadeOutTRTiles_turnOnTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -26980,7 +26980,7 @@ int lua_cocos2dx_FadeOutTRTiles_turnOffTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -27026,7 +27026,7 @@ int lua_cocos2dx_FadeOutTRTiles_transformTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; double arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -27239,7 +27239,7 @@ int lua_cocos2dx_FadeOutUpTiles_transformTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; double arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -27399,7 +27399,7 @@ int lua_cocos2dx_TurnOffTiles_turnOnTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -27445,7 +27445,7 @@ int lua_cocos2dx_TurnOffTiles_turnOffTile(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -28319,7 +28319,7 @@ int lua_cocos2dx_CardinalSplineTo_updatePosition(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -28668,9 +28668,9 @@ int lua_cocos2dx_DrawNode_drawQuadraticBezier(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 5) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; unsigned int arg3; cocos2d::Color4F arg4; @@ -28726,7 +28726,7 @@ int lua_cocos2dx_DrawNode_onDraw(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Matrix arg0; + cocos2d::Mat4 arg0; bool arg1; ok &= luaval_to_matrix(tolua_S, 2, &arg0); @@ -28818,9 +28818,9 @@ int lua_cocos2dx_DrawNode_drawTriangle(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 4) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; cocos2d::Color4F arg3; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -28873,7 +28873,7 @@ int lua_cocos2dx_DrawNode_drawDot(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 3) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; double arg1; cocos2d::Color4F arg2; @@ -28925,10 +28925,10 @@ int lua_cocos2dx_DrawNode_drawCubicBezier(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 6) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; - cocos2d::Vector2 arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; unsigned int arg4; cocos2d::Color4F arg5; @@ -28986,8 +28986,8 @@ int lua_cocos2dx_DrawNode_drawSegment(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 4) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; double arg2; cocos2d::Color4F arg3; @@ -30998,7 +30998,7 @@ int lua_cocos2dx_GLProgram_setUniformsForBuiltins(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { - cocos2d::Matrix arg0; + cocos2d::Mat4 arg0; ok &= luaval_to_matrix(tolua_S, 2, &arg0); if (!ok) { break; } @@ -33601,7 +33601,7 @@ int lua_cocos2dx_Label_setBMFontFilePath(lua_State* tolua_S) if (argc == 2) { std::string arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); @@ -34834,7 +34834,7 @@ int lua_cocos2dx_Label_createWithBMFont(lua_State* tolua_S) std::string arg1; cocos2d::TextHAlignment arg2; int arg3; - cocos2d::Vector2 arg4; + cocos2d::Vec2 arg4; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); @@ -35518,7 +35518,7 @@ int lua_cocos2dx_LabelBMFont_initWithString(lua_State* tolua_S) std::string arg1; double arg2; cocos2d::TextHAlignment arg3; - cocos2d::Vector2 arg4; + cocos2d::Vec2 arg4; ok &= luaval_to_std_string(tolua_S, 2,&arg0); @@ -35674,7 +35674,7 @@ int lua_cocos2dx_LabelBMFont_setFntFile(lua_State* tolua_S) if (argc == 2) { std::string arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); @@ -35883,7 +35883,7 @@ int lua_cocos2dx_LabelBMFont_create(lua_State* tolua_S) cocos2d::TextHAlignment arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } - cocos2d::Vector2 arg4; + cocos2d::Vec2 arg4; ok &= luaval_to_vector2(tolua_S, 6, &arg4); if (!ok) { break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3, arg4); @@ -36407,7 +36407,7 @@ int lua_cocos2dx_LayerGradient_setVector(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -36593,7 +36593,7 @@ int lua_cocos2dx_LayerGradient_getVector(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getVector(); + const cocos2d::Vec2& ret = cobj->getVector(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -36837,7 +36837,7 @@ int lua_cocos2dx_LayerGradient_create(lua_State* tolua_S) cocos2d::Color4B arg1; ok &=luaval_to_color4b(tolua_S, 3, &arg1); if (!ok) { break; } - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_vector2(tolua_S, 4, &arg2); if (!ok) { break; } cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1, arg2); @@ -43428,7 +43428,7 @@ int lua_cocos2dx_Sprite_getOffsetPosition(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getOffsetPosition(); + const cocos2d::Vec2& ret = cobj->getOffsetPosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -44587,7 +44587,7 @@ int lua_cocos2dx_ProgressTimer_setBarChangeRate(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -44811,7 +44811,7 @@ int lua_cocos2dx_ProgressTimer_setMidpoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -44859,7 +44859,7 @@ int lua_cocos2dx_ProgressTimer_getBarChangeRate(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getBarChangeRate(); + cocos2d::Vec2 ret = cobj->getBarChangeRate(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -44956,7 +44956,7 @@ int lua_cocos2dx_ProgressTimer_getMidpoint(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getMidpoint(); + cocos2d::Vec2 ret = cobj->getMidpoint(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -45769,7 +45769,7 @@ int lua_cocos2dx_RenderTexture_setVirtualViewport(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 3) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; cocos2d::Rect arg1; cocos2d::Rect arg2; @@ -48088,7 +48088,7 @@ int lua_cocos2dx_ParticleSystem_setPosVar(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -48724,7 +48724,7 @@ int lua_cocos2dx_ParticleSystem_getGravity(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getGravity(); + const cocos2d::Vec2& ret = cobj->getGravity(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -49130,7 +49130,7 @@ int lua_cocos2dx_ParticleSystem_getPosVar(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getPosVar(); + const cocos2d::Vec2& ret = cobj->getPosVar(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -49394,7 +49394,7 @@ int lua_cocos2dx_ParticleSystem_getSourcePosition(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getSourcePosition(); + const cocos2d::Vec2& ret = cobj->getSourcePosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -49575,7 +49575,7 @@ int lua_cocos2dx_ParticleSystem_updateQuadWithParticle(lua_State* tolua_S) if (argc == 2) { cocos2d::sParticle* arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; #pragma warning NO CONVERSION TO NATIVE FOR sParticle*; @@ -50432,7 +50432,7 @@ int lua_cocos2dx_ParticleSystem_setSourcePosition(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -51292,7 +51292,7 @@ int lua_cocos2dx_ParticleSystem_setGravity(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -53920,7 +53920,7 @@ int lua_cocos2dx_GridBase_getStep(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getStep(); + const cocos2d::Vec2& ret = cobj->getStep(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -54005,7 +54005,7 @@ int lua_cocos2dx_GridBase_setStep(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -55381,7 +55381,7 @@ int lua_cocos2dx_GLViewProtocol_getVisibleOrigin(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getVisibleOrigin(); + cocos2d::Vec2 ret = cobj->getVisibleOrigin(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -58315,8 +58315,8 @@ int lua_cocos2dx_ParallaxNode_addChild(lua_State* tolua_S) { cocos2d::Node* arg0; int arg1; - cocos2d::Vector2 arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); @@ -58514,7 +58514,7 @@ int lua_cocos2dx_TMXObjectGroup_setPositionOffset(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -58609,7 +58609,7 @@ int lua_cocos2dx_TMXObjectGroup_getPositionOffset(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getPositionOffset(); + const cocos2d::Vec2& ret = cobj->getPositionOffset(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -60905,7 +60905,7 @@ int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -60916,7 +60916,7 @@ int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; cocos2d::TMXTileFlags_* arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -60966,12 +60966,12 @@ int lua_cocos2dx_TMXLayer_getPositionAt(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPositionAt(arg0); + cocos2d::Vec2 ret = cobj->getPositionAt(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -61374,7 +61374,7 @@ int lua_cocos2dx_TMXLayer_removeTileAt(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -61515,7 +61515,7 @@ int lua_cocos2dx_TMXLayer_setTileGID(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 2,&arg0); if (!ok) { break; } - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 3, &arg1); if (!ok) { break; } @@ -61534,7 +61534,7 @@ int lua_cocos2dx_TMXLayer_setTileGID(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 2,&arg0); if (!ok) { break; } - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 3, &arg1); if (!ok) { break; } @@ -61899,7 +61899,7 @@ int lua_cocos2dx_TMXLayer_getTileAt(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -62855,7 +62855,7 @@ int lua_cocos2dx_TileMapAtlas_getTileAt(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -62903,7 +62903,7 @@ int lua_cocos2dx_TileMapAtlas_setTile(lua_State* tolua_S) if (argc == 2) { cocos2d::Color3B arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_color3b(tolua_S, 2, &arg0); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp index b6bce1338b..6ca6cda628 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp @@ -2027,7 +2027,7 @@ int lua_cocos2dx_extension_Control_getTouchLocation(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.Touch",&arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getTouchLocation(arg0); + cocos2d::Vec2 ret = cobj->getTouchLocation(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2506,7 +2506,7 @@ int lua_cocos2dx_extension_ControlButton_setLabelAnchorPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -2554,7 +2554,7 @@ int lua_cocos2dx_extension_ControlButton_getLabelAnchorPoint(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getLabelAnchorPoint(); + const cocos2d::Vec2& ret = cobj->getLabelAnchorPoint(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4170,7 +4170,7 @@ int lua_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(lua_State* tolu if (argc == 2) { cocos2d::Node* arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); @@ -4267,7 +4267,7 @@ int lua_cocos2dx_extension_ControlHuePicker_getStartPos(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getStartPos(); + cocos2d::Vec2 ret = cobj->getStartPos(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4613,7 +4613,7 @@ int lua_cocos2dx_extension_ControlHuePicker_create(lua_State* tolua_S) if (argc == 2) { cocos2d::Node* arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); if(!ok) @@ -4769,7 +4769,7 @@ int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPo if (argc == 2) { cocos2d::Node* arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); @@ -4820,7 +4820,7 @@ int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos(lua_Sta { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getStartPos(); + cocos2d::Vec2 ret = cobj->getStartPos(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5118,7 +5118,7 @@ int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_create(lua_State* t if (argc == 2) { cocos2d::Node* arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); if(!ok) @@ -5828,7 +5828,7 @@ int lua_cocos2dx_extension_ControlPotentiometer_setPreviousLocation(lua_State* t argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -6008,10 +6008,10 @@ int lua_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoi argc = lua_gettop(tolua_S)-1; if (argc == 4) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; - cocos2d::Vector2 arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -6064,7 +6064,7 @@ int lua_cocos2dx_extension_ControlPotentiometer_potentiometerBegan(lua_State* to argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -6292,7 +6292,7 @@ int lua_cocos2dx_extension_ControlPotentiometer_getPreviousLocation(lua_State* t { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPreviousLocation(); + cocos2d::Vec2 ret = cobj->getPreviousLocation(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6334,8 +6334,8 @@ int lua_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint(lua argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -6384,7 +6384,7 @@ int lua_cocos2dx_extension_ControlPotentiometer_potentiometerEnded(lua_State* to argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -6619,7 +6619,7 @@ int lua_cocos2dx_extension_ControlPotentiometer_potentiometerMoved(lua_State* to argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -6824,7 +6824,7 @@ int lua_cocos2dx_extension_ControlSlider_locationFromTouch(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.Touch",&arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->locationFromTouch(arg0); + cocos2d::Vec2 ret = cobj->locationFromTouch(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -8249,7 +8249,7 @@ int lua_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation(lua_Sta argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -9374,7 +9374,7 @@ int lua_cocos2dx_extension_ControlSwitch_locationFromTouch(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.Touch",&arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->locationFromTouch(arg0); + cocos2d::Vec2 ret = cobj->locationFromTouch(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9688,7 +9688,7 @@ int lua_cocos2dx_extension_ScrollView_setContentOffsetInDuration(lua_State* tolu argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; double arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -10253,7 +10253,7 @@ int lua_cocos2dx_extension_ScrollView_setContentOffset(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -10263,7 +10263,7 @@ int lua_cocos2dx_extension_ScrollView_setContentOffset(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; bool arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -10541,7 +10541,7 @@ int lua_cocos2dx_extension_ScrollView_getContentOffset(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getContentOffset(); + cocos2d::Vec2 ret = cobj->getContentOffset(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -10816,7 +10816,7 @@ int lua_cocos2dx_extension_ScrollView_maxContainerOffset(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->maxContainerOffset(); + cocos2d::Vec2 ret = cobj->maxContainerOffset(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -11001,7 +11001,7 @@ int lua_cocos2dx_extension_ScrollView_minContainerOffset(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->minContainerOffset(); + cocos2d::Vec2 ret = cobj->minContainerOffset(); vector2_to_luaval(tolua_S, ret); return 1; } diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp index 39f5662b2b..dcb96d7212 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp @@ -35,7 +35,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getGravity(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getGravity(); + cocos2d::Vec2 ret = cobj->getGravity(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -121,7 +121,7 @@ int lua_cocos2dx_physics_PhysicsWorld_setGravity(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -413,7 +413,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getShapes(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -513,7 +513,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getShape(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -1335,7 +1335,7 @@ int lua_cocos2dx_physics_PhysicsShape_containsPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -1516,7 +1516,7 @@ int lua_cocos2dx_physics_PhysicsShape_getCenter(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getCenter(); + cocos2d::Vec2 ret = cobj->getCenter(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1828,7 +1828,7 @@ int lua_cocos2dx_physics_PhysicsShape_getOffset(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getOffset(); + cocos2d::Vec2 ret = cobj->getOffset(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2293,7 +2293,7 @@ int lua_cocos2dx_physics_PhysicsShapeCircle_create(lua_State* tolua_S) { double arg0; cocos2d::PhysicsMaterial arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -2375,7 +2375,7 @@ int lua_cocos2dx_physics_PhysicsShapeCircle_calculateMoment(lua_State* tolua_S) { double arg0; double arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -2545,7 +2545,7 @@ int lua_cocos2dx_physics_PhysicsShapeBox_create(lua_State* tolua_S) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -2627,7 +2627,7 @@ int lua_cocos2dx_physics_PhysicsShapeBox_calculateMoment(lua_State* tolua_S) { double arg0; cocos2d::Size arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -2746,7 +2746,7 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_getPoint(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPoint(arg0); + cocos2d::Vec2 ret = cobj->getPoint(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2811,7 +2811,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointB(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPointB(); + cocos2d::Vec2 ret = cobj->getPointB(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2855,7 +2855,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointA(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPointA(); + cocos2d::Vec2 ret = cobj->getPointA(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2886,8 +2886,8 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_create(lua_State* tolua_S) if (argc == 2) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); if(!ok) @@ -2898,8 +2898,8 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_create(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; cocos2d::PhysicsMaterial arg2; ok &= luaval_to_vector2(tolua_S, 2, &arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); @@ -2912,8 +2912,8 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_create(lua_State* tolua_S) } if (argc == 4) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; cocos2d::PhysicsMaterial arg2; double arg3; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -3056,7 +3056,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeBox_create(lua_State* tolua_S) cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; double arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); @@ -3644,11 +3644,11 @@ int lua_cocos2dx_physics_PhysicsBody_applyImpulse(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if (!ok) { break; } - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 3, &arg1); if (!ok) { break; } @@ -3659,7 +3659,7 @@ int lua_cocos2dx_physics_PhysicsBody_applyImpulse(lua_State* tolua_S) ok = true; do{ if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if (!ok) { break; } @@ -3747,11 +3747,11 @@ int lua_cocos2dx_physics_PhysicsBody_applyForce(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if (!ok) { break; } - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 3, &arg1); if (!ok) { break; } @@ -3762,7 +3762,7 @@ int lua_cocos2dx_physics_PhysicsBody_applyForce(lua_State* tolua_S) ok = true; do{ if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if (!ok) { break; } @@ -4008,7 +4008,7 @@ int lua_cocos2dx_physics_PhysicsBody_getVelocity(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getVelocity(); + cocos2d::Vec2 ret = cobj->getVelocity(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4287,7 +4287,7 @@ int lua_cocos2dx_physics_PhysicsBody_getPositionOffset(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPositionOffset(); + cocos2d::Vec2 ret = cobj->getPositionOffset(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4465,7 +4465,7 @@ int lua_cocos2dx_physics_PhysicsBody_getPosition(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getPosition(); + cocos2d::Vec2 ret = cobj->getPosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4733,12 +4733,12 @@ int lua_cocos2dx_physics_PhysicsBody_local2World(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->local2World(arg0); + cocos2d::Vec2 ret = cobj->local2World(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5048,12 +5048,12 @@ int lua_cocos2dx_physics_PhysicsBody_world2Local(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->world2Local(arg0); + cocos2d::Vec2 ret = cobj->world2Local(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5314,7 +5314,7 @@ int lua_cocos2dx_physics_PhysicsBody_setVelocity(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -5452,7 +5452,7 @@ int lua_cocos2dx_physics_PhysicsBody_setPositionOffset(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -5632,12 +5632,12 @@ int lua_cocos2dx_physics_PhysicsBody_getVelocityAtLocalPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getVelocityAtLocalPoint(arg0); + cocos2d::Vec2 ret = cobj->getVelocityAtLocalPoint(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -5862,12 +5862,12 @@ int lua_cocos2dx_physics_PhysicsBody_getVelocityAtWorldPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getVelocityAtWorldPoint(arg0); + cocos2d::Vec2 ret = cobj->getVelocityAtWorldPoint(arg0); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6099,7 +6099,7 @@ int lua_cocos2dx_physics_PhysicsBody_createBox(lua_State* tolua_S) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -6134,8 +6134,8 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeSegment(lua_State* tolua_S) if (argc == 2) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; ok &= luaval_to_vector2(tolua_S, 2, &arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); if(!ok) @@ -6146,8 +6146,8 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeSegment(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; cocos2d::PhysicsMaterial arg2; ok &= luaval_to_vector2(tolua_S, 2, &arg0); ok &= luaval_to_vector2(tolua_S, 3, &arg1); @@ -6160,8 +6160,8 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeSegment(lua_State* tolua_S) } if (argc == 4) { - cocos2d::Vector2 arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; cocos2d::PhysicsMaterial arg2; double arg3; ok &= luaval_to_vector2(tolua_S, 2, &arg0); @@ -6299,7 +6299,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeBox(lua_State* tolua_S) cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; double arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); @@ -6359,7 +6359,7 @@ int lua_cocos2dx_physics_PhysicsBody_createCircle(lua_State* tolua_S) { double arg0; cocos2d::PhysicsMaterial arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -6913,7 +6913,7 @@ int lua_cocos2dx_physics_PhysicsContactPreSolve_getSurfaceVelocity(lua_State* to { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getSurfaceVelocity(); + cocos2d::Vec2 ret = cobj->getSurfaceVelocity(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6955,7 +6955,7 @@ int lua_cocos2dx_physics_PhysicsContactPreSolve_setSurfaceVelocity(lua_State* to argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -7119,7 +7119,7 @@ int lua_cocos2dx_physics_PhysicsContactPostSolve_getSurfaceVelocity(lua_State* t { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getSurfaceVelocity(); + cocos2d::Vec2 ret = cobj->getSurfaceVelocity(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -8184,7 +8184,7 @@ int lua_cocos2dx_physics_PhysicsJointFixed_construct(lua_State* tolua_S) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0); ok &= luaval_to_object(tolua_S, 3, "cc.PhysicsBody",&arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -8250,7 +8250,7 @@ int lua_cocos2dx_physics_PhysicsJointLimit_setAnchr2(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -8296,7 +8296,7 @@ int lua_cocos2dx_physics_PhysicsJointLimit_setAnchr1(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -8390,7 +8390,7 @@ int lua_cocos2dx_physics_PhysicsJointLimit_getAnchr2(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchr2(); + cocos2d::Vec2 ret = cobj->getAnchr2(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -8434,7 +8434,7 @@ int lua_cocos2dx_physics_PhysicsJointLimit_getAnchr1(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchr1(); + cocos2d::Vec2 ret = cobj->getAnchr1(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -8606,10 +8606,10 @@ int lua_cocos2dx_physics_PhysicsJointLimit_construct(lua_State* tolua_S) cocos2d::PhysicsBody* arg1; ok &= luaval_to_object(tolua_S, 3, "cc.PhysicsBody",&arg1); if (!ok) { break; } - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_vector2(tolua_S, 4, &arg2); if (!ok) { break; } - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 5, &arg3); if (!ok) { break; } double arg4; @@ -8634,10 +8634,10 @@ int lua_cocos2dx_physics_PhysicsJointLimit_construct(lua_State* tolua_S) cocos2d::PhysicsBody* arg1; ok &= luaval_to_object(tolua_S, 3, "cc.PhysicsBody",&arg1); if (!ok) { break; } - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_vector2(tolua_S, 4, &arg2); if (!ok) { break; } - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_vector2(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::PhysicsJointLimit* ret = cocos2d::PhysicsJointLimit::construct(arg0, arg1, arg2, arg3); @@ -8701,7 +8701,7 @@ int lua_cocos2dx_physics_PhysicsJointPin_construct(lua_State* tolua_S) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0); ok &= luaval_to_object(tolua_S, 3, "cc.PhysicsBody",&arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -8848,8 +8848,8 @@ int lua_cocos2dx_physics_PhysicsJointDistance_construct(lua_State* tolua_S) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; - cocos2d::Vector2 arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0); ok &= luaval_to_object(tolua_S, 3, "cc.PhysicsBody",&arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); @@ -8918,7 +8918,7 @@ int lua_cocos2dx_physics_PhysicsJointSpring_setAnchr2(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -8964,7 +8964,7 @@ int lua_cocos2dx_physics_PhysicsJointSpring_setAnchr1(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -9146,7 +9146,7 @@ int lua_cocos2dx_physics_PhysicsJointSpring_getAnchr2(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchr2(); + cocos2d::Vec2 ret = cobj->getAnchr2(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9190,7 +9190,7 @@ int lua_cocos2dx_physics_PhysicsJointSpring_getAnchr1(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchr1(); + cocos2d::Vec2 ret = cobj->getAnchr1(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9359,8 +9359,8 @@ int lua_cocos2dx_physics_PhysicsJointSpring_construct(lua_State* tolua_S) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; - cocos2d::Vector2 arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; double arg4; double arg5; ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0); @@ -9441,7 +9441,7 @@ int lua_cocos2dx_physics_PhysicsJointGroove_setAnchr2(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -9487,7 +9487,7 @@ int lua_cocos2dx_physics_PhysicsJointGroove_setGrooveA(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -9533,7 +9533,7 @@ int lua_cocos2dx_physics_PhysicsJointGroove_setGrooveB(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -9581,7 +9581,7 @@ int lua_cocos2dx_physics_PhysicsJointGroove_getGrooveA(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getGrooveA(); + cocos2d::Vec2 ret = cobj->getGrooveA(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9625,7 +9625,7 @@ int lua_cocos2dx_physics_PhysicsJointGroove_getGrooveB(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getGrooveB(); + cocos2d::Vec2 ret = cobj->getGrooveB(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9669,7 +9669,7 @@ int lua_cocos2dx_physics_PhysicsJointGroove_getAnchr2(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchr2(); + cocos2d::Vec2 ret = cobj->getAnchr2(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9702,9 +9702,9 @@ int lua_cocos2dx_physics_PhysicsJointGroove_construct(lua_State* tolua_S) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; - cocos2d::Vector2 arg2; - cocos2d::Vector2 arg3; - cocos2d::Vector2 arg4; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; + cocos2d::Vec2 arg4; ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0); ok &= luaval_to_object(tolua_S, 3, "cc.PhysicsBody",&arg1); ok &= luaval_to_vector2(tolua_S, 4, &arg2); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp index e06e9d847e..7a3c4ab0d6 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp @@ -122,7 +122,7 @@ int lua_cocos2dx_spine_Skeleton_onDraw(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::Matrix arg0; + cocos2d::Mat4 arg0; bool arg1; ok &= luaval_to_matrix(tolua_S, 2, &arg0); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp index d912d49a5e..b236889cd1 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp @@ -3026,7 +3026,7 @@ int lua_cocos2dx_studio_ContourData_addVertex(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -3813,7 +3813,7 @@ int lua_cocos2dx_studio_DisplayManager_getAnchorPointInPoints(lua_State* tolua_S { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchorPointInPoints(); + cocos2d::Vec2 ret = cobj->getAnchorPointInPoints(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -4198,7 +4198,7 @@ int lua_cocos2dx_studio_DisplayManager_containPoint(lua_State* tolua_S) ok = true; do{ if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if (!ok) { break; } @@ -4434,7 +4434,7 @@ int lua_cocos2dx_studio_DisplayManager_getAnchorPoint(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getAnchorPoint(); + cocos2d::Vec2 ret = cobj->getAnchorPoint(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -6051,7 +6051,7 @@ int lua_cocos2dx_studio_Bone_getNodeToArmatureTransform(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Matrix ret = cobj->getNodeToArmatureTransform(); + cocos2d::Mat4 ret = cobj->getNodeToArmatureTransform(); matrix_to_luaval(tolua_S, ret); return 1; } @@ -9615,7 +9615,7 @@ int lua_cocos2dx_studio_Skin_getNodeToWorldTransformAR(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Matrix ret = cobj->getNodeToWorldTransformAR(); + cocos2d::Mat4 ret = cobj->getNodeToWorldTransformAR(); matrix_to_luaval(tolua_S, ret); return 1; } diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 2baacc9523..0017040254 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -841,7 +841,7 @@ int lua_cocos2dx_ui_Widget_setSizePercent(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -1069,7 +1069,7 @@ int lua_cocos2dx_ui_Widget_getTouchEndPos(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getTouchEndPos(); + const cocos2d::Vec2& ret = cobj->getTouchEndPos(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -1111,7 +1111,7 @@ int lua_cocos2dx_ui_Widget_setPositionPercent(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -1879,7 +1879,7 @@ int lua_cocos2dx_ui_Widget_getWorldPosition(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::Vector2 ret = cobj->getWorldPosition(); + cocos2d::Vec2 ret = cobj->getWorldPosition(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2059,7 +2059,7 @@ int lua_cocos2dx_ui_Widget_getTouchMovePos(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getTouchMovePos(); + const cocos2d::Vec2& ret = cobj->getTouchMovePos(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2331,7 +2331,7 @@ int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getSizePercent(); + const cocos2d::Vec2& ret = cobj->getSizePercent(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2375,7 +2375,7 @@ int lua_cocos2dx_ui_Widget_getTouchStartPos(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getTouchStartPos(); + const cocos2d::Vec2& ret = cobj->getTouchStartPos(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -2553,7 +2553,7 @@ int lua_cocos2dx_ui_Widget_clippingParentAreaContainPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -3013,7 +3013,7 @@ int lua_cocos2dx_ui_Widget_getPositionPercent(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getPositionPercent(); + const cocos2d::Vec2& ret = cobj->getPositionPercent(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -3055,7 +3055,7 @@ int lua_cocos2dx_ui_Widget_hitTest(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -3238,7 +3238,7 @@ int lua_cocos2dx_ui_Widget_checkChildInfo(lua_State* tolua_S) { int arg0; cocos2d::ui::Widget* arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); @@ -3567,7 +3567,7 @@ int lua_cocos2dx_ui_Layout_setBackGroundColorVector(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -3799,7 +3799,7 @@ int lua_cocos2dx_ui_Layout_getBackGroundColorVector(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vector2& ret = cobj->getBackGroundColorVector(); + const cocos2d::Vec2& ret = cobj->getBackGroundColorVector(); vector2_to_luaval(tolua_S, ret); return 1; } @@ -9574,7 +9574,7 @@ int lua_cocos2dx_ui_ScrollView_scrollToPercentBothDirection(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 3) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; double arg1; bool arg2; @@ -10533,7 +10533,7 @@ int lua_cocos2dx_ui_ScrollView_jumpToPercentBothDirection(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -14325,7 +14325,7 @@ int lua_cocos2dx_ui_TextField_hitTest(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) @@ -16388,7 +16388,7 @@ int lua_cocos2dx_ui_RichText_setAnchorPoint(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::Vector2 arg0; + cocos2d::Vec2 arg0; ok &= luaval_to_vector2(tolua_S, 2, &arg0); if(!ok) diff --git a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp index 5e60eb4e1d..f224315b62 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp @@ -493,7 +493,7 @@ int LuaEngine::handleTouchEvent(void* data) Touch* touch = touchScriptData->touch; if (NULL != touch) { - const cocos2d::Vector2 pt = Director::getInstance()->convertToGL(touch->getLocationInView()); + const cocos2d::Vec2 pt = Director::getInstance()->convertToGL(touch->getLocationInView()); _stack->pushFloat(pt.x); _stack->pushFloat(pt.y); ret = _stack->executeFunctionByHandler(handler, 3); @@ -546,7 +546,7 @@ int LuaEngine::handleTouchesEvent(void* data) int i = 1; for (auto& touch : touchesScriptData->touches) { - cocos2d::Vector2 pt = pDirector->convertToGL(touch->getLocationInView()); + cocos2d::Vec2 pt = pDirector->convertToGL(touch->getLocationInView()); lua_pushnumber(L, pt.x); lua_rawseti(L, -2, i++); lua_pushnumber(L, pt.y); diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp index 16e69a0273..b782746e51 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -271,7 +271,7 @@ bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue) return ok; } -bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vector2* outValue) +bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vec2* outValue) { if (nullptr == L || nullptr == outValue) return false; @@ -303,7 +303,7 @@ bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vector2* outValue) return ok; } -bool luaval_to_vector3(lua_State* L,int lo,cocos2d::Vector3* outValue) +bool luaval_to_Vec3(lua_State* L,int lo,cocos2d::Vec3* outValue) { if (nullptr == L || nullptr == outValue) return false; @@ -903,7 +903,7 @@ bool luaval_to_ttfconfig(lua_State* L,int lo, cocos2d::TTFConfig* outValue) return false; } -bool luaval_to_matrix(lua_State* L, int lo, cocos2d::Matrix* outValue ) +bool luaval_to_matrix(lua_State* L, int lo, cocos2d::Mat4* outValue ) { if (nullptr == L || nullptr == outValue) return false; @@ -1145,7 +1145,7 @@ bool luaval_to_dictionary(lua_State* L,int lo, __Dictionary** outValue) return ok; } -bool luaval_to_array_of_vector2(lua_State* L,int lo,cocos2d::Vector2 **points, int *numPoints) +bool luaval_to_array_of_vector2(lua_State* L,int lo,cocos2d::Vec2 **points, int *numPoints) { if (NULL == L) return false; @@ -1167,7 +1167,7 @@ bool luaval_to_array_of_vector2(lua_State* L,int lo,cocos2d::Vector2 **points, i size_t len = lua_objlen(L, lo); if (len > 0) { - cocos2d::Vector2* array = (cocos2d::Vector2*) new Vector2[len]; + cocos2d::Vec2* array = (cocos2d::Vec2*) new Vec2[len]; if (NULL == array) return false; for (uint32_t i = 0; i < len; ++i) @@ -1697,7 +1697,7 @@ bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector* ret) return ok; } -void vector2_array_to_luaval(lua_State* L,const cocos2d::Vector2* points, int count) +void vector2_array_to_luaval(lua_State* L,const cocos2d::Vec2* points, int count) { if (NULL == L) return; @@ -1710,7 +1710,7 @@ void vector2_array_to_luaval(lua_State* L,const cocos2d::Vector2* points, int co } } -void vector2_to_luaval(lua_State* L,const cocos2d::Vector2& vec2) +void vector2_to_luaval(lua_State* L,const cocos2d::Vec2& vec2) { if (NULL == L) return; @@ -1724,7 +1724,7 @@ void vector2_to_luaval(lua_State* L,const cocos2d::Vector2& vec2) } -void vector3_to_luaval(lua_State* L,const cocos2d::Vector3& vec3) +void Vec3_to_luaval(lua_State* L,const cocos2d::Vec3& vec3) { if (NULL == L) return; @@ -2406,7 +2406,7 @@ void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue) } } -void matrix_to_luaval(lua_State* L, const cocos2d::Matrix& mat) +void matrix_to_luaval(lua_State* L, const cocos2d::Mat4& mat) { if (nullptr == L) return; diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index 791d169194..f5f7a44570 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -58,8 +58,8 @@ extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue); extern bool luaval_to_long(lua_State* L,int lo, long* outValue); extern bool luaval_to_ssize(lua_State* L,int lo, ssize_t* outValue); -extern bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vector2* outValue); -extern bool luaval_to_vector3(lua_State* L,int lo,cocos2d::Vector3* outValue); +extern bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vec2* outValue); +extern bool luaval_to_Vec3(lua_State* L,int lo,cocos2d::Vec3* outValue); extern bool luaval_to_size(lua_State* L,int lo,Size* outValue); extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue); @@ -69,27 +69,27 @@ extern bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue); extern bool luaval_to_physics_material(lua_State* L,int lo, cocos2d::PhysicsMaterial* outValue); extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue); extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ); -extern bool luaval_to_matrix(lua_State* L, int lo, cocos2d::Matrix* outValue ); +extern bool luaval_to_matrix(lua_State* L, int lo, cocos2d::Mat4* outValue ); extern bool luaval_to_array(lua_State* L,int lo, __Array** outValue); extern bool luaval_to_dictionary(lua_State* L,int lo, __Dictionary** outValue); -extern bool luaval_to_array_of_vector2(lua_State* L,int lo,cocos2d::Vector2 **points, int *numPoints); +extern bool luaval_to_array_of_vector2(lua_State* L,int lo,cocos2d::Vec2 **points, int *numPoints); extern bool luavals_variadic_to_array(lua_State* L,int argc, __Array** ret); extern bool luavals_variadic_to_ccvaluevector(lua_State* L, int argc, cocos2d::ValueVector* ret); -extern bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vector2* outValue); -extern bool luaval_to_vector3(lua_State* L,int lo,cocos2d::Vector3* outValue); +extern bool luaval_to_vector2(lua_State* L,int lo,cocos2d::Vec2* outValue); +extern bool luaval_to_Vec3(lua_State* L,int lo,cocos2d::Vec3* outValue); extern bool luaval_to_blendfunc(lua_State* L, int lo, cocos2d::BlendFunc* outValue); extern bool luaval_to_ttfconfig(lua_State* L, int lo, cocos2d::TTFConfig* outValue); -CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_point(lua_State* L,int lo,cocos2d::Vector2* outValue) +CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_point(lua_State* L,int lo,cocos2d::Vec2* outValue) { return luaval_to_vector2(L, lo, outValue); } -CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_kmMat4(lua_State* L, int lo, cocos2d::Matrix* outValue ) +CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_kmMat4(lua_State* L, int lo, cocos2d::Mat4* outValue ) { return luaval_to_matrix(L, lo, outValue); } -CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_array_of_Point(lua_State* L,int lo,cocos2d::Vector2 **points, int *numPoints) +CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_array_of_Point(lua_State* L,int lo,cocos2d::Vec2 **points, int *numPoints) { return luaval_to_array_of_vector2(L, lo, points, numPoints); } @@ -234,9 +234,9 @@ bool luaval_to_object(lua_State* L, int lo, const char* type, T** ret) // from native -extern void vector2_to_luaval(lua_State* L,const cocos2d::Vector2& vec2); -extern void vector3_to_luaval(lua_State* L,const cocos2d::Vector3& vec3); -extern void vector2_array_to_luaval(lua_State* L,const cocos2d::Vector2* points, int count); +extern void vector2_to_luaval(lua_State* L,const cocos2d::Vec2& vec2); +extern void Vec3_to_luaval(lua_State* L,const cocos2d::Vec3& vec3); +extern void vector2_array_to_luaval(lua_State* L,const cocos2d::Vec2* points, int count); extern void size_to_luaval(lua_State* L,const Size& sz); extern void rect_to_luaval(lua_State* L,const Rect& rt); extern void color3b_to_luaval(lua_State* L,const Color3B& cc); @@ -249,16 +249,16 @@ extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValu extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue); extern void array_to_luaval(lua_State* L, __Array* inValue); extern void dictionary_to_luaval(lua_State* L, __Dictionary* dict); -extern void matrix_to_luaval(lua_State* L, const cocos2d::Matrix& mat); +extern void matrix_to_luaval(lua_State* L, const cocos2d::Mat4& mat); extern void blendfunc_to_luaval(lua_State* L, const cocos2d::BlendFunc& func); extern void ttfconfig_to_luaval(lua_State* L, const cocos2d::TTFConfig& config); -CC_DEPRECATED_ATTRIBUTE static inline void point_to_luaval(lua_State* L,const cocos2d::Vector2& pt) +CC_DEPRECATED_ATTRIBUTE static inline void point_to_luaval(lua_State* L,const cocos2d::Vec2& pt) { vector2_to_luaval(L, pt); } -CC_DEPRECATED_ATTRIBUTE static inline void points_to_luaval(lua_State* L,const cocos2d::Vector2* points, int count) +CC_DEPRECATED_ATTRIBUTE static inline void points_to_luaval(lua_State* L,const cocos2d::Vec2* points, int count) { vector2_array_to_luaval(L, points, count); } diff --git a/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp b/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp index 91cb42cd38..80d41b1cf0 100644 --- a/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp @@ -38,14 +38,14 @@ using namespace cocos2d::extension; -void GLNode::draw(Renderer *renderer, const cocos2d::Matrix& transform, bool transformUpdated) +void GLNode::draw(Renderer *renderer, const cocos2d::Mat4& transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(GLNode::onDraw, this, transform, transformUpdated); renderer->addCommand(&_renderCmd); } -void GLNode::onDraw(const cocos2d::Matrix &transform, bool transformUpdated) +void GLNode::onDraw(const cocos2d::Mat4 &transform, bool transformUpdated) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::GL_NODE_DRAW); if (0 != handler) @@ -4403,7 +4403,7 @@ static int tolua_cocos2d_DrawPrimitives_drawPoint00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 vec2; + cocos2d::Vec2 vec2; if(luaval_to_vector2(tolua_S, 1, &vec2)) { DrawPrimitives::drawPoint(vec2); @@ -4437,7 +4437,7 @@ static int tolua_cocos2d_DrawPrimitives_drawPoints00(lua_State* tolua_S) if (numberOfPoints > 0) { - cocos2d::Vector2* points = new cocos2d::Vector2[numberOfPoints]; + cocos2d::Vec2* points = new cocos2d::Vec2[numberOfPoints]; if (NULL == points) return 0; @@ -4486,11 +4486,11 @@ static int tolua_cocos2d_DrawPrimitives_drawLine00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 origin; + cocos2d::Vec2 origin; if (!luaval_to_vector2(tolua_S, 1, &origin)) return 0; - cocos2d::Vector2 destination; + cocos2d::Vec2 destination; if (!luaval_to_vector2(tolua_S, 2, &destination)) return 0; @@ -4519,11 +4519,11 @@ static int tolua_cocos2d_DrawPrimitives_drawRect00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 origin; + cocos2d::Vec2 origin; if (!luaval_to_vector2(tolua_S, 1, &origin)) return 0; - cocos2d::Vector2 destination; + cocos2d::Vec2 destination; if (!luaval_to_vector2(tolua_S, 2, &destination)) return 0; @@ -4554,11 +4554,11 @@ static int tolua_cocos2d_DrawPrimitives_drawSolidRect00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 origin; + cocos2d::Vec2 origin; if (!luaval_to_vector2(tolua_S, 1, &origin)) return 0; - cocos2d::Vector2 destination; + cocos2d::Vec2 destination; if (!luaval_to_vector2(tolua_S, 2, &destination)) return 0; @@ -4599,7 +4599,7 @@ static int tolua_cocos2d_DrawPrimitives_drawPoly00(lua_State* tolua_S) if (numOfVertices > 0) { - cocos2d::Vector2* points = new cocos2d::Vector2[numOfVertices]; + cocos2d::Vec2* points = new cocos2d::Vec2[numOfVertices]; if (NULL == points) return 0; @@ -4653,7 +4653,7 @@ static int tolua_cocos2d_DrawPrimitives_drawSolidPoly00(lua_State* tolua_S) unsigned int numberOfPoints = ((unsigned int) tolua_tonumber(tolua_S,2,0)); if (numberOfPoints > 0) { - cocos2d::Vector2* points = new cocos2d::Vector2[numberOfPoints]; + cocos2d::Vec2* points = new cocos2d::Vec2[numberOfPoints]; if (NULL == points) return 0; @@ -4716,7 +4716,7 @@ static int tolua_cocos2d_DrawPrimitives_drawCircle00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 center; + cocos2d::Vec2 center; if (!luaval_to_vector2(tolua_S, 1, ¢er)) return 0; @@ -4757,7 +4757,7 @@ static int tolua_cocos2d_DrawPrimitives_drawSolidCircle00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 center; + cocos2d::Vec2 center; if (!luaval_to_vector2(tolua_S, 1, ¢er)) return 0; float radius = ((float) tolua_tonumber(tolua_S,2,0)); @@ -4794,15 +4794,15 @@ static int tolua_cocos2d_DrawPrimitives_drawQuadBezier00(lua_State* tolua_S) else #endif { - cocos2d::Vector2 origin; + cocos2d::Vec2 origin; if (!luaval_to_vector2(tolua_S, 1, &origin)) return 0; - cocos2d::Vector2 control; + cocos2d::Vec2 control; if (!luaval_to_vector2(tolua_S, 2, &control)) return 0; - cocos2d::Vector2 destination; + cocos2d::Vec2 destination; if (!luaval_to_vector2(tolua_S, 3, &destination)) return 0; @@ -4837,19 +4837,19 @@ static int tolua_cocos2d_DrawPrimitives_drawCubicBezier00(lua_State* tolua_S) #endif { - cocos2d::Vector2 origin; + cocos2d::Vec2 origin; if (!luaval_to_vector2(tolua_S, 1, &origin)) return 0; - cocos2d::Vector2 control1; + cocos2d::Vec2 control1; if (!luaval_to_vector2(tolua_S, 2, &control1)) return 0; - cocos2d::Vector2 control2; + cocos2d::Vec2 control2; if (!luaval_to_vector2(tolua_S, 3, &control2)) return 0; - cocos2d::Vector2 destination; + cocos2d::Vec2 destination; if (!luaval_to_vector2(tolua_S, 4, &destination)) return 0; @@ -4881,7 +4881,7 @@ int tolua_cocos2d_DrawPrimitives_drawCatmullRom00(lua_State* tolua_S) #endif { int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; if (!luaval_to_array_of_vector2(tolua_S, 1, &arr, &num)) return 0; @@ -4928,7 +4928,7 @@ int tolua_cocos2d_DrawPrimitives_drawCardinalSpline00(lua_State* tolua_S) #endif { int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; if (!luaval_to_array_of_vector2(tolua_S, 1, &arr, &num)) return 0; diff --git a/cocos/scripting/lua-bindings/manual/LuaOpengl.h b/cocos/scripting/lua-bindings/manual/LuaOpengl.h index 950201fd78..606b99ae16 100644 --- a/cocos/scripting/lua-bindings/manual/LuaOpengl.h +++ b/cocos/scripting/lua-bindings/manual/LuaOpengl.h @@ -39,10 +39,10 @@ class GLNode:public cocos2d::Node { public: virtual ~GLNode(){} - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Matrix& transform, bool transformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4& transform, bool transformUpdated) override; protected: cocos2d::CustomCommand _renderCmd; - void onDraw(const cocos2d::Matrix &transform, bool transformUpdated); + void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated); }; TOLUA_API int tolua_opengl_open(lua_State* tolua_S); diff --git a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp index 42daac3c56..61bc38a2d8 100644 --- a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp @@ -2125,7 +2125,7 @@ int tolua_cocos2d_Node_setAnchorPoint(lua_State* tolua_S) if (1 == argc) { - cocos2d::Vector2 pt; + cocos2d::Vec2 pt; ok &= luaval_to_vector2(tolua_S, 2, &pt); if (!ok) return 0; @@ -2147,7 +2147,7 @@ int tolua_cocos2d_Node_setAnchorPoint(lua_State* tolua_S) if (!ok) return 0; - cobj->setAnchorPoint(cocos2d::Vector2(x,y)); + cobj->setAnchorPoint(cocos2d::Vec2(x,y)); return 0; } @@ -2291,7 +2291,7 @@ int lua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) return 0; int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; ok &= luaval_to_array_of_vector2(tolua_S, 3, &arr, &num); if (!ok) return 0; @@ -2363,7 +2363,7 @@ int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S) return 0; int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; ok &= luaval_to_array_of_vector2(tolua_S, 3, &arr, &num); if (!ok) return 0; @@ -2427,7 +2427,7 @@ int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S) return 0; int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; ok &= luaval_to_array_of_vector2(tolua_S, 3, &arr, &num); if (!ok) return 0; @@ -2491,7 +2491,7 @@ int tolua_cocos2d_BezierBy_create(lua_State* tolua_S) return 0; int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; ok &= luaval_to_array_of_vector2(tolua_S, 3, &arr, &num); if (!ok) return 0; @@ -2551,7 +2551,7 @@ int tolua_cocos2d_BezierTo_create(lua_State* tolua_S) return 0; int num = 0; - cocos2d::Vector2 *arr = NULL; + cocos2d::Vec2 *arr = NULL; ok &= luaval_to_array_of_vector2(tolua_S, 3, &arr, &num); if (!ok) return 0; @@ -2626,7 +2626,7 @@ static int tolua_cocos2d_DrawNode_drawPolygon(lua_State* tolua_S) size_t size = lua_tonumber(tolua_S, 3); if ( size > 0 ) { - cocos2d::Vector2* points = new cocos2d::Vector2[size]; + cocos2d::Vec2* points = new cocos2d::Vec2[size]; if (NULL == points) return 0; diff --git a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_physics_manual.cpp b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_physics_manual.cpp index 52fed99e00..1998631dfa 100644 --- a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_physics_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_physics_manual.cpp @@ -162,8 +162,8 @@ int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S) if (argc == 3) { std::function arg0; - cocos2d::Vector2 arg1; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); do { arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool @@ -278,7 +278,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S) if (argc == 2) { std::function arg0; - cocos2d::Vector2 arg1; + cocos2d::Vec2 arg1; LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); do { arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool @@ -325,7 +325,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0 = nullptr; + cocos2d::Vec2* arg0 = nullptr; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -355,7 +355,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; do { @@ -388,10 +388,10 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ @@ -446,7 +446,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -476,7 +476,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { @@ -508,7 +508,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1; cocos2d::PhysicsMaterial arg2; double arg3; @@ -566,7 +566,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -596,7 +596,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { @@ -628,7 +628,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1; cocos2d::PhysicsMaterial arg2; double arg3; @@ -686,7 +686,7 @@ int lua_cocos2dx_physics_PhysicsShape_recenterPoints(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -706,9 +706,9 @@ int lua_cocos2dx_physics_PhysicsShape_recenterPoints(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; - cocos2d::Vector2 arg2; + cocos2d::Vec2 arg2; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ @@ -751,7 +751,7 @@ int lua_cocos2dx_physics_PhysicsShape_getPolyonCenter(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -763,7 +763,7 @@ int lua_cocos2dx_physics_PhysicsShape_getPolyonCenter(lua_State* tolua_S) CC_SAFE_FREE(arg0); return 0; } - cocos2d::Vector2 ret = cocos2d::PhysicsShape::getPolyonCenter(arg0, arg1); + cocos2d::Vec2 ret = cocos2d::PhysicsShape::getPolyonCenter(arg0, arg1); CC_SAFE_FREE(arg0); vector2_to_luaval(tolua_S, ret); return 1; @@ -803,7 +803,7 @@ int lua_cocos2dx_physics_PhysicsShapeBox_getPoints(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 0) { - cocos2d::Vector2 arg0[4]; + cocos2d::Vec2 arg0[4]; cobj->getPoints(arg0); vector2_array_to_luaval(tolua_S, arg0, 4); return 0; @@ -846,7 +846,7 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_getPoints(lua_State* tolua_S) if (argc == 0) { int count = cobj->getPointsCount(); - cocos2d::Vector2* arg0 = new cocos2d::Vector2[count]; + cocos2d::Vec2* arg0 = new cocos2d::Vec2[count]; cobj->getPoints(arg0); vector2_array_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); @@ -880,7 +880,7 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_create(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -900,7 +900,7 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_create(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; do { @@ -921,10 +921,10 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_create(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ @@ -967,7 +967,7 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_calculateArea(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -1010,7 +1010,7 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_calculateMoment(lua_State* tolua_S) if (argc == 2) { double arg0; - cocos2d::Vector2* arg1; + cocos2d::Vec2* arg1; int arg2 = 0; ok &= luaval_to_number(tolua_S, 2,&arg0); do { @@ -1031,9 +1031,9 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_calculateMoment(lua_State* tolua_S) if (argc == 2) { double arg0; - cocos2d::Vector2* arg1; + cocos2d::Vec2* arg1; int arg2 = 0; - cocos2d::Vector2 arg3; + cocos2d::Vec2 arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); do { ok = luaval_to_array_of_vector2(tolua_S, 3, &arg1, &arg2); @@ -1087,7 +1087,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints(lua_State* tolua_S) if (argc == 0) { int count = cobj->getPointsCount(); - cocos2d::Vector2* arg0 = new cocos2d::Vector2[count]; + cocos2d::Vec2* arg0 = new cocos2d::Vec2[count]; cobj->getPoints(arg0); vector2_array_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); @@ -1131,7 +1131,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints(lua_State* tolua_S) if (argc == 0) { int count = cobj->getPointsCount(); - cocos2d::Vector2* arg0 = new cocos2d::Vector2[count]; + cocos2d::Vec2* arg0 = new cocos2d::Vec2[count]; cobj->getPoints(arg0); vector2_array_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); @@ -1175,7 +1175,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints(lua_State* tolua_S) if (argc == 0) { int count = cobj->getPointsCount(); - cocos2d::Vector2* arg0 = new cocos2d::Vector2[count]; + cocos2d::Vec2* arg0 = new cocos2d::Vec2[count]; cobj->getPoints(arg0); vector2_array_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); @@ -1313,7 +1313,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_create(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -1332,7 +1332,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_create(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; do { @@ -1353,7 +1353,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_create(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; double arg3; @@ -1400,7 +1400,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeChain_create(lua_State* tolua_S) if (argc == 1) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; do { ok = luaval_to_array_of_vector2(tolua_S, 2, &arg0, &arg1); @@ -1419,7 +1419,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeChain_create(lua_State* tolua_S) } if (argc == 2) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; do { @@ -1440,7 +1440,7 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeChain_create(lua_State* tolua_S) } if (argc == 3) { - cocos2d::Vector2* arg0; + cocos2d::Vec2* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; double arg3; diff --git a/cocos/ui/CCProtectedNode.cpp b/cocos/ui/CCProtectedNode.cpp index 45dc3e9dc8..6162e57846 100644 --- a/cocos/ui/CCProtectedNode.cpp +++ b/cocos/ui/CCProtectedNode.cpp @@ -268,7 +268,7 @@ void ProtectedNode::reorderProtectedChild(cocos2d::Node *child, int localZOrder) child->_setLocalZOrder(localZOrder); } -void ProtectedNode::visit(Renderer* renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -283,7 +283,7 @@ void ProtectedNode::visit(Renderer* renderer, const Matrix &parentTransform, boo // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/cocos/ui/CCProtectedNode.h b/cocos/ui/CCProtectedNode.h index 22fbc8e10a..d49c690699 100644 --- a/cocos/ui/CCProtectedNode.h +++ b/cocos/ui/CCProtectedNode.h @@ -127,7 +127,7 @@ public: /// @} end of Children and Parent - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool transformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool transformUpdated) override; virtual void cleanup() override; diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index b54c7816bd..6b64134a45 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -135,7 +135,7 @@ void Button::initRenderer() _buttonClickedRenderer = Sprite::create(); _buttonDisableRenderer = Sprite::create(); _titleRenderer = Label::create(); - _titleRenderer->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + _titleRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE); addProtectedChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); addProtectedChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); @@ -520,7 +520,7 @@ void Button::updateFlippedY() void Button::updateTitleLocation() { - _titleRenderer->setPosition(Vector2(_contentSize.width * 0.5f, _contentSize.height * 0.5f)); + _titleRenderer->setPosition(Vec2(_contentSize.width * 0.5f, _contentSize.height * 0.5f)); } void Button::onSizeChanged() diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index 9b59671e6b..6ec19c02fb 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -477,7 +477,7 @@ void CheckBox::backGroundTextureScaleChangedWithSize() _backGroundBoxRenderer->setScaleX(scaleX); _backGroundBoxRenderer->setScaleY(scaleY); } - _backGroundBoxRenderer->setPosition(Vector2(_contentSize.width / 2, _contentSize.height / 2)); + _backGroundBoxRenderer->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::backGroundSelectedTextureScaleChangedWithSize() @@ -499,7 +499,7 @@ void CheckBox::backGroundSelectedTextureScaleChangedWithSize() _backGroundSelectedBoxRenderer->setScaleX(scaleX); _backGroundSelectedBoxRenderer->setScaleY(scaleY); } - _backGroundSelectedBoxRenderer->setPosition(Vector2(_contentSize.width / 2, _contentSize.height / 2)); + _backGroundSelectedBoxRenderer->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::frontCrossTextureScaleChangedWithSize() @@ -521,7 +521,7 @@ void CheckBox::frontCrossTextureScaleChangedWithSize() _frontCrossRenderer->setScaleX(scaleX); _frontCrossRenderer->setScaleY(scaleY); } - _frontCrossRenderer->setPosition(Vector2(_contentSize.width / 2, _contentSize.height / 2)); + _frontCrossRenderer->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::backGroundDisabledTextureScaleChangedWithSize() @@ -543,7 +543,7 @@ void CheckBox::backGroundDisabledTextureScaleChangedWithSize() _backGroundBoxDisabledRenderer->setScaleX(scaleX); _backGroundBoxDisabledRenderer->setScaleY(scaleY); } - _backGroundBoxDisabledRenderer->setPosition(Vector2(_contentSize.width / 2, _contentSize.height / 2)); + _backGroundBoxDisabledRenderer->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::frontCrossDisabledTextureScaleChangedWithSize() @@ -565,7 +565,7 @@ void CheckBox::frontCrossDisabledTextureScaleChangedWithSize() _frontCrossDisabledRenderer->setScaleX(scaleX); _frontCrossDisabledRenderer->setScaleY(scaleY); } - _frontCrossDisabledRenderer->setPosition(Vector2(_contentSize.width / 2, _contentSize.height / 2)); + _frontCrossDisabledRenderer->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2)); } std::string CheckBox::getDescription() const diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 22a7f8fed2..be628e30f9 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -135,7 +135,7 @@ void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Ve if (layoutParameter) { LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity(); - Vector2 ap = child->getAnchorPoint(); + Vec2 ap = child->getAnchorPoint(); Size cs = child->getSize(); float finalPosX = ap.x * cs.width; float finalPosY = topBoundary - ((1.0f-ap.y) * cs.height); @@ -156,7 +156,7 @@ void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Ve Margin mg = layoutParameter->getMargin(); finalPosX += mg.left; finalPosY -= mg.top; - child->setPosition(Vector2(finalPosX, finalPosY)); + child->setPosition(Vec2(finalPosX, finalPosY)); topBoundary = child->getBottomInParent() - mg.bottom; } } @@ -175,7 +175,7 @@ void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, if (layoutParameter) { LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity(); - Vector2 ap = child->getAnchorPoint(); + Vec2 ap = child->getAnchorPoint(); Size cs = child->getSize(); float finalPosX = leftBoundary + (ap.x * cs.width); float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height; @@ -196,7 +196,7 @@ void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Margin mg = layoutParameter->getMargin(); finalPosX += mg.left; finalPosY -= mg.top; - child->setPosition(Vector2(finalPosX, finalPosY)); + child->setPosition(Vec2(finalPosX, finalPosY)); leftBoundary = child->getRightInParent() + mg.right; } } @@ -231,7 +231,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorgetAnchorPoint(); + Vec2 ap = child->getAnchorPoint(); Size cs = child->getSize(); RelativeLayoutParameter::RelativeAlign align = layoutParameter->getAlign(); const std::string relativeName = layoutParameter->getRelativeToWidgetName(); @@ -549,7 +549,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorsetPosition(Vector2(finalPosX, finalPosY)); + child->setPosition(Vec2(finalPosX, finalPosY)); layoutParameter->_put = true; unlayoutChildCount--; } @@ -579,7 +579,7 @@ _gradientRender(nullptr), _cColor(Color3B::WHITE), _gStartColor(Color3B::WHITE), _gEndColor(Color3B::WHITE), -_alongVector(Vector2(0.0f, -1.0f)), +_alongVector(Vec2(0.0f, -1.0f)), _cOpacity(255), _backGroundImageTextureSize(Size::ZERO), _layoutType(Type::ABSOLUTE), @@ -609,7 +609,7 @@ _passFocusToChild(true), _loopFocus(false) { onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); - this->setAnchorPoint(Vector2::ZERO); + this->setAnchorPoint(Vec2::ZERO); } Layout::~Layout() @@ -658,7 +658,7 @@ bool Layout::init() setBright(true); ignoreContentAdaptWithSize(false); setSize(Size::ZERO); - setAnchorPoint(Vector2::ZERO); + setAnchorPoint(Vec2::ZERO); return true; } return false; @@ -703,7 +703,7 @@ bool Layout::isClippingEnabled() return _clippingEnabled; } -void Layout::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if (!_enabled) { @@ -736,7 +736,7 @@ void Layout::sortAllChildren() doLayout(); } -void Layout::stencilClippingVisit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if(!_visible) return; @@ -747,7 +747,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Matrix &parentTransf _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -853,7 +853,7 @@ void Layout::onBeforeVisitStencil() director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - DrawPrimitives::drawSolidRect(Vector2(-1,-1), Vector2(1,1), Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Vec2(-1,-1), Vec2(1,1), Color4F(1, 1, 1, 1)); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -894,7 +894,7 @@ void Layout::onAfterVisitScissor() glDisable(GL_SCISSOR_TEST); } -void Layout::scissorClippingVisit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated) +void Layout::scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated) { _beforeVisitCmdScissor.init(_globalZOrder); _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); @@ -973,11 +973,11 @@ void Layout::setStencilClippingSize(const Size &size) { if (_clippingEnabled && _clippingType == ClippingType::STENCIL) { - Vector2 rect[4]; - rect[0] = Vector2::ZERO; - rect[1] = Vector2(_size.width, 0); - rect[2] = Vector2(_size.width, _size.height); - rect[3] = Vector2(0, _size.height); + Vec2 rect[4]; + rect[0] = Vec2::ZERO; + rect[1] = Vec2(_size.width, 0); + rect[2] = Vec2(_size.width, _size.height); + rect[3] = Vec2(0, _size.height); Color4F green(0, 1, 0, 1); _clippingStencil->clear(); _clippingStencil->drawPolygon(rect, 4, green, 0, green); @@ -988,7 +988,7 @@ const Rect& Layout::getClippingRect() { if (_clippingRectDirty) { - Vector2 worldPos = convertToWorldSpace(Vector2::ZERO); + Vec2 worldPos = convertToWorldSpace(Vec2::ZERO); AffineTransform t = getNodeToWorldAffineTransform(); float scissorWidth = _size.width*t.a; float scissorHeight = _size.height*t.d; @@ -1071,7 +1071,7 @@ void Layout::onSizeChanged() _clippingRectDirty = true; if (_backGroundImage) { - _backGroundImage->setPosition(Vector2(_size.width/2.0f, _size.height/2.0f)); + _backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f)); if (_backGroundScale9Enabled && _backGroundImage) { static_cast(_backGroundImage)->setPreferredSize(_size); @@ -1149,7 +1149,7 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy } } _backGroundImageTextureSize = _backGroundImage->getContentSize(); - _backGroundImage->setPosition(Vector2(_size.width/2.0f, _size.height/2.0f)); + _backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f)); updateBackGroundImageRGBA(); } @@ -1214,7 +1214,7 @@ void Layout::addBackGroundImage() _backGroundImage = Sprite::create(); addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } - _backGroundImage->setPosition(Vector2(_size.width/2.0f, _size.height/2.0f)); + _backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f)); } void Layout::removeBackGroundImage() @@ -1358,7 +1358,7 @@ GLubyte Layout::getBackGroundColorOpacity() return _cOpacity; } -void Layout::setBackGroundColorVector(const Vector2 &vector) +void Layout::setBackGroundColorVector(const Vec2 &vector) { _alongVector = vector; if (_gradientRender) @@ -1367,7 +1367,7 @@ void Layout::setBackGroundColorVector(const Vector2 &vector) } } -const Vector2& Layout::getBackGroundColorVector() +const Vec2& Layout::getBackGroundColorVector() { return _alongVector; } @@ -1576,20 +1576,20 @@ Size Layout::getLayoutContentSize()const return layoutSize; } -Vector2 Layout::getWorldCenterPoint(Widget* widget) +Vec2 Layout::getWorldCenterPoint(Widget* widget) { Layout *layout = dynamic_cast(widget); //FIXEDME: we don't need to calculate the content size of layout anymore Size widgetSize = layout ? layout->getLayoutContentSize() : widget->getSize(); // CCLOG("contnet size : width = %f, height = %f", widgetSize.width, widgetSize.height); - return widget->convertToWorldSpace(Vector2(widgetSize.width/2, widgetSize.height/2)); + return widget->convertToWorldSpace(Vec2(widgetSize.width/2, widgetSize.height/2)); } float Layout::caculateNearestDistance(Widget* baseWidget) { float distance = FLT_MAX; - Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget); for (Node* node : _children) { Layout *layout = dynamic_cast(node); @@ -1601,7 +1601,7 @@ float Layout::caculateNearestDistance(Widget* baseWidget) { Widget* w = dynamic_cast(node); if (w && w->isFocusEnabled()) { - Vector2 wPosition = this->getWorldCenterPoint(w); + Vec2 wPosition = this->getWorldCenterPoint(w); length = (wPosition - widgetPosition).length(); } else { @@ -1622,7 +1622,7 @@ float Layout::caculateFarestDistance(cocos2d::ui::Widget *baseWidget) { float distance = -FLT_MAX; - Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget); for (Node* node : _children) { Layout *layout = dynamic_cast(node); @@ -1634,7 +1634,7 @@ float Layout::caculateFarestDistance(cocos2d::ui::Widget *baseWidget) { Widget* w = dynamic_cast(node); if (w && w->isFocusEnabled()) { - Vector2 wPosition = this->getWorldCenterPoint(w); + Vec2 wPosition = this->getWorldCenterPoint(w); length = (wPosition - widgetPosition).length(); } else { @@ -1677,13 +1677,13 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi int found = 0; if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT) { - Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) { Widget *w = dynamic_cast(this->getChildren().at(index)); if (w && w->isFocusEnabled()) { - Vector2 wPosition = this->getWorldCenterPoint(w); + Vec2 wPosition = this->getWorldCenterPoint(w); float length; Layout *layout = dynamic_cast(w); if (layout) @@ -1710,13 +1710,13 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi found = 0; distance = FLT_MAX; if (direction == FocusDirection::DOWN || direction == FocusDirection::UP) { - Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) { Widget *w = dynamic_cast(this->getChildren().at(index)); if (w && w->isFocusEnabled()) { - Vector2 wPosition = this->getWorldCenterPoint(w); + Vec2 wPosition = this->getWorldCenterPoint(w); float length; Layout *layout = dynamic_cast(w); if (layout) @@ -1756,13 +1756,13 @@ int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Wi int found = 0; if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT) { - Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) { Widget *w = dynamic_cast(this->getChildren().at(index)); if (w && w->isFocusEnabled()) { - Vector2 wPosition = this->getWorldCenterPoint(w); + Vec2 wPosition = this->getWorldCenterPoint(w); float length; Layout *layout = dynamic_cast(w); if (layout) @@ -1789,13 +1789,13 @@ int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Wi found = 0; distance = -FLT_MAX; if (direction == FocusDirection::DOWN || direction == FocusDirection::UP) { - Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) { Widget *w = dynamic_cast(this->getChildren().at(index)); if (w && w->isFocusEnabled()) { - Vector2 wPosition = this->getWorldCenterPoint(w); + Vec2 wPosition = this->getWorldCenterPoint(w); float length; Layout *layout = dynamic_cast(w); if (layout) @@ -1869,9 +1869,9 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget) return; } - Vector2 previousWidgetPosition = this->getWorldCenterPoint(baseWidget); + Vec2 previousWidgetPosition = this->getWorldCenterPoint(baseWidget); - Vector2 layoutPosition = this->getWorldCenterPoint(this->findFirstNonLayoutWidget()); + Vec2 layoutPosition = this->getWorldCenterPoint(this->findFirstNonLayoutWidget()); if (dir == FocusDirection::LEFT) { if (previousWidgetPosition.x > layoutPosition.x) { diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 2a1e63d7e0..f9f5eab81d 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -153,9 +153,9 @@ public: * * @param vector */ - void setBackGroundColorVector(const Vector2 &vector); + void setBackGroundColorVector(const Vec2 &vector); - const Vector2& getBackGroundColorVector(); + const Vec2& getBackGroundColorVector(); void setBackGroundImageColor(const Color3B& color); @@ -228,7 +228,7 @@ public: */ virtual void addChild(Node* child, int zOrder, int tag) override; - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; virtual void removeChild(Node* child, bool cleanup = true) override; @@ -308,8 +308,8 @@ protected: virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; - void stencilClippingVisit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated); - void scissorClippingVisit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated); + void stencilClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated); + void scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated); void setStencilClippingSize(const Size& size); const Rect& getClippingRect(); @@ -386,7 +386,7 @@ protected: /** * get the center point of a widget in world space */ - Vector2 getWorldCenterPoint(Widget* node); + Vec2 getWorldCenterPoint(Widget* node); /** * this method is called internally by nextFocusedWidget. When the dir is Right/Down, then this method will be called @@ -445,7 +445,7 @@ protected: Color3B _cColor; Color3B _gStartColor; Color3B _gEndColor; - Vector2 _alongVector; + Vec2 _alongVector; GLubyte _cOpacity; Size _backGroundImageTextureSize; Type _layoutType; diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index dd3f8ee01a..d61af9d837 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -444,7 +444,7 @@ void ListView::selectedItemEvent(int state) } -void ListView::interceptTouchEvent(int handleState, Widget *sender, const Vector2 &touchPoint) +void ListView::interceptTouchEvent(int handleState, Widget *sender, const Vec2 &touchPoint) { ScrollView::interceptTouchEvent(handleState, sender, touchPoint); if (handleState != 1) diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 8394c340ef..5407dd4b41 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -205,7 +205,7 @@ protected: virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; void selectedItemEvent(int state); - virtual void interceptTouchEvent(int handleState,Widget* sender,const Vector2 &touchPoint) override; + virtual void interceptTouchEvent(int handleState,Widget* sender,const Vec2 &touchPoint) override; protected: Widget* _model; diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index 56e6f0b8ac..fd4395487b 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -82,7 +82,7 @@ void LoadingBar::initRenderer() { _barRenderer = Sprite::create(); addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1); - _barRenderer->setAnchorPoint(Vector2(0.0,0.5)); + _barRenderer->setAnchorPoint(Vec2(0.0,0.5)); } @@ -97,16 +97,16 @@ void LoadingBar::setDirection(cocos2d::ui::LoadingBar::Direction direction) switch (_direction) { case Direction::LEFT: - _barRenderer->setAnchorPoint(Vector2(0.0f,0.5f)); - _barRenderer->setPosition(Vector2(-_totalLength*0.5f,0.0f)); + _barRenderer->setAnchorPoint(Vec2(0.0f,0.5f)); + _barRenderer->setPosition(Vec2(-_totalLength*0.5f,0.0f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(false); } break; case Direction::RIGHT: - _barRenderer->setAnchorPoint(Vector2(1.0f,0.5f)); - _barRenderer->setPosition(Vector2(_totalLength*0.5f,0.0f)); + _barRenderer->setAnchorPoint(Vec2(1.0f,0.5f)); + _barRenderer->setPosition(Vec2(_totalLength*0.5f,0.0f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(true); @@ -165,14 +165,14 @@ LoadingBar::Direction LoadingBar::getDirection()const switch (_direction) { case Direction::LEFT: - _barRenderer->setAnchorPoint(Vector2(0.0f,0.5f)); + _barRenderer->setAnchorPoint(Vec2(0.0f,0.5f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(false); } break; case Direction::RIGHT: - _barRenderer->setAnchorPoint(Vector2(1.0f,0.5f)); + _barRenderer->setAnchorPoint(Vec2(1.0f,0.5f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(true); @@ -337,10 +337,10 @@ void LoadingBar::barRendererScaleChangedWithSize() switch (_direction) { case Direction::LEFT: - _barRenderer->setPosition(Vector2(0.0f, _contentSize.height / 2.0f)); + _barRenderer->setPosition(Vec2(0.0f, _contentSize.height / 2.0f)); break; case Direction::RIGHT: - _barRenderer->setPosition(Vector2(_totalLength, _contentSize.height / 2.0f)); + _barRenderer->setPosition(Vec2(_totalLength, _contentSize.height / 2.0f)); break; default: break; diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index ae65a9036f..4a69fa7aba 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -35,7 +35,7 @@ _curPageIdx(0), _touchMoveDir(TouchDirection::LEFT), _touchStartLocation(0.0f), _touchMoveStartLocation(0.0f), -_movePagePoint(Vector2::ZERO), +_movePagePoint(Vec2::ZERO), _leftChild(nullptr), _rightChild(nullptr), _leftBoundary(0.0f), @@ -143,7 +143,7 @@ void PageView::addPage(Layout* page) CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } - page->setPosition(Vector2(getPositionXByIndex(_pages.size()), 0)); + page->setPosition(Vec2(getPositionXByIndex(_pages.size()), 0)); _pages.pushBack(page); addChild(page); updateBoundaryPages(); @@ -173,7 +173,7 @@ void PageView::insertPage(Layout* page, int idx) else { _pages.insert(idx, page); - page->setPosition(Vector2(getPositionXByIndex(idx), 0)); + page->setPosition(Vec2(getPositionXByIndex(idx), 0)); addChild(page); Size pSize = page->getSize(); Size pvSize = getSize(); @@ -185,8 +185,8 @@ void PageView::insertPage(Layout* page, int idx) ssize_t length = _pages.size(); for (ssize_t i=(idx+1); igetPosition(); - behindPage->setPosition(Vector2(formerPos.x+getSize().width, 0)); + Vec2 formerPos = behindPage->getPosition(); + behindPage->setPosition(Vec2(formerPos.x+getSize().width, 0)); } updateBoundaryPages(); } @@ -292,7 +292,7 @@ void PageView::updateChildrenPosition() for (int i=0; isetPosition(Vector2((i-_curPageIdx)*pageWidth, 0)); + page->setPosition(Vec2((i-_curPageIdx)*pageWidth, 0)); } } @@ -459,16 +459,16 @@ bool PageView::scrollPages(float touchOffset) return true; } -void PageView::handlePressLogic(const Vector2 &touchPoint) +void PageView::handlePressLogic(const Vec2 &touchPoint) { - Vector2 nsp = convertToNodeSpace(touchPoint); + Vec2 nsp = convertToNodeSpace(touchPoint); _touchMoveStartLocation = nsp.x; _touchStartLocation = nsp.x; } -void PageView::handleMoveLogic(const Vector2 &touchPoint) +void PageView::handleMoveLogic(const Vec2 &touchPoint) { - Vector2 nsp = convertToNodeSpace(touchPoint); + Vec2 nsp = convertToNodeSpace(touchPoint); float offset = 0.0; float moveX = nsp.x; offset = moveX - _touchMoveStartLocation; @@ -484,7 +484,7 @@ void PageView::handleMoveLogic(const Vector2 &touchPoint) scrollPages(offset); } -void PageView::handleReleaseLogic(const Vector2 &touchPoint) +void PageView::handleReleaseLogic(const Vec2 &touchPoint) { if (_pages.size() <= 0) { @@ -493,7 +493,7 @@ void PageView::handleReleaseLogic(const Vector2 &touchPoint) Widget* curPage = _pages.at(_curPageIdx); if (curPage) { - Vector2 curPagePos = curPage->getPosition(); + Vec2 curPagePos = curPage->getPosition(); ssize_t pageCount = _pages.size(); float curPageLocation = curPagePos.x; float pageWidth = getSize().width; @@ -527,12 +527,12 @@ void PageView::handleReleaseLogic(const Vector2 &touchPoint) } } -void PageView::checkChildInfo(int handleState,Widget* sender, const Vector2 &touchPoint) +void PageView::checkChildInfo(int handleState,Widget* sender, const Vec2 &touchPoint) { interceptTouchEvent(handleState, sender, touchPoint); } -void PageView::interceptTouchEvent(int handleState, Widget *sender, const Vector2 &touchPoint) +void PageView::interceptTouchEvent(int handleState, Widget *sender, const Vec2 &touchPoint) { switch (handleState) { diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 8d6f9b4728..75153408a4 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -189,11 +189,11 @@ virtual Widget* getChildByName(const std::string& name) override {return Widget: Layout* createPage(); float getPositionXByIndex(ssize_t idx); void updateBoundaryPages(); - virtual void handlePressLogic(const Vector2 &touchPoint) override; - virtual void handleMoveLogic(const Vector2 &touchPoint) override; - virtual void handleReleaseLogic(const Vector2 &touchPoint) override; - virtual void interceptTouchEvent(int handleState, Widget* sender, const Vector2 &touchPoint) override; - virtual void checkChildInfo(int handleState, Widget* sender, const Vector2 &touchPoint) override; + virtual void handlePressLogic(const Vec2 &touchPoint) override; + virtual void handleMoveLogic(const Vec2 &touchPoint) override; + virtual void handleReleaseLogic(const Vec2 &touchPoint) override; + virtual void interceptTouchEvent(int handleState, Widget* sender, const Vec2 &touchPoint) override; + virtual void checkChildInfo(int handleState, Widget* sender, const Vec2 &touchPoint) override; virtual bool scrollPages(float touchOffset); void movePages(float offset); void pageTurningEvent(); @@ -211,7 +211,7 @@ protected: TouchDirection _touchMoveDir; float _touchStartLocation; float _touchMoveStartLocation; - Vector2 _movePagePoint; + Vec2 _movePagePoint; Widget* _leftChild; Widget* _rightChild; float _leftBoundary; diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 1c96d9e50b..e0436e594f 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -162,7 +162,7 @@ bool RichText::init() void RichText::initRenderer() { _elementRenderersContainer = Node::create(); - _elementRenderersContainer->setAnchorPoint(Vector2(0.5f, 0.5f)); + _elementRenderersContainer->setAnchorPoint(Vec2(0.5f, 0.5f)); addProtectedChild(_elementRenderersContainer, 0, -1); } @@ -367,8 +367,8 @@ void RichText::formarRenderers() for (ssize_t j=0; jsize(); j++) { Node* l = row->at(j); - l->setAnchorPoint(Vector2::ZERO); - l->setPosition(Vector2(nextPosX, 0.0f)); + l->setAnchorPoint(Vec2::ZERO); + l->setPosition(Vec2(nextPosX, 0.0f)); _elementRenderersContainer->addChild(l, 1, (int)j); Size iSize = l->getContentSize(); newContentSizeWidth += iSize.width; @@ -406,8 +406,8 @@ void RichText::formarRenderers() for (ssize_t j=0; jsize(); j++) { Node* l = row->at(j); - l->setAnchorPoint(Vector2::ZERO); - l->setPosition(Vector2(nextPosX, nextPosY)); + l->setAnchorPoint(Vec2::ZERO); + l->setPosition(Vec2(nextPosX, nextPosY)); _elementRenderersContainer->addChild(l, 1, (int)(i*10 + j)); nextPosX += l->getContentSize().width; } @@ -447,7 +447,7 @@ void RichText::pushToContainer(cocos2d::Node *renderer) _elementRenders[_elementRenders.size()-1]->pushBack(renderer); } -void RichText::visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if (_enabled) { @@ -461,7 +461,7 @@ void RichText::setVerticalSpace(float space) _verticalSpace = space; } -void RichText::setAnchorPoint(const Vector2 &pt) +void RichText::setAnchorPoint(const Vec2 &pt) { Widget::setAnchorPoint(pt); _elementRenderersContainer->setAnchorPoint(pt); diff --git a/cocos/ui/UIRichText.h b/cocos/ui/UIRichText.h index b65ee42053..b3893bef12 100644 --- a/cocos/ui/UIRichText.h +++ b/cocos/ui/UIRichText.h @@ -102,9 +102,9 @@ public: void pushBackElement(RichElement* element); void removeElement(int index); void removeElement(RichElement* element); - virtual void visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; void setVerticalSpace(float space); - virtual void setAnchorPoint(const Vector2 &pt); + virtual void setAnchorPoint(const Vec2 &pt); virtual const Size& getVirtualRendererSize() const override; void formatText(); virtual void ignoreContentAdaptWithSize(bool ignore); diff --git a/cocos/ui/UIScrollInterface.h b/cocos/ui/UIScrollInterface.h index 68e7187c8e..f4ba00dc00 100644 --- a/cocos/ui/UIScrollInterface.h +++ b/cocos/ui/UIScrollInterface.h @@ -37,10 +37,10 @@ public: virtual ~UIScrollInterface() {} protected: - virtual void handlePressLogic(const Vector2 &touchPoint) = 0; - virtual void handleMoveLogic(const Vector2 &touchPoint) = 0; - virtual void handleReleaseLogic(const Vector2 &touchPoint) = 0; - virtual void interceptTouchEvent(int handleState, Widget* sender, const Vector2 &touchPoint) = 0; + virtual void handlePressLogic(const Vec2 &touchPoint) = 0; + virtual void handleMoveLogic(const Vec2 &touchPoint) = 0; + virtual void handleReleaseLogic(const Vec2 &touchPoint) = 0; + virtual void interceptTouchEvent(int handleState, Widget* sender, const Vec2 &touchPoint) = 0; }; } diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 3d904cda8a..ae1313aa9e 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -65,21 +65,21 @@ const Size& ScrollInnerContainer::getLayoutSize() static const float AUTOSCROLLMAXSPEED = 1000.0f; -const Vector2 SCROLLDIR_UP = Vector2(0.0f, 1.0f); -const Vector2 SCROLLDIR_DOWN = Vector2(0.0f, -1.0f); -const Vector2 SCROLLDIR_LEFT = Vector2(-1.0f, 0.0f); -const Vector2 SCROLLDIR_RIGHT = Vector2(1.0f, 0.0f); +const Vec2 SCROLLDIR_UP = Vec2(0.0f, 1.0f); +const Vec2 SCROLLDIR_DOWN = Vec2(0.0f, -1.0f); +const Vec2 SCROLLDIR_LEFT = Vec2(-1.0f, 0.0f); +const Vec2 SCROLLDIR_RIGHT = Vec2(1.0f, 0.0f); IMPLEMENT_CLASS_GUI_INFO(ScrollView) ScrollView::ScrollView(): _innerContainer(nullptr), _direction(Direction::VERTICAL), -_touchBeganPoint(Vector2::ZERO), -_touchMovedPoint(Vector2::ZERO), -_touchEndedPoint(Vector2::ZERO), -_touchMovingPoint(Vector2::ZERO), -_autoScrollDir(Vector2::ZERO), +_touchBeganPoint(Vec2::ZERO), +_touchMovedPoint(Vec2::ZERO), +_touchEndedPoint(Vec2::ZERO), +_touchMovingPoint(Vec2::ZERO), +_autoScrollDir(Vec2::ZERO), _topBoundary(0.0f), _bottomBoundary(0.0f), _leftBoundary(0.0f), @@ -94,10 +94,10 @@ _autoScrollOriginalSpeed(0.0f), _autoScrollAcceleration(-1000.0f), _isAutoScrollSpeedAttenuated(false), _needCheckAutoScrollDestination(false), -_autoScrollDestination(Vector2::ZERO), +_autoScrollDestination(Vec2::ZERO), _bePressed(false), _slidTime(0.0f), -_moveChildPoint(Vector2::ZERO), +_moveChildPoint(Vec2::ZERO), _childFocusCancelOffset(5.0f), _leftBounceNeeded(false), _topBounceNeeded(false), @@ -105,7 +105,7 @@ _rightBounceNeeded(false), _bottomBounceNeeded(false), _bounceEnabled(false), _bouncing(false), -_bounceDir(Vector2::ZERO), +_bounceDir(Vec2::ZERO), _bounceOriginalSpeed(0.0f), _inertiaScrollEnabled(true), _scrollViewEventListener(nullptr), @@ -174,7 +174,7 @@ void ScrollView::onSizeChanged() float innerSizeWidth = MAX(orginInnerSizeWidth, _size.width); float innerSizeHeight = MAX(orginInnerSizeHeight, _size.height); _innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); - _innerContainer->setPosition(Vector2(0, _size.height - _innerContainer->getSize().height)); + _innerContainer->setPosition(Vec2(0, _size.height - _innerContainer->getSize().height)); } void ScrollView::setInnerContainerSize(const Size &size) @@ -236,19 +236,19 @@ void ScrollView::setInnerContainerSize(const Size &size) } if (_innerContainer->getLeftInParent() > 0.0f) { - _innerContainer->setPosition(Vector2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y)); + _innerContainer->setPosition(Vec2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y)); } if (_innerContainer->getRightInParent() < _size.width) { - _innerContainer->setPosition(Vector2(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y)); + _innerContainer->setPosition(Vec2(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y)); } if (_innerContainer->getPosition().y > 0.0f) { - _innerContainer->setPosition(Vector2(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height)); + _innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height)); } if (_innerContainer->getTopInParent() < _size.height) { - _innerContainer->setPosition(Vector2(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height)); + _innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height)); } } @@ -314,7 +314,7 @@ Widget* ScrollView::getChildByName(const std::string& name) void ScrollView::moveChildren(float offsetX, float offsetY) { - _moveChildPoint = _innerContainer->getPosition() + Vector2(offsetX, offsetY); + _moveChildPoint = _innerContainer->getPosition() + Vec2(offsetX, offsetY); _innerContainer->setPosition(_moveChildPoint); } @@ -391,56 +391,56 @@ bool ScrollView::checkNeedBounce() { if (_topBounceNeeded && _leftBounceNeeded) { - Vector2 scrollVector = Vector2(0.0f, _size.height) - Vector2(_innerContainer->getLeftInParent(), _innerContainer->getTopInParent()); + Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(_innerContainer->getLeftInParent(), _innerContainer->getTopInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_topBounceNeeded && _rightBounceNeeded) { - Vector2 scrollVector = Vector2(_size.width, _size.height) - Vector2(_innerContainer->getRightInParent(), _innerContainer->getTopInParent()); + Vec2 scrollVector = Vec2(_size.width, _size.height) - Vec2(_innerContainer->getRightInParent(), _innerContainer->getTopInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_bottomBounceNeeded && _leftBounceNeeded) { - Vector2 scrollVector = Vector2::ZERO - Vector2(_innerContainer->getLeftInParent(), _innerContainer->getBottomInParent()); + Vec2 scrollVector = Vec2::ZERO - Vec2(_innerContainer->getLeftInParent(), _innerContainer->getBottomInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_bottomBounceNeeded && _rightBounceNeeded) { - Vector2 scrollVector = Vector2(_size.width, 0.0f) - Vector2(_innerContainer->getRightInParent(), _innerContainer->getBottomInParent()); + Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightInParent(), _innerContainer->getBottomInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_topBounceNeeded) { - Vector2 scrollVector = Vector2(0.0f, _size.height) - Vector2(0.0f, _innerContainer->getTopInParent()); + Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(0.0f, _innerContainer->getTopInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_bottomBounceNeeded) { - Vector2 scrollVector = Vector2::ZERO - Vector2(0.0f, _innerContainer->getBottomInParent()); + Vec2 scrollVector = Vec2::ZERO - Vec2(0.0f, _innerContainer->getBottomInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_leftBounceNeeded) { - Vector2 scrollVector = Vector2::ZERO - Vector2(_innerContainer->getLeftInParent(), 0.0f); + Vec2 scrollVector = Vec2::ZERO - Vec2(_innerContainer->getLeftInParent(), 0.0f); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); } else if (_rightBounceNeeded) { - Vector2 scrollVector = Vector2(_size.width, 0.0f) - Vector2(_innerContainer->getRightInParent(), 0.0f); + Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightInParent(), 0.0f); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.getNormalized(); startBounceChildren(orSpeed); @@ -510,7 +510,7 @@ void ScrollView::stopBounceChildren() _bottomBounceNeeded = false; } -void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Vector2& dir, float v, bool attenuated, float acceleration) +void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Vec2& dir, float v, bool attenuated, float acceleration) { stopAutoScrollChildren(); _autoScrollDir = dir; @@ -520,12 +520,12 @@ void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Vector2& dir, fl _autoScrollAcceleration = acceleration; } -void ScrollView::startAutoScrollChildrenWithDestination(const Vector2& des, float time, bool attenuated) +void ScrollView::startAutoScrollChildrenWithDestination(const Vec2& des, float time, bool attenuated) { _needCheckAutoScrollDestination = false; _autoScrollDestination = des; - Vector2 dis = des - _innerContainer->getPosition(); - Vector2 dir = dis.getNormalized(); + Vec2 dis = des - _innerContainer->getPosition(); + Vec2 dir = dis.getNormalized(); float orSpeed = 0.0f; float acceleration = -1000.0f; if (attenuated) @@ -541,7 +541,7 @@ void ScrollView::startAutoScrollChildrenWithDestination(const Vector2& des, floa startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration); } -void ScrollView::jumpToDestination(const Vector2 &des) +void ScrollView::jumpToDestination(const Vec2 &des) { float finalOffsetX = des.x; float finalOffsetY = des.y; @@ -572,7 +572,7 @@ void ScrollView::jumpToDestination(const Vector2 &des) default: break; } - _innerContainer->setPosition(Vector2(finalOffsetX, finalOffsetY)); + _innerContainer->setPosition(Vec2(finalOffsetX, finalOffsetY)); } void ScrollView::stopAutoScrollChildren() @@ -1194,22 +1194,22 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) void ScrollView::scrollToBottom(float time, bool attenuated) { - startAutoScrollChildrenWithDestination(Vector2(_innerContainer->getPosition().x, 0.0f), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, 0.0f), time, attenuated); } void ScrollView::scrollToTop(float time, bool attenuated) { - startAutoScrollChildrenWithDestination(Vector2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated); } void ScrollView::scrollToLeft(float time, bool attenuated) { - startAutoScrollChildrenWithDestination(Vector2(0.0f, _innerContainer->getPosition().y), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(0.0f, _innerContainer->getPosition().y), time, attenuated); } void ScrollView::scrollToRight(float time, bool attenuated) { - startAutoScrollChildrenWithDestination(Vector2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated); } void ScrollView::scrollToTopLeft(float time, bool attenuated) @@ -1219,7 +1219,7 @@ void ScrollView::scrollToTopLeft(float time, bool attenuated) CCLOG("Scroll diretion is not both!"); return; } - startAutoScrollChildrenWithDestination(Vector2(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated); } void ScrollView::scrollToTopRight(float time, bool attenuated) @@ -1229,7 +1229,7 @@ void ScrollView::scrollToTopRight(float time, bool attenuated) CCLOG("Scroll diretion is not both!"); return; } - startAutoScrollChildrenWithDestination(Vector2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated); } void ScrollView::scrollToBottomLeft(float time, bool attenuated) @@ -1239,7 +1239,7 @@ void ScrollView::scrollToBottomLeft(float time, bool attenuated) CCLOG("Scroll diretion is not both!"); return; } - startAutoScrollChildrenWithDestination(Vector2::ZERO, time, attenuated); + startAutoScrollChildrenWithDestination(Vec2::ZERO, time, attenuated); } void ScrollView::scrollToBottomRight(float time, bool attenuated) @@ -1249,23 +1249,23 @@ void ScrollView::scrollToBottomRight(float time, bool attenuated) CCLOG("Scroll diretion is not both!"); return; } - startAutoScrollChildrenWithDestination(Vector2(_size.width - _innerContainer->getSize().width, 0.0f), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, 0.0f), time, attenuated); } void ScrollView::scrollToPercentVertical(float percent, float time, bool attenuated) { float minY = _size.height - _innerContainer->getSize().height; float h = - minY; - startAutoScrollChildrenWithDestination(Vector2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated); } void ScrollView::scrollToPercentHorizontal(float percent, float time, bool attenuated) { float w = _innerContainer->getSize().width - _size.width; - startAutoScrollChildrenWithDestination(Vector2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated); } -void ScrollView::scrollToPercentBothDirection(const Vector2& percent, float time, bool attenuated) +void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float time, bool attenuated) { if (_direction != Direction::BOTH) { @@ -1274,27 +1274,27 @@ void ScrollView::scrollToPercentBothDirection(const Vector2& percent, float time float minY = _size.height - _innerContainer->getSize().height; float h = - minY; float w = _innerContainer->getSize().width - _size.width; - startAutoScrollChildrenWithDestination(Vector2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated); + startAutoScrollChildrenWithDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated); } void ScrollView::jumpToBottom() { - jumpToDestination(Vector2(_innerContainer->getPosition().x, 0.0f)); + jumpToDestination(Vec2(_innerContainer->getPosition().x, 0.0f)); } void ScrollView::jumpToTop() { - jumpToDestination(Vector2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height)); + jumpToDestination(Vec2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height)); } void ScrollView::jumpToLeft() { - jumpToDestination(Vector2(0.0f, _innerContainer->getPosition().y)); + jumpToDestination(Vec2(0.0f, _innerContainer->getPosition().y)); } void ScrollView::jumpToRight() { - jumpToDestination(Vector2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y)); + jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y)); } void ScrollView::jumpToTopLeft() @@ -1304,7 +1304,7 @@ void ScrollView::jumpToTopLeft() CCLOG("Scroll diretion is not both!"); return; } - jumpToDestination(Vector2(0.0f, _size.height - _innerContainer->getSize().height)); + jumpToDestination(Vec2(0.0f, _size.height - _innerContainer->getSize().height)); } void ScrollView::jumpToTopRight() @@ -1314,7 +1314,7 @@ void ScrollView::jumpToTopRight() CCLOG("Scroll diretion is not both!"); return; } - jumpToDestination(Vector2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height)); + jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height)); } void ScrollView::jumpToBottomLeft() @@ -1324,7 +1324,7 @@ void ScrollView::jumpToBottomLeft() CCLOG("Scroll diretion is not both!"); return; } - jumpToDestination(Vector2::ZERO); + jumpToDestination(Vec2::ZERO); } void ScrollView::jumpToBottomRight() @@ -1334,23 +1334,23 @@ void ScrollView::jumpToBottomRight() CCLOG("Scroll diretion is not both!"); return; } - jumpToDestination(Vector2(_size.width - _innerContainer->getSize().width, 0.0f)); + jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, 0.0f)); } void ScrollView::jumpToPercentVertical(float percent) { float minY = _size.height - _innerContainer->getSize().height; float h = - minY; - jumpToDestination(Vector2(_innerContainer->getPosition().x, minY + percent * h / 100.0f)); + jumpToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f)); } void ScrollView::jumpToPercentHorizontal(float percent) { float w = _innerContainer->getSize().width - _size.width; - jumpToDestination(Vector2(-(percent * w / 100.0f), _innerContainer->getPosition().y)); + jumpToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y)); } -void ScrollView::jumpToPercentBothDirection(const Vector2& percent) +void ScrollView::jumpToPercentBothDirection(const Vec2& percent) { if (_direction != Direction::BOTH) { @@ -1359,7 +1359,7 @@ void ScrollView::jumpToPercentBothDirection(const Vector2& percent) float minY = _size.height - _innerContainer->getSize().height; float h = - minY; float w = _innerContainer->getSize().width - _size.width; - jumpToDestination(Vector2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f)); + jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f)); } void ScrollView::startRecordSlidAction() @@ -1384,7 +1384,7 @@ void ScrollView::endRecordSlidAction() return; } float totalDis = 0.0f; - Vector2 dir; + Vec2 dir; switch (_direction) { case Direction::VERTICAL: @@ -1411,7 +1411,7 @@ void ScrollView::endRecordSlidAction() break; case Direction::BOTH: { - Vector2 subVector = _touchEndedPoint - _touchBeganPoint; + Vec2 subVector = _touchEndedPoint - _touchBeganPoint; totalDis = subVector.getLength(); dir = subVector.getNormalized(); break; @@ -1425,7 +1425,7 @@ void ScrollView::endRecordSlidAction() } } -void ScrollView::handlePressLogic(const Vector2 &touchPoint) +void ScrollView::handlePressLogic(const Vec2 &touchPoint) { _touchBeganPoint = convertToNodeSpace(touchPoint); _touchMovingPoint = _touchBeganPoint; @@ -1433,10 +1433,10 @@ void ScrollView::handlePressLogic(const Vector2 &touchPoint) _bePressed = true; } -void ScrollView::handleMoveLogic(const Vector2 &touchPoint) +void ScrollView::handleMoveLogic(const Vec2 &touchPoint) { _touchMovedPoint = convertToNodeSpace(touchPoint); - Vector2 delta = _touchMovedPoint - _touchMovingPoint; + Vec2 delta = _touchMovedPoint - _touchMovingPoint; _touchMovingPoint = _touchMovedPoint; switch (_direction) { @@ -1460,7 +1460,7 @@ void ScrollView::handleMoveLogic(const Vector2 &touchPoint) } } -void ScrollView::handleReleaseLogic(const Vector2 &touchPoint) +void ScrollView::handleReleaseLogic(const Vec2 &touchPoint) { _touchEndedPoint = convertToNodeSpace(touchPoint); endRecordSlidAction(); @@ -1516,7 +1516,7 @@ void ScrollView::recordSlidTime(float dt) } } -void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Vector2 &touchPoint) +void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Vec2 &touchPoint) { switch (handleState) { @@ -1545,7 +1545,7 @@ void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Vect } } -void ScrollView::checkChildInfo(int handleState,Widget* sender,const Vector2 &touchPoint) +void ScrollView::checkChildInfo(int handleState,Widget* sender,const Vec2 &touchPoint) { interceptTouchEvent(handleState, sender, touchPoint); } diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 96e68d9e7b..2f986dfdeb 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -180,7 +180,7 @@ public: /** * Scroll inner container to both direction percent position of scrollview. */ - void scrollToPercentBothDirection(const Vector2& percent, float time, bool attenuated); + void scrollToPercentBothDirection(const Vec2& percent, float time, bool attenuated); /** * Move inner container to bottom boundary of scrollview. @@ -235,7 +235,7 @@ public: /** * Move inner container to both direction percent position of scrollview. */ - void jumpToPercentBothDirection(const Vector2& percent); + void jumpToPercentBothDirection(const Vec2& percent); /** * Changes inner container size of scrollview. @@ -350,9 +350,9 @@ protected: void bounceChildren(float dt); void checkBounceBoundary(); bool checkNeedBounce(); - void startAutoScrollChildrenWithOriginalSpeed(const Vector2& dir, float v, bool attenuated, float acceleration); - void startAutoScrollChildrenWithDestination(const Vector2& des, float time, bool attenuated); - void jumpToDestination(const Vector2& des); + void startAutoScrollChildrenWithOriginalSpeed(const Vec2& dir, float v, bool attenuated, float acceleration); + void startAutoScrollChildrenWithDestination(const Vec2& des, float time, bool attenuated); + void jumpToDestination(const Vec2& des); void stopAutoScrollChildren(); void startBounceChildren(float v); void stopBounceChildren(); @@ -361,11 +361,11 @@ protected: bool bounceScrollChildren(float touchOffsetX, float touchOffsetY); void startRecordSlidAction(); virtual void endRecordSlidAction(); - virtual void handlePressLogic(const Vector2 &touchPoint) override; - virtual void handleMoveLogic(const Vector2 &touchPoint) override; - virtual void handleReleaseLogic(const Vector2 &touchPoint) override; - virtual void interceptTouchEvent(int handleState,Widget* sender,const Vector2 &touchPoint) override; - virtual void checkChildInfo(int handleState,Widget* sender,const Vector2 &touchPoint) override; + virtual void handlePressLogic(const Vec2 &touchPoint) override; + virtual void handleMoveLogic(const Vec2 &touchPoint) override; + virtual void handleReleaseLogic(const Vec2 &touchPoint) override; + virtual void interceptTouchEvent(int handleState,Widget* sender,const Vec2 &touchPoint) override; + virtual void checkChildInfo(int handleState,Widget* sender,const Vec2 &touchPoint) override; void recordSlidTime(float dt); void scrollToTopEvent(); void scrollToBottomEvent(); @@ -387,11 +387,11 @@ protected: Direction _direction; - Vector2 _touchBeganPoint; - Vector2 _touchMovedPoint; - Vector2 _touchEndedPoint; - Vector2 _touchMovingPoint; - Vector2 _autoScrollDir; + Vec2 _touchBeganPoint; + Vec2 _touchMovedPoint; + Vec2 _touchEndedPoint; + Vec2 _touchMovingPoint; + Vec2 _autoScrollDir; float _topBoundary; float _bottomBoundary; @@ -411,11 +411,11 @@ protected: float _autoScrollAcceleration; bool _isAutoScrollSpeedAttenuated; bool _needCheckAutoScrollDestination; - Vector2 _autoScrollDestination; + Vec2 _autoScrollDestination; bool _bePressed; float _slidTime; - Vector2 _moveChildPoint; + Vec2 _moveChildPoint; float _childFocusCancelOffset; bool _leftBounceNeeded; @@ -425,7 +425,7 @@ protected: bool _bounceEnabled; bool _bouncing; - Vector2 _bounceDir; + Vec2 _bounceDir; float _bounceOriginalSpeed; bool _inertiaScrollEnabled; diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index cc7c26d6ee..09fd5d23e7 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -99,7 +99,7 @@ void Slider::initRenderer() { _barRenderer = Sprite::create(); _progressBarRenderer = Sprite::create(); - _progressBarRenderer->setAnchorPoint(Vector2(0.0f, 0.5f)); + _progressBarRenderer->setAnchorPoint(Vec2(0.0f, 0.5f)); addProtectedChild(_barRenderer, BASEBAR_RENDERER_Z, -1); addProtectedChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); _slidBallNormalRenderer = Sprite::create(); @@ -187,7 +187,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType break; } updateRGBAToRenderer(_progressBarRenderer); - _progressBarRenderer->setAnchorPoint(Vector2(0.0f, 0.5f)); + _progressBarRenderer->setAnchorPoint(Vec2(0.0f, 0.5f)); _progressBarTextureSize = _progressBarRenderer->getContentSize(); _progressBarRendererDirty = true; } @@ -368,7 +368,7 @@ void Slider::setPercent(int percent) _percent = percent; float res = percent / 100.0f; float dis = _barLength * res; - _slidBallRenderer->setPosition(Vector2(dis, _contentSize.height / 2.0f)); + _slidBallRenderer->setPosition(Vec2(dis, _contentSize.height / 2.0f)); if (_scale9Enabled) { static_cast(_progressBarRenderer)->setPreferredSize(Size(dis,_progressBarTextureSize.height)); @@ -382,9 +382,9 @@ void Slider::setPercent(int percent) } } -bool Slider::hitTest(const cocos2d::Vector2 &pt) +bool Slider::hitTest(const cocos2d::Vec2 &pt) { - Vector2 nsp = this->_slidBallNormalRenderer->convertToNodeSpace(pt); + Vec2 nsp = this->_slidBallNormalRenderer->convertToNodeSpace(pt); Size ballSize = this->_slidBallNormalRenderer->getContentSize(); Rect ballRect = Rect(0,0, ballSize.width, ballSize.height); if (ballRect.containsPoint(nsp)) { @@ -398,7 +398,7 @@ bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent) bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { - Vector2 nsp = convertToNodeSpace(_touchStartPos); + Vec2 nsp = convertToNodeSpace(_touchStartPos); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } @@ -408,7 +408,7 @@ bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent) void Slider::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePos = touch->getLocation(); - Vector2 nsp = convertToNodeSpace(_touchMovePos); + Vec2 nsp = convertToNodeSpace(_touchMovePos); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index 3472266a8f..fc2e9af290 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -199,7 +199,7 @@ public: virtual void ignoreContentAdaptWithSize(bool ignore) override; //override the widget's hitTest function to perfom its own - virtual bool hitTest(const Vector2 &pt) override; + virtual bool hitTest(const Vec2 &pt) override; /** * Returns the "class name" of widget. */ diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index e77e7f6420..e75b6cc881 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -437,11 +437,11 @@ void TextField::setTouchAreaEnabled(bool enable) _useTouchArea = enable; } -bool TextField::hitTest(const Vector2 &pt) +bool TextField::hitTest(const Vec2 &pt) { if (_useTouchArea) { - Vector2 nsp = convertToNodeSpace(pt); + Vec2 nsp = convertToNodeSpace(pt); Rect bb = Rect(-_touchWidth * _anchorPoint.x, -_touchHeight * _anchorPoint.y, _touchWidth, _touchHeight); if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) { diff --git a/cocos/ui/UITextField.h b/cocos/ui/UITextField.h index 1279304531..95cc9ca650 100644 --- a/cocos/ui/UITextField.h +++ b/cocos/ui/UITextField.h @@ -125,7 +125,7 @@ public: void setTouchSize(const Size &size); Size getTouchSize(); void setTouchAreaEnabled(bool enable); - virtual bool hitTest(const Vector2 &pt); + virtual bool hitTest(const Vec2 &pt); void setText(const std::string& text); void setPlaceHolder(const std::string& value); const std::string& getPlaceHolder(); diff --git a/cocos/ui/UIVideoPlayer.h b/cocos/ui/UIVideoPlayer.h index 24558c6b60..5f30281b47 100644 --- a/cocos/ui/UIVideoPlayer.h +++ b/cocos/ui/UIVideoPlayer.h @@ -74,7 +74,7 @@ namespace experimental{ virtual void addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback); virtual void onPlayEvent(VideoPlayer::EventType event); - virtual void draw(Renderer *renderer, const Matrix& transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated) override; protected: VideoPlayer(); diff --git a/cocos/ui/UIVideoPlayerIOS.mm b/cocos/ui/UIVideoPlayerIOS.mm index ed54eb2ecc..dfc1c3021a 100644 --- a/cocos/ui/UIVideoPlayerIOS.mm +++ b/cocos/ui/UIVideoPlayerIOS.mm @@ -312,7 +312,7 @@ void VideoPlayer::setURL(const std::string& videoUrl) [((UIVideoViewWrapperIos*)_videoView) setURL:(int)_videoSource :_videoURL]; } -void VideoPlayer::draw(Renderer* renderer, const Matrix &transform, bool transformUpdated) +void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated) { cocos2d::ui::Widget::draw(renderer,transform,transformUpdated); @@ -325,8 +325,8 @@ void VideoPlayer::draw(Renderer* renderer, const Matrix &transform, bool transfo auto winSize = directorInstance->getWinSize(); - auto leftBottom = convertToWorldSpace(Vector2::ZERO); - auto rightTop = convertToWorldSpace(Vector2(_contentSize.width,_contentSize.height)); + auto leftBottom = convertToWorldSpace(Vec2::ZERO); + auto rightTop = convertToWorldSpace(Vec2(_contentSize.width,_contentSize.height)); auto uiLeft = (frameSize.width / 2 + (leftBottom.x - winSize.width / 2 ) * glView->getScaleX()) / scaleFactor; auto uiTop = (frameSize.height /2 - (rightTop.y - winSize.height / 2) * glView->getScaleY()) / scaleFactor; diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 2c74761008..c2164c6ab8 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -40,9 +40,9 @@ _touchEnabled(false), _touchPassedEnabled(false), _highlight(false), _brightStyle(BrightStyle::NONE), -_touchStartPos(Vector2::ZERO), -_touchMovePos(Vector2::ZERO), -_touchEndPos(Vector2::ZERO), +_touchStartPos(Vec2::ZERO), +_touchMovePos(Vec2::ZERO), +_touchEndPos(Vec2::ZERO), _touchEventListener(nullptr), _touchEventSelector(nullptr), _name("default"), @@ -52,9 +52,9 @@ _customSize(Size::ZERO), _ignoreSize(false), _affectByClipping(false), _sizeType(SizeType::ABSOLUTE), -_sizePercent(Vector2::ZERO), +_sizePercent(Vec2::ZERO), _positionType(PositionType::ABSOLUTE), -_positionPercent(Vector2::ZERO), +_positionPercent(Vec2::ZERO), _reorderWidgetChildDirty(true), _hitted(false), _touchListener(nullptr), @@ -67,7 +67,7 @@ _focusEnabled(true) { onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this); onNextFocusedWidget = nullptr; - this->setAnchorPoint(Vector2(0.5f, 0.5f)); + this->setAnchorPoint(Vec2(0.5f, 0.5f)); } Widget::~Widget() @@ -102,7 +102,7 @@ bool Widget::init() initRenderer(); setBright(true); ignoreContentAdaptWithSize(true); - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); return true; } return false; @@ -120,7 +120,7 @@ void Widget::onExit() ProtectedNode::onExit(); } -void Widget::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Widget::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if (_enabled) { @@ -218,12 +218,12 @@ void Widget::setSize(const Size &size) { spy = _customSize.height / pSize.height; } - _sizePercent = Vector2(spx, spy); + _sizePercent = Vec2(spx, spy); } onSizeChanged(); } -void Widget::setSizePercent(const Vector2 &percent) +void Widget::setSizePercent(const Vec2 &percent) { _sizePercent = percent; Size cSize = _customSize; @@ -290,7 +290,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) { spy = _customSize.height / parentSize.height; } - _sizePercent = Vector2(spx, spy); + _sizePercent = Vec2(spx, spy); break; } case SizeType::PERCENT: @@ -311,24 +311,24 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) break; } onSizeChanged(); - Vector2 absPos = getPosition(); + Vec2 absPos = getPosition(); switch (_positionType) { case PositionType::ABSOLUTE: { if (parentSize.width <= 0.0f || parentSize.height <= 0.0f) { - _positionPercent = Vector2::ZERO; + _positionPercent = Vec2::ZERO; } else { - _positionPercent = Vector2(absPos.x / parentSize.width, absPos.y / parentSize.height); + _positionPercent = Vec2(absPos.x / parentSize.width, absPos.y / parentSize.height); } break; } case PositionType::PERCENT: { - absPos = Vector2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); + absPos = Vec2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); break; } default: @@ -381,14 +381,14 @@ const Size& Widget::getCustomSize() const return _customSize; } -const Vector2& Widget::getSizePercent() const +const Vec2& Widget::getSizePercent() const { return _sizePercent; } -Vector2 Widget::getWorldPosition() +Vec2 Widget::getWorldPosition() { - return convertToWorldSpace(Vector2(_anchorPoint.x * _contentSize.width, _anchorPoint.y * _contentSize.height)); + return convertToWorldSpace(Vec2(_anchorPoint.x * _contentSize.width, _anchorPoint.y * _contentSize.height)); } Node* Widget::getVirtualRenderer() @@ -661,9 +661,9 @@ void Widget::addTouchEventListener(Widget::ccWidgetTouchCallback callback) this->_touchEventCallback = callback; } -bool Widget::hitTest(const Vector2 &pt) +bool Widget::hitTest(const Vec2 &pt) { - Vector2 nsp = convertToNodeSpace(pt); + Vec2 nsp = convertToNodeSpace(pt); Rect bb; bb.size = _contentSize; if (bb.containsPoint(nsp)) @@ -673,7 +673,7 @@ bool Widget::hitTest(const Vector2 &pt) return false; } -bool Widget::clippingParentAreaContainPoint(const Vector2 &pt) +bool Widget::clippingParentAreaContainPoint(const Vec2 &pt) { _affectByClipping = false; Widget* parent = getWidgetParent(); @@ -715,7 +715,7 @@ bool Widget::clippingParentAreaContainPoint(const Vector2 &pt) return true; } -void Widget::checkChildInfo(int handleState, Widget *sender, const Vector2 &touchPoint) +void Widget::checkChildInfo(int handleState, Widget *sender, const Vec2 &touchPoint) { Widget* widgetParent = getWidgetParent(); if (widgetParent) @@ -724,7 +724,7 @@ void Widget::checkChildInfo(int handleState, Widget *sender, const Vector2 &touc } } -void Widget::setPosition(const Vector2 &pos) +void Widget::setPosition(const Vec2 &pos) { if (_running) { @@ -734,18 +734,18 @@ void Widget::setPosition(const Vector2 &pos) Size pSize = widgetParent->getSize(); if (pSize.width <= 0.0f || pSize.height <= 0.0f) { - _positionPercent = Vector2::ZERO; + _positionPercent = Vec2::ZERO; } else { - _positionPercent = Vector2(pos.x / pSize.width, pos.y / pSize.height); + _positionPercent = Vec2(pos.x / pSize.width, pos.y / pSize.height); } } } ProtectedNode::setPosition(pos); } -void Widget::setPositionPercent(const Vector2 &percent) +void Widget::setPositionPercent(const Vec2 &percent) { _positionPercent = percent; if (_running) @@ -754,13 +754,13 @@ void Widget::setPositionPercent(const Vector2 &percent) if (widgetParent) { Size parentSize = widgetParent->getSize(); - Vector2 absPos = Vector2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); + Vec2 absPos = Vec2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); setPosition(absPos); } } } -const Vector2& Widget::getPositionPercent() +const Vec2& Widget::getPositionPercent() { return _positionPercent; } @@ -805,17 +805,17 @@ float Widget::getTopInParent() return getBottomInParent() + _size.height; } -const Vector2& Widget::getTouchStartPos() +const Vec2& Widget::getTouchStartPos() { return _touchStartPos; } -const Vector2& Widget::getTouchMovePos() +const Vec2& Widget::getTouchMovePos() { return _touchMovePos; } -const Vector2& Widget::getTouchEndPos() +const Vec2& Widget::getTouchEndPos() { return _touchEndPos; } diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index 517adda8af..b95d4a7d7b 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -231,7 +231,7 @@ public: */ virtual Widget* getChildByName(const std::string& name); - virtual void visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; /** * Sets the touch event target/selector of the menu item @@ -244,31 +244,31 @@ public: /** * Changes the position (x,y) of the widget in OpenGL coordinates * - * Usually we use p(x,y) to compose Vector2 object. + * Usually we use p(x,y) to compose Vec2 object. * The original point (0,0) is at the left-bottom corner of screen. * * @param position The position (x,y) of the widget in OpenGL coordinates */ - virtual void setPosition(const Vector2 &pos) override; + virtual void setPosition(const Vec2 &pos) override; /** * Changes the position (x,y) of the widget in OpenGL coordinates * - * Usually we use p(x,y) to compose Vector2 object. + * Usually we use p(x,y) to compose Vec2 object. * The original point (0,0) is at the left-bottom corner of screen. * * @param percent The percent (x,y) of the widget in OpenGL coordinates */ - void setPositionPercent(const Vector2 &percent); + void setPositionPercent(const Vec2 &percent); /** * Gets the percent (x,y) of the widget in OpenGL coordinates * - * @see setPosition(const Vector2&) + * @see setPosition(const Vec2&) * * @return The percent (x,y) of the widget in OpenGL coordinates */ - const Vector2& getPositionPercent(); + const Vec2& getPositionPercent(); /** * Changes the position type of the widget @@ -350,33 +350,33 @@ public: * * @return true if the point is in parent's area, flase otherwise. */ - bool clippingParentAreaContainPoint(const Vector2 &pt); + bool clippingParentAreaContainPoint(const Vec2 &pt); /* * Sends the touch event to widget's parent */ - virtual void checkChildInfo(int handleState,Widget* sender,const Vector2 &touchPoint); + virtual void checkChildInfo(int handleState,Widget* sender,const Vec2 &touchPoint); /* * Gets the touch began point of widget when widget is selected. * * @return the touch began point. */ - const Vector2& getTouchStartPos(); + const Vec2& getTouchStartPos(); /* * Gets the touch move point of widget when widget is selected. * * @return the touch move point. */ - const Vector2& getTouchMovePos(); + const Vec2& getTouchMovePos(); /* * Gets the touch end point of widget when widget is selected. * * @return the touch end point. */ - const Vector2& getTouchEndPos(); + const Vec2& getTouchEndPos(); /** * Changes the name that is used to identify the widget easily. @@ -406,7 +406,7 @@ public: * * @param percent that is widget's percent size */ - virtual void setSizePercent(const Vector2 &percent); + virtual void setSizePercent(const Vec2 &percent); /** * Changes the size type of widget. @@ -442,7 +442,7 @@ public: * * @return size percent */ - const Vector2& getSizePercent() const; + const Vec2& getSizePercent() const; /** * Checks a point if is in widget's space @@ -451,7 +451,7 @@ public: * * @return true if the point is in widget's space, flase otherwise. */ - virtual bool hitTest(const Vector2 &pt); + virtual bool hitTest(const Vec2 &pt); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent); virtual void onTouchMoved(Touch *touch, Event *unusedEvent); @@ -499,7 +499,7 @@ public: * * @return world position of widget. */ - Vector2 getWorldPosition(); + Vec2 getWorldPosition(); /** * Gets the Virtual Renderer of widget. @@ -636,9 +636,9 @@ protected: bool _touchPassedEnabled; ///< is the touch event should be passed bool _highlight; ///< is the widget on focus BrightStyle _brightStyle; ///< bright style - Vector2 _touchStartPos; ///< touch began point - Vector2 _touchMovePos; ///< touch moved point - Vector2 _touchEndPos; ///< touch ended point + Vec2 _touchStartPos; ///< touch began point + Vec2 _touchMovePos; ///< touch moved point + Vec2 _touchEndPos; ///< touch ended point //if use the old API, we must retain the _touchEventListener Ref* _touchEventListener; @@ -665,9 +665,9 @@ protected: bool _ignoreSize; bool _affectByClipping; SizeType _sizeType; - Vector2 _sizePercent; + Vec2 _sizePercent; PositionType _positionType; - Vector2 _positionPercent; + Vec2 _positionPercent; bool _reorderWidgetChildDirty; bool _hitted; EventListenerTouchOneByOne* _touchListener; diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index e40c11b694..128443fa5f 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -240,9 +240,9 @@ bool Control::isOpacityModifyRGB() const } -Vector2 Control::getTouchLocation(Touch* touch) +Vec2 Control::getTouchLocation(Touch* touch) { - Vector2 touchLocation = touch->getLocation(); // Get the touch position + Vec2 touchLocation = touch->getLocation(); // Get the touch position touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class return touchLocation; @@ -250,7 +250,7 @@ Vector2 Control::getTouchLocation(Touch* touch) bool Control::isTouchInside(Touch* touch) { - Vector2 touchLocation = touch->getLocation(); // Get the touch position + Vec2 touchLocation = touch->getLocation(); // Get the touch position touchLocation = this->getParent()->convertToNodeSpace(touchLocation); Rect bBox = getBoundingBox(); return bBox.containsPoint(touchLocation); diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index e81a94e7e9..cf6efa865d 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -152,7 +152,7 @@ public: * control space coordinates. * @param touch A Touch object that represents a touch. */ - virtual Vector2 getTouchLocation(Touch* touch); + virtual Vec2 getTouchLocation(Touch* touch); virtual bool onTouchBegan(Touch *touch, Event *event) { return false; }; virtual void onTouchMoved(Touch *touch, Event *event) {}; diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index c3754aaa18..69617309c0 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -89,7 +89,7 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b // Set the default anchor point ignoreAnchorPointForPosition(false); - setAnchorPoint(Vector2::ANCHOR_MIDDLE); + setAnchorPoint(Vec2::ANCHOR_MIDDLE); // Set the nodes setTitleLabel(node); @@ -107,7 +107,7 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b setTitleLabelForState(node, Control::State::NORMAL); setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL); - setLabelAnchorPoint(Vector2::ANCHOR_MIDDLE); + setLabelAnchorPoint(Vec2::ANCHOR_MIDDLE); // Layout update needsLayout(); @@ -250,12 +250,12 @@ bool ControlButton::doesAdjustBackgroundImage() return _doesAdjustBackgroundImage; } -const Vector2& ControlButton::getLabelAnchorPoint() const +const Vec2& ControlButton::getLabelAnchorPoint() const { return this->_labelAnchorPoint; } -void ControlButton::setLabelAnchorPoint(const Vector2& labelAnchorPoint) +void ControlButton::setLabelAnchorPoint(const Vec2& labelAnchorPoint) { this->_labelAnchorPoint = labelAnchorPoint; if (_titleLabel != nullptr) @@ -348,7 +348,7 @@ void ControlButton::setTitleLabelForState(Node* titleLabel, State state) _titleLabelDispatchTable.insert((int)state, titleLabel); titleLabel->setVisible(false); - titleLabel->setAnchorPoint(Vector2(0.5f, 0.5f)); + titleLabel->setAnchorPoint(Vec2(0.5f, 0.5f)); addChild(titleLabel, 1); // If the current state if equal to the given state we update the layout @@ -447,7 +447,7 @@ void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, State stat _backgroundSpriteDispatchTable.insert((int)state, sprite); sprite->setVisible(false); - sprite->setAnchorPoint(Vector2(0.5f, 0.5f)); + sprite->setAnchorPoint(Vec2(0.5f, 0.5f)); addChild(sprite); if (this->_preferredSize.width != 0 || this->_preferredSize.height != 0) @@ -509,14 +509,14 @@ void ControlButton::needsLayout() } if (_titleLabel != nullptr) { - _titleLabel->setPosition(Vector2 (getContentSize().width / 2, getContentSize().height / 2)); + _titleLabel->setPosition(Vec2 (getContentSize().width / 2, getContentSize().height / 2)); } // Update the background sprite this->setBackgroundSprite(this->getBackgroundSpriteForState(_state)); if (_backgroundSprite != nullptr) { - _backgroundSprite->setPosition(Vector2 (getContentSize().width / 2, getContentSize().height / 2)); + _backgroundSprite->setPosition(Vec2 (getContentSize().width / 2, getContentSize().height / 2)); } // Get the title label size @@ -571,14 +571,14 @@ void ControlButton::needsLayout() if (_titleLabel != nullptr) { - _titleLabel->setPosition(Vector2(getContentSize().width/2, getContentSize().height/2)); + _titleLabel->setPosition(Vec2(getContentSize().width/2, getContentSize().height/2)); // Make visible the background and the label _titleLabel->setVisible(true); } if (_backgroundSprite != nullptr) { - _backgroundSprite->setPosition(Vector2(getContentSize().width/2, getContentSize().height/2)); + _backgroundSprite->setPosition(Vec2(getContentSize().width/2, getContentSize().height/2)); _backgroundSprite->setVisible(true); } } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 4db682ed51..f471cc039c 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -231,7 +231,7 @@ protected: /** Scale ratio button on touchdown. Default value 1.1f */ CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio); - CC_PROPERTY_PASS_BY_REF(Vector2, _labelAnchorPoint, LabelAnchorPoint); + CC_PROPERTY_PASS_BY_REF(Vec2, _labelAnchorPoint, LabelAnchorPoint); std::unordered_map _titleDispatchTable; std::unordered_map _titleColorDispatchTable; diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index e4d0076717..36a2c6ec31 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -76,19 +76,19 @@ bool ControlColourPicker::init() _hsv.v = 0; // Add image - _background=ControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, Vector2::ZERO, Vector2(0.5f, 0.5f)); + _background=ControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, Vec2::ZERO, Vec2(0.5f, 0.5f)); CC_SAFE_RETAIN(_background); - Vector2 backgroundPointZero = _background->getPosition() - Vector2(_background->getContentSize().width / 2, _background->getContentSize().height / 2); + Vec2 backgroundPointZero = _background->getPosition() - Vec2(_background->getContentSize().width / 2, _background->getContentSize().height / 2); // Setup panels float hueShift = 8; float colourShift = 28; _huePicker = new ControlHuePicker(); - _huePicker->initWithTargetAndPos(spriteSheet, Vector2(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); + _huePicker->initWithTargetAndPos(spriteSheet, Vec2(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); _colourPicker = new ControlSaturationBrightnessPicker(); - _colourPicker->initWithTargetAndPos(spriteSheet, Vector2(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); + _colourPicker->initWithTargetAndPos(spriteSheet, Vec2(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); // Setup events _huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), Control::EventType::VALUE_CHANGED); diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp index 289a755dae..9850aacff8 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp @@ -49,7 +49,7 @@ ControlHuePicker::~ControlHuePicker() CC_SAFE_RELEASE(_slider); } -ControlHuePicker* ControlHuePicker::create(Node* target, Vector2 pos) +ControlHuePicker* ControlHuePicker::create(Node* target, Vec2 pos) { ControlHuePicker *pRet = new ControlHuePicker(); pRet->initWithTargetAndPos(target, pos); @@ -58,15 +58,15 @@ ControlHuePicker* ControlHuePicker::create(Node* target, Vector2 pos) } -bool ControlHuePicker::initWithTargetAndPos(Node* target, Vector2 pos) +bool ControlHuePicker::initWithTargetAndPos(Node* target, Vec2 pos) { if (Control::init()) { // Add background and slider sprites - this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Vector2(0.0f, 0.0f))); - this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vector2(0.5f, 0.5f))); + this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Vec2(0.0f, 0.0f))); + this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2(0.5f, 0.5f))); - _slider->setPosition(Vector2(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f)); + _slider->setPosition(Vec2(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f)); _startPos=pos; // Sets the default value @@ -111,7 +111,7 @@ void ControlHuePicker::setHuePercentage(float hueValueInPercent) // Set new position of the slider float x = centerX + limit * cosf(angle); float y = centerY + limit * sinf(angle); - _slider->setPosition(Vector2(x, y)); + _slider->setPosition(Vec2(x, y)); } @@ -124,7 +124,7 @@ void ControlHuePicker::setEnabled(bool enabled) } } -void ControlHuePicker::updateSliderPosition(Vector2 location) +void ControlHuePicker::updateSliderPosition(Vec2 location) { // Clamp the position of the icon within the circle @@ -149,7 +149,7 @@ void ControlHuePicker::updateSliderPosition(Vector2 location) sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } -bool ControlHuePicker::checkSliderPosition(Vector2 location) +bool ControlHuePicker::checkSliderPosition(Vec2 location) { // compute the distance between the current location and the center double distance = sqrt(pow (location.x + 10, 2) + pow(location.y, 2)); @@ -171,7 +171,7 @@ bool ControlHuePicker::onTouchBegan(Touch* touch, Event* event) } // Get the touch location - Vector2 touchLocation=getTouchLocation(touch); + Vec2 touchLocation=getTouchLocation(touch); // Check the touch position on the slider return checkSliderPosition(touchLocation); @@ -181,7 +181,7 @@ bool ControlHuePicker::onTouchBegan(Touch* touch, Event* event) void ControlHuePicker::onTouchMoved(Touch* touch, Event* event) { // Get the touch location - Vector2 touchLocation=getTouchLocation(touch); + Vec2 touchLocation=getTouchLocation(touch); //small modification: this allows changing of the colour, even if the touch leaves the bounding area // updateSliderPosition(touchLocation); diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.h b/extensions/GUI/CCControlExtension/CCControlHuePicker.h index c60fe3db51..896e452618 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.h +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.h @@ -48,7 +48,7 @@ NS_CC_EXT_BEGIN class ControlHuePicker : public Control { public: - static ControlHuePicker* create(Node* target, Vector2 pos); + static ControlHuePicker* create(Node* target, Vec2 pos); /** * @js ctor */ @@ -58,7 +58,7 @@ public: * @lua NA */ virtual ~ControlHuePicker(); - virtual bool initWithTargetAndPos(Node* target, Vector2 pos); + virtual bool initWithTargetAndPos(Node* target, Vec2 pos); virtual void setEnabled(bool enabled); @@ -67,8 +67,8 @@ public: virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override; protected: - void updateSliderPosition(Vector2 location); - bool checkSliderPosition(Vector2 location); + void updateSliderPosition(Vec2 location); + bool checkSliderPosition(Vec2 location); //maunally put in the setters CC_SYNTHESIZE_READONLY(float, _hue, Hue); @@ -79,7 +79,7 @@ protected: //not sure if these need to be there actually. I suppose someone might want to access the sprite? CC_SYNTHESIZE_RETAIN(Sprite*, _background, Background); CC_SYNTHESIZE_RETAIN(Sprite*, _slider, Slider); - CC_SYNTHESIZE_READONLY(Vector2, _startPos, StartPos); + CC_SYNTHESIZE_READONLY(Vec2, _startPos, StartPos); }; // end of GUI group diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp index 083f979d95..13698bcbdf 100644 --- a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp @@ -167,7 +167,7 @@ float ControlPotentiometer::getMaximumValue() bool ControlPotentiometer::isTouchInside(Touch * touch) { - Vector2 touchLocation = this->getTouchLocation(touch); + Vec2 touchLocation = this->getTouchLocation(touch); float distance = this->distanceBetweenPointAndPoint(_progressTimer->getPosition(), touchLocation); @@ -190,17 +190,17 @@ bool ControlPotentiometer::onTouchBegan(Touch *pTouch, Event *pEvent) void ControlPotentiometer::onTouchMoved(Touch *pTouch, Event *pEvent) { - Vector2 location = this->getTouchLocation(pTouch); + Vec2 location = this->getTouchLocation(pTouch); this->potentiometerMoved(location); } void ControlPotentiometer::onTouchEnded(Touch *pTouch, Event *pEvent) { - this->potentiometerEnded(Vector2::ZERO); + this->potentiometerEnded(Vec2::ZERO); } -float ControlPotentiometer::distanceBetweenPointAndPoint(Vector2 point1, Vector2 point2) +float ControlPotentiometer::distanceBetweenPointAndPoint(Vec2 point1, Vec2 point2) { float dx = point1.x - point2.x; float dy = point1.y - point2.y; @@ -208,10 +208,10 @@ float ControlPotentiometer::distanceBetweenPointAndPoint(Vector2 point1, Vector2 } float ControlPotentiometer::angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( - Vector2 beginLineA, - Vector2 endLineA, - Vector2 beginLineB, - Vector2 endLineB) + Vec2 beginLineA, + Vec2 endLineA, + Vec2 beginLineB, + 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(Vector2 location) +void ControlPotentiometer::potentiometerBegan(Vec2 location) { setSelected(true); getThumbSprite()->setColor(Color3B::GRAY); } -void ControlPotentiometer::potentiometerMoved(Vector2 location) +void ControlPotentiometer::potentiometerMoved(Vec2 location) { float angle = this->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( _progressTimer->getPosition(), @@ -254,7 +254,7 @@ void ControlPotentiometer::potentiometerMoved(Vector2 location) _previousLocation = location; } -void ControlPotentiometer::potentiometerEnded(Vector2 location) +void ControlPotentiometer::potentiometerEnded(Vec2 location) { getThumbSprite()->setColor(Color3B::WHITE); setSelected(false); diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.h b/extensions/GUI/CCControlExtension/CCControlPotentiometer.h index bf238ac2c0..fc8156a8b8 100644 --- a/extensions/GUI/CCControlExtension/CCControlPotentiometer.h +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.h @@ -82,18 +82,18 @@ public: virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override; /** Factorize the event dispath into these methods. */ - void potentiometerBegan(Vector2 location); - void potentiometerMoved(Vector2 location); - void potentiometerEnded(Vector2 location); + void potentiometerBegan(Vec2 location); + void potentiometerMoved(Vec2 location); + void potentiometerEnded(Vec2 location); /** Returns the distance between the point1 and point2. */ - float distanceBetweenPointAndPoint(Vector2 point1, Vector2 point2); + float distanceBetweenPointAndPoint(Vec2 point1, Vec2 point2); /** Returns the angle in degree between line1 and line2. */ float angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( - Vector2 beginLineA, - Vector2 endLineA, - Vector2 beginLineB, - Vector2 endLineB); + Vec2 beginLineA, + Vec2 endLineA, + Vec2 beginLineB, + Vec2 endLineB); protected: /** Contains the receiver’s current value. */ @@ -107,7 +107,7 @@ protected: CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite) CC_SYNTHESIZE_RETAIN(ProgressTimer*, _progressTimer, ProgressTimer) - CC_SYNTHESIZE(Vector2, _previousLocation, PreviousLocation) + CC_SYNTHESIZE(Vec2, _previousLocation, PreviousLocation) }; // end of GUI group diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 8b452a39ff..d23eba4ab2 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -56,15 +56,15 @@ ControlSaturationBrightnessPicker::~ControlSaturationBrightnessPicker() _slider = NULL; } -bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, Vector2 pos) +bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, Vec2 pos) { if (Control::init()) { // Add background and slider sprites - _background=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, Vector2(0.0f, 0.0f)); - _overlay=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, Vector2(0.0f, 0.0f)); - _shadow=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, Vector2(0.0f, 0.0f)); - _slider=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vector2(0.5f, 0.5f)); + _background=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, Vec2(0.0f, 0.0f)); + _overlay=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, Vec2(0.0f, 0.0f)); + _shadow=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, Vec2(0.0f, 0.0f)); + _slider=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2(0.5f, 0.5f)); _startPos=pos; // starting position of the colour picker boxPos = 35; // starting position of the virtual box area for picking a colour @@ -77,7 +77,7 @@ bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, Vecto } } -ControlSaturationBrightnessPicker* ControlSaturationBrightnessPicker::create(Node* target, Vector2 pos) +ControlSaturationBrightnessPicker* ControlSaturationBrightnessPicker::create(Node* target, Vec2 pos) { ControlSaturationBrightnessPicker *pRet = new ControlSaturationBrightnessPicker(); pRet->initWithTargetAndPos(target, pos); @@ -108,14 +108,14 @@ void ControlSaturationBrightnessPicker::updateWithHSV(HSV hsv) void ControlSaturationBrightnessPicker::updateDraggerWithHSV(HSV hsv) { // Set the position of the slider to the correct saturation and brightness - Vector2 pos = Vector2(_startPos.x + boxPos + (boxSize*(1 - hsv.s)), + Vec2 pos = Vec2(_startPos.x + boxPos + (boxSize*(1 - hsv.s)), _startPos.y + boxPos + (boxSize*hsv.v)); // update updateSliderPosition(pos); } -void ControlSaturationBrightnessPicker::updateSliderPosition(Vector2 sliderPosition) +void ControlSaturationBrightnessPicker::updateSliderPosition(Vec2 sliderPosition) { // Clamp the position of the icon within the circle @@ -156,7 +156,7 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Vector2 sliderPosit _brightness = fabs((_startPos.y + (float)boxPos - sliderPosition.y)/(float)boxSize); } -bool ControlSaturationBrightnessPicker::checkSliderPosition(Vector2 location) +bool ControlSaturationBrightnessPicker::checkSliderPosition(Vec2 location) { // Clamp the position of the icon within the circle @@ -188,7 +188,7 @@ bool ControlSaturationBrightnessPicker::onTouchBegan(Touch* touch, Event* event) } // Get the touch location - Vector2 touchLocation=getTouchLocation(touch); + Vec2 touchLocation=getTouchLocation(touch); // Check the touch position on the slider return checkSliderPosition(touchLocation); @@ -198,7 +198,7 @@ bool ControlSaturationBrightnessPicker::onTouchBegan(Touch* touch, Event* event) void ControlSaturationBrightnessPicker::onTouchMoved(Touch* touch, Event* event) { // Get the touch location - Vector2 touchLocation=getTouchLocation(touch); + Vec2 touchLocation=getTouchLocation(touch); //small modification: this allows changing of the colour, even if the touch leaves the bounding area // updateSliderPosition(touchLocation); diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h index d22276f792..0ae9cbeaa1 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -57,7 +57,7 @@ class ControlSaturationBrightnessPicker : public Control CC_SYNTHESIZE_READONLY(Sprite*, _overlay, Overlay); CC_SYNTHESIZE_READONLY(Sprite*, _shadow, Shadow); CC_SYNTHESIZE_READONLY(Sprite*, _slider, Slider); - CC_SYNTHESIZE_READONLY(Vector2, _startPos, StartPos); + CC_SYNTHESIZE_READONLY(Vec2, _startPos, StartPos); protected: int boxPos; @@ -73,9 +73,9 @@ public: * @lua NA */ virtual ~ControlSaturationBrightnessPicker(); - virtual bool initWithTargetAndPos(Node* target, Vector2 pos); + virtual bool initWithTargetAndPos(Node* target, Vec2 pos); - static ControlSaturationBrightnessPicker* create(Node* target, Vector2 pos); + static ControlSaturationBrightnessPicker* create(Node* target, Vec2 pos); virtual void setEnabled(bool enabled); /** @@ -90,8 +90,8 @@ public: virtual void updateDraggerWithHSV(HSV hsv); protected: - void updateSliderPosition(Vector2 location); - bool checkSliderPosition(Vector2 location); + void updateSliderPosition(Vec2 location); + bool checkSliderPosition(Vec2 location); virtual bool onTouchBegan(Touch* touch, Event* pEvent); virtual void onTouchMoved(Touch *pTouch, Event *pEvent); diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 9bbe28f8e5..42cf2dae6a 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -135,20 +135,20 @@ bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressS setContentSize(Size(maxRect.size.width, maxRect.size.height)); // Add the slider background - _backgroundSprite->setAnchorPoint(Vector2(0.5f, 0.5f)); - _backgroundSprite->setPosition(Vector2(this->getContentSize().width / 2, this->getContentSize().height / 2)); + _backgroundSprite->setAnchorPoint(Vec2(0.5f, 0.5f)); + _backgroundSprite->setPosition(Vec2(this->getContentSize().width / 2, this->getContentSize().height / 2)); addChild(_backgroundSprite); // Add the progress bar - _progressSprite->setAnchorPoint(Vector2(0.0f, 0.5f)); - _progressSprite->setPosition(Vector2(0.0f, this->getContentSize().height / 2)); + _progressSprite->setAnchorPoint(Vec2(0.0f, 0.5f)); + _progressSprite->setPosition(Vec2(0.0f, this->getContentSize().height / 2)); addChild(_progressSprite); // Add the slider thumb - _thumbSprite->setPosition(Vector2(0.0f, this->getContentSize().height / 2)); + _thumbSprite->setPosition(Vec2(0.0f, this->getContentSize().height / 2)); addChild(_thumbSprite); - _selectedThumbSprite->setPosition(Vector2(0.0f, this->getContentSize().height / 2)); + _selectedThumbSprite->setPosition(Vec2(0.0f, this->getContentSize().height / 2)); _selectedThumbSprite->setVisible(false); addChild(_selectedThumbSprite); @@ -219,7 +219,7 @@ void ControlSlider::setEnabled(bool enabled) bool ControlSlider::isTouchInside(Touch * touch) { - Vector2 touchLocation = touch->getLocation(); + Vec2 touchLocation = touch->getLocation(); touchLocation = this->getParent()->convertToNodeSpace(touchLocation); Rect rect = this->getBoundingBox(); @@ -229,9 +229,9 @@ bool ControlSlider::isTouchInside(Touch * touch) return rect.containsPoint(touchLocation); } -Vector2 ControlSlider::locationFromTouch(Touch* touch) +Vec2 ControlSlider::locationFromTouch(Touch* touch) { - Vector2 touchLocation = touch->getLocation(); // Get the touch position + Vec2 touchLocation = touch->getLocation(); // Get the touch position touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class if (touchLocation.x < 0) @@ -253,20 +253,20 @@ bool ControlSlider::onTouchBegan(Touch* touch, Event* pEvent) return false; } - Vector2 location = locationFromTouch(touch); + Vec2 location = locationFromTouch(touch); sliderBegan(location); return true; } void ControlSlider::onTouchMoved(Touch *pTouch, Event *pEvent) { - Vector2 location = locationFromTouch(pTouch); + Vec2 location = locationFromTouch(pTouch); sliderMoved(location); } void ControlSlider::onTouchEnded(Touch *pTouch, Event *pEvent) { - sliderEnded(Vector2::ZERO); + sliderEnded(Vec2::ZERO); } void ControlSlider::needsLayout() @@ -279,7 +279,7 @@ void ControlSlider::needsLayout() // Update thumb position for new value float percent = (_value - _minimumValue) / (_maximumValue - _minimumValue); - Vector2 pos = _thumbSprite->getPosition(); + Vec2 pos = _thumbSprite->getPosition(); pos.x = percent * _backgroundSprite->getContentSize().width; _thumbSprite->setPosition(pos); _selectedThumbSprite->setPosition(pos); @@ -290,7 +290,7 @@ void ControlSlider::needsLayout() _progressSprite->setTextureRect(textureRect, _progressSprite->isTextureRectRotated(), textureRect.size); } -void ControlSlider::sliderBegan(Vector2 location) +void ControlSlider::sliderBegan(Vec2 location) { this->setSelected(true); _thumbSprite->setVisible(false); @@ -298,12 +298,12 @@ void ControlSlider::sliderBegan(Vector2 location) setValue(valueForLocation(location)); } -void ControlSlider::sliderMoved(Vector2 location) +void ControlSlider::sliderMoved(Vec2 location) { setValue(valueForLocation(location)); } -void ControlSlider::sliderEnded(Vector2 location) +void ControlSlider::sliderEnded(Vec2 location) { if (this->isSelected()) { @@ -314,7 +314,7 @@ void ControlSlider::sliderEnded(Vector2 location) this->setSelected(false); } -float ControlSlider::valueForLocation(Vector2 location) +float ControlSlider::valueForLocation(Vec2 location) { float percent = location.x/ _backgroundSprite->getContentSize().width; return MAX(MIN(_minimumValue + percent * (_maximumValue - _minimumValue), _maximumAllowedValue), _minimumAllowedValue); diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 63800b1eec..eeca322c25 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -111,21 +111,21 @@ public: virtual void setMaximumValue(float val); virtual void setEnabled(bool enabled); virtual bool isTouchInside(Touch * touch); - Vector2 locationFromTouch(Touch* touch); + Vec2 locationFromTouch(Touch* touch); virtual void setValue(float val); virtual void setMinimumValue(float val); protected: - void sliderBegan(Vector2 location); - void sliderMoved(Vector2 location); - void sliderEnded(Vector2 location); + void sliderBegan(Vec2 location); + void sliderMoved(Vec2 location); + void sliderEnded(Vec2 location); virtual bool onTouchBegan(Touch* touch, Event* pEvent); virtual void onTouchMoved(Touch *pTouch, Event *pEvent); virtual void onTouchEnded(Touch *pTouch, Event *pEvent); /** Returns the value for the given location. */ - float valueForLocation(Vector2 location); + float valueForLocation(Vec2 location); //maunally put in the setters /** Contains the receiver's current value. */ diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.cpp b/extensions/GUI/CCControlExtension/CCControlStepper.cpp index 3477a4b5e9..f96d27496d 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.cpp +++ b/extensions/GUI/CCControlExtension/CCControlStepper.cpp @@ -86,25 +86,25 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit // Add the minus components this->setMinusSprite(minusSprite); - _minusSprite->setPosition( Vector2(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) ); + _minusSprite->setPosition( Vec2(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) ); this->addChild(_minusSprite); this->setMinusLabel( Label::createWithSystemFont("-", ControlStepperLabelFont, 40)); _minusLabel->setColor(ControlStepperLabelColorDisabled); - _minusLabel->setAnchorPoint(Vector2::ANCHOR_MIDDLE); - _minusLabel->setPosition(Vector2(_minusSprite->getContentSize().width / 2, _minusSprite->getContentSize().height / 2) ); + _minusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); + _minusLabel->setPosition(Vec2(_minusSprite->getContentSize().width / 2, _minusSprite->getContentSize().height / 2) ); _minusSprite->addChild(_minusLabel); // Add the plus components this->setPlusSprite( plusSprite ); - _plusSprite->setPosition( Vector2(minusSprite->getContentSize().width + plusSprite->getContentSize().width / 2, + _plusSprite->setPosition( Vec2(minusSprite->getContentSize().width + plusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) ); this->addChild(_plusSprite); this->setPlusLabel( Label::createWithSystemFont("+", ControlStepperLabelFont, 40 )); _plusLabel->setColor( ControlStepperLabelColorEnabled ); - _plusLabel->setAnchorPoint(Vector2::ANCHOR_MIDDLE); - _plusLabel->setPosition( Vector2(_plusSprite->getContentSize().width / 2, _plusSprite->getContentSize().height / 2) ); + _plusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); + _plusLabel->setPosition( Vec2(_plusSprite->getContentSize().width / 2, _plusSprite->getContentSize().height / 2) ); _plusSprite->addChild(_plusLabel); // Defines the content size @@ -248,7 +248,7 @@ void ControlStepper::update(float dt) //// ControlStepper Private Methods -void ControlStepper::updateLayoutUsingTouchLocation(Vector2 location) +void ControlStepper::updateLayoutUsingTouchLocation(Vec2 location) { if (location.x < _minusSprite->getContentSize().width && _value > _minimumValue) @@ -281,7 +281,7 @@ bool ControlStepper::onTouchBegan(Touch *pTouch, Event *pEvent) return false; } - Vector2 location = this->getTouchLocation(pTouch); + Vec2 location = this->getTouchLocation(pTouch); this->updateLayoutUsingTouchLocation(location); _touchInsideFlag = true; @@ -298,7 +298,7 @@ void ControlStepper::onTouchMoved(Touch *pTouch, Event *pEvent) { if (this->isTouchInside(pTouch)) { - Vector2 location = this->getTouchLocation(pTouch); + Vec2 location = this->getTouchLocation(pTouch); this->updateLayoutUsingTouchLocation(location); if (!_touchInsideFlag) @@ -339,7 +339,7 @@ void ControlStepper::onTouchEnded(Touch *pTouch, Event *pEvent) if (this->isTouchInside(pTouch)) { - Vector2 location = this->getTouchLocation(pTouch); + Vec2 location = this->getTouchLocation(pTouch); this->setValue(_value + ((location.x < _minusSprite->getContentSize().width) ? (0.0-_stepValue) : _stepValue)); } diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.h b/extensions/GUI/CCControlExtension/CCControlStepper.h index 92b4009794..1b45a497f6 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.h +++ b/extensions/GUI/CCControlExtension/CCControlStepper.h @@ -81,7 +81,7 @@ public: void update(float dt); /** Update the layout of the stepper with the given touch location. */ - void updateLayoutUsingTouchLocation(Vector2 location); + void updateLayoutUsingTouchLocation(Vec2 location); /** Start the autorepeat increment/decrement. */ void startAutorepeat(); diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index a11a849541..d8b73a587e 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -218,26 +218,26 @@ void ControlSwitchSprite::updateTweenAction(float value, const std::string& key) void ControlSwitchSprite::needsLayout() { - _onSprite->setPosition(Vector2(_onSprite->getContentSize().width / 2 + _sliderXPosition, + _onSprite->setPosition(Vec2(_onSprite->getContentSize().width / 2 + _sliderXPosition, _onSprite->getContentSize().height / 2)); - _offSprite->setPosition(Vector2(_onSprite->getContentSize().width + _offSprite->getContentSize().width / 2 + _sliderXPosition, + _offSprite->setPosition(Vec2(_onSprite->getContentSize().width + _offSprite->getContentSize().width / 2 + _sliderXPosition, _offSprite->getContentSize().height / 2)); - _thumbSprite->setPosition(Vector2(_onSprite->getContentSize().width + _sliderXPosition, + _thumbSprite->setPosition(Vec2(_onSprite->getContentSize().width + _sliderXPosition, _maskTexture->getContentSize().height / 2)); - _clipperStencil->setPosition(Vector2(_maskTexture->getContentSize().width/2, + _clipperStencil->setPosition(Vec2(_maskTexture->getContentSize().width/2, _maskTexture->getContentSize().height / 2)); if (_onLabel) { - _onLabel->setAnchorPoint(Vector2::ANCHOR_MIDDLE); - _onLabel->setPosition(Vector2(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6, + _onLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); + _onLabel->setPosition(Vec2(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6, _onSprite->getContentSize().height / 2)); } if (_offLabel) { - _offLabel->setAnchorPoint(Vector2::ANCHOR_MIDDLE); - _offLabel->setPosition(Vector2(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6, + _offLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); + _offLabel->setPosition(Vec2(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6, _offSprite->getContentSize().height / 2)); } @@ -326,11 +326,11 @@ bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sp onLabel, offLabel); _switchSprite->retain(); - _switchSprite->setPosition(Vector2(_switchSprite->getContentSize().width / 2, _switchSprite->getContentSize().height / 2)); + _switchSprite->setPosition(Vec2(_switchSprite->getContentSize().width / 2, _switchSprite->getContentSize().height / 2)); addChild(_switchSprite); ignoreAnchorPointForPosition(false); - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); setContentSize(_switchSprite->getContentSize()); return true; } @@ -388,9 +388,9 @@ void ControlSwitch::setEnabled(bool enabled) } } -Vector2 ControlSwitch::locationFromTouch(Touch* pTouch) +Vec2 ControlSwitch::locationFromTouch(Touch* pTouch) { - Vector2 touchLocation = pTouch->getLocation(); // Get the touch position + Vec2 touchLocation = pTouch->getLocation(); // Get the touch position touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class return touchLocation; @@ -405,7 +405,7 @@ bool ControlSwitch::onTouchBegan(Touch *pTouch, Event *pEvent) _moved = false; - Vector2 location = this->locationFromTouch(pTouch); + Vec2 location = this->locationFromTouch(pTouch); _initialTouchXPosition = location.x - _switchSprite->getSliderXPosition(); @@ -417,8 +417,8 @@ bool ControlSwitch::onTouchBegan(Touch *pTouch, Event *pEvent) void ControlSwitch::onTouchMoved(Touch *pTouch, Event *pEvent) { - Vector2 location = this->locationFromTouch(pTouch); - location = Vector2(location.x - _initialTouchXPosition, 0); + Vec2 location = this->locationFromTouch(pTouch); + location = Vec2(location.x - _initialTouchXPosition, 0); _moved = true; @@ -427,7 +427,7 @@ void ControlSwitch::onTouchMoved(Touch *pTouch, Event *pEvent) void ControlSwitch::onTouchEnded(Touch *pTouch, Event *pEvent) { - Vector2 location = this->locationFromTouch(pTouch); + Vec2 location = this->locationFromTouch(pTouch); _switchSprite->getThumbSprite()->setColor(Color3B::WHITE); @@ -443,7 +443,7 @@ void ControlSwitch::onTouchEnded(Touch *pTouch, Event *pEvent) void ControlSwitch::onTouchCancelled(Touch *pTouch, Event *pEvent) { - Vector2 location = this->locationFromTouch(pTouch); + Vec2 location = this->locationFromTouch(pTouch); _switchSprite->getThumbSprite()->setColor(Color3B::WHITE); diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.h b/extensions/GUI/CCControlExtension/CCControlSwitch.h index 24d5d1bcef..6575937e13 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.h +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.h @@ -82,7 +82,7 @@ public: bool hasMoved() const { return _moved; } virtual void setEnabled(bool enabled); - Vector2 locationFromTouch(Touch* touch); + Vec2 locationFromTouch(Touch* touch); // Overrides virtual bool onTouchBegan(Touch *pTouch, Event *pEvent) override; diff --git a/extensions/GUI/CCControlExtension/CCControlUtils.cpp b/extensions/GUI/CCControlExtension/CCControlUtils.cpp index f3954f9677..414e43bd86 100644 --- a/extensions/GUI/CCControlExtension/CCControlUtils.cpp +++ b/extensions/GUI/CCControlExtension/CCControlUtils.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. NS_CC_EXT_BEGIN -Sprite* ControlUtils::addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vector2 pos, Vector2 anchor) +Sprite* ControlUtils::addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vec2 pos, Vec2 anchor) { Sprite *sprite =Sprite::createWithSpriteFrameName(spriteName); @@ -163,7 +163,7 @@ Rect ControlUtils::RectUnion(const Rect& src1, const Rect& src2) float x2 = MAX(src1.getMaxX(), src2.getMaxX()); float y2 = MAX(src1.getMaxY(), src2.getMaxY()); - result.origin=Vector2(x1,y1); + result.origin=Vec2(x1,y1); result.size=Size(x2-x1, y2-y1); return result; } diff --git a/extensions/GUI/CCControlExtension/CCControlUtils.h b/extensions/GUI/CCControlExtension/CCControlUtils.h index 078ed505b7..f927822f10 100644 --- a/extensions/GUI/CCControlExtension/CCControlUtils.h +++ b/extensions/GUI/CCControlExtension/CCControlUtils.h @@ -80,7 +80,7 @@ public: * @js NA * @lua NA */ - static Sprite* addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vector2 pos, Vector2 anchor); + static Sprite* addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vec2 pos, Vec2 anchor); /** * @js NA * @lua NA diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 32398db39b..8501d097a8 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -99,7 +99,7 @@ bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rec this->updateWithBatchNode(batchnode, rect, rotated, capInsets); } - this->setAnchorPoint(Vector2(0.5f, 0.5f)); + this->setAnchorPoint(Vec2(0.5f, 0.5f)); this->_positionsAreDirty = true; return true; @@ -428,34 +428,34 @@ void Scale9Sprite::updatePositions() float leftWidth = _bottomLeft->getContentSize().width; float bottomHeight = _bottomLeft->getContentSize().height; - _bottomLeft->setAnchorPoint(Vector2(0,0)); - _bottomRight->setAnchorPoint(Vector2(0,0)); - _topLeft->setAnchorPoint(Vector2(0,0)); - _topRight->setAnchorPoint(Vector2(0,0)); - _left->setAnchorPoint(Vector2(0,0)); - _right->setAnchorPoint(Vector2(0,0)); - _top->setAnchorPoint(Vector2(0,0)); - _bottom->setAnchorPoint(Vector2(0,0)); - _centre->setAnchorPoint(Vector2(0,0)); + _bottomLeft->setAnchorPoint(Vec2(0,0)); + _bottomRight->setAnchorPoint(Vec2(0,0)); + _topLeft->setAnchorPoint(Vec2(0,0)); + _topRight->setAnchorPoint(Vec2(0,0)); + _left->setAnchorPoint(Vec2(0,0)); + _right->setAnchorPoint(Vec2(0,0)); + _top->setAnchorPoint(Vec2(0,0)); + _bottom->setAnchorPoint(Vec2(0,0)); + _centre->setAnchorPoint(Vec2(0,0)); // Position corners - _bottomLeft->setPosition(Vector2(0,0)); - _bottomRight->setPosition(Vector2(leftWidth+rescaledWidth,0)); - _topLeft->setPosition(Vector2(0, bottomHeight+rescaledHeight)); - _topRight->setPosition(Vector2(leftWidth+rescaledWidth, bottomHeight+rescaledHeight)); + _bottomLeft->setPosition(Vec2(0,0)); + _bottomRight->setPosition(Vec2(leftWidth+rescaledWidth,0)); + _topLeft->setPosition(Vec2(0, bottomHeight+rescaledHeight)); + _topRight->setPosition(Vec2(leftWidth+rescaledWidth, bottomHeight+rescaledHeight)); // Scale and position borders - _left->setPosition(Vector2(0, bottomHeight)); + _left->setPosition(Vec2(0, bottomHeight)); _left->setScaleY(verticalScale); - _right->setPosition(Vector2(leftWidth+rescaledWidth,bottomHeight)); + _right->setPosition(Vec2(leftWidth+rescaledWidth,bottomHeight)); _right->setScaleY(verticalScale); - _bottom->setPosition(Vector2(leftWidth,0)); + _bottom->setPosition(Vec2(leftWidth,0)); _bottom->setScaleX(horizontalScale); - _top->setPosition(Vector2(leftWidth,bottomHeight+rescaledHeight)); + _top->setPosition(Vec2(leftWidth,bottomHeight+rescaledHeight)); _top->setScaleX(horizontalScale); // Position centre - _centre->setPosition(Vector2(leftWidth, bottomHeight)); + _centre->setPosition(Vec2(leftWidth, bottomHeight)); } bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect, const Rect& capInsets) @@ -764,7 +764,7 @@ void Scale9Sprite::setInsetBottom(float insetBottom) this->updateCapInset(); } -void Scale9Sprite::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { if(this->_positionsAreDirty) { diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index 9497d932ae..da66186462 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -261,7 +261,7 @@ public: * @js NA * @lua NA */ - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; virtual void setOpacityModifyRGB(bool bValue) override; virtual bool isOpacityModifyRGB(void) const override; virtual void setOpacity(GLubyte opacity) override; diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp index deb4f3ccd4..97b4b6c629 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -97,7 +97,7 @@ bool EditBox::initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pP this->setZoomOnTouchDown(false); this->setPreferredSize(size); - this->setPosition(Vector2(0, 0)); + this->setPosition(Vec2(0, 0)); this->addTargetWithActionForControlEvent(this, cccontrol_selector(EditBox::touchDownAction), Control::EventType::TOUCH_UP_INSIDE); return true; @@ -282,7 +282,7 @@ void EditBox::setReturnType(EditBox::KeyboardReturnType returnType) } /* override function */ -void EditBox::setPosition(const Vector2& pos) +void EditBox::setPosition(const Vec2& pos) { ControlButton::setPosition(pos); if (_editBoxImpl != NULL) @@ -309,7 +309,7 @@ void EditBox::setContentSize(const Size& size) } } -void EditBox::setAnchorPoint(const Vector2& anchorPoint) +void EditBox::setAnchorPoint(const Vec2& anchorPoint) { ControlButton::setAnchorPoint(anchorPoint); if (_editBoxImpl != NULL) @@ -318,7 +318,7 @@ void EditBox::setAnchorPoint(const Vector2& anchorPoint) } } -void EditBox::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { ControlButton::visit(renderer, parentTransform, parentTransformUpdated); if (_editBoxImpl != NULL) diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index 48bab4d589..d666528d18 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -371,15 +371,15 @@ public: void setReturnType(EditBox::KeyboardReturnType returnType); /* override functions */ - virtual void setPosition(const Vector2& pos) override; + virtual void setPosition(const Vec2& pos) override; virtual void setVisible(bool visible) override; virtual void setContentSize(const Size& size) override; - virtual void setAnchorPoint(const Vector2& anchorPoint) override; + virtual void setAnchorPoint(const Vec2& anchorPoint) override; /** * @js NA * @lua NA */ - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; /** * @js NA * @lua NA diff --git a/extensions/GUI/CCEditBox/CCEditBoxImpl.h b/extensions/GUI/CCEditBox/CCEditBoxImpl.h index b10c812778..44118c1c0b 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImpl.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImpl.h @@ -65,10 +65,10 @@ public: virtual void openKeyboard() = 0; virtual void closeKeyboard() = 0; - virtual void setPosition(const Vector2& pos) = 0; + virtual void setPosition(const Vec2& pos) = 0; virtual void setVisible(bool visible) = 0; virtual void setContentSize(const Size& size) = 0; - virtual void setAnchorPoint(const Vector2& anchorPoint) = 0; + virtual void setAnchorPoint(const Vec2& anchorPoint) = 0; /** * check the editbox's position, update it when needed diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp index 2931a51efc..e610819d17 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp @@ -71,16 +71,16 @@ bool EditBoxImplAndroid::initWithSize(const Size& size) _label = Label::create(); _label->setSystemFontSize(size.height-12); // align the text vertically center - _label->setAnchorPoint(Vector2(0, 0.5f)); - _label->setPosition(Vector2(CC_EDIT_BOX_PADDING, size.height / 2.0f)); + _label->setAnchorPoint(Vec2(0, 0.5f)); + _label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height / 2.0f)); _label->setColor(_colText); _editBox->addChild(_label); _labelPlaceHolder = Label::create(); _labelPlaceHolder->setSystemFontSize(size.height-12); // align the text vertically center - _labelPlaceHolder->setAnchorPoint(Vector2(0, 0.5f)); - _labelPlaceHolder->setPosition(Vector2(CC_EDIT_BOX_PADDING, size.height / 2.0f)); + _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); + _labelPlaceHolder->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height / 2.0f)); _labelPlaceHolder->setVisible(false); _labelPlaceHolder->setColor(_colPlaceHolder); _editBox->addChild(_labelPlaceHolder); @@ -215,7 +215,7 @@ void EditBoxImplAndroid::setPlaceHolder(const char* pText) } } -void EditBoxImplAndroid::setPosition(const Vector2& pos) +void EditBoxImplAndroid::setPosition(const Vec2& pos) { // don't need to be implemented on android platform. } @@ -230,7 +230,7 @@ void EditBoxImplAndroid::setContentSize(const Size& size) } -void EditBoxImplAndroid::setAnchorPoint(const Vector2& anchorPoint) +void EditBoxImplAndroid::setAnchorPoint(const Vec2& anchorPoint) { // don't need to be implemented on android platform. } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h index 908ac57fc6..8f4d6a1e95 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h @@ -65,10 +65,10 @@ public: virtual void setText(const char* pText); virtual const char* getText(void); virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vector2& pos); + virtual void setPosition(const Vec2& pos); virtual void setVisible(bool visible); virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vector2& anchorPoint); + virtual void setAnchorPoint(const Vec2& anchorPoint); /** * @js NA * @lua NA diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h index 575f32a3de..0e666ee6ed 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h @@ -97,10 +97,10 @@ public: virtual const char* getText(void); virtual void refreshInactiveText(); virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vector2& pos); + virtual void setPosition(const Vec2& pos); virtual void setVisible(bool visible); virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vector2& anchorPoint); + virtual void setAnchorPoint(const Vec2& anchorPoint); virtual void updatePosition(float dt) override; /** * @js NA @@ -126,8 +126,8 @@ private: Label* _label; Label* _labelPlaceHolder; Size _contentSize; - Vector2 _position; - Vector2 _anchorPoint; + Vec2 _position; + Vec2 _anchorPoint; CCEditBoxImplIOS_objc* _systemControl; int _maxTextLength; bool _inRetinaMode; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm index 49f7013396..edab22c826 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm @@ -270,7 +270,7 @@ EditBoxImplIOS::EditBoxImplIOS(EditBox* pEditText) : EditBoxImpl(pEditText) , _label(nullptr) , _labelPlaceHolder(nullptr) -, _anchorPoint(Vector2(0.5f, 0.5f)) +, _anchorPoint(Vec2(0.5f, 0.5f)) , _systemControl(nullptr) , _maxTextLength(-1) { @@ -323,14 +323,14 @@ void EditBoxImplIOS::initInactiveLabels(const Size& size) const char* pDefaultFontName = [[_systemControl.textField.font fontName] UTF8String]; _label = Label::create(); - _label->setAnchorPoint(Vector2(0, 0.5f)); + _label->setAnchorPoint(Vec2(0, 0.5f)); _label->setColor(Color3B::WHITE); _label->setVisible(false); _editBox->addChild(_label, kLabelZOrder); _labelPlaceHolder = Label::create(); // align the text vertically center - _labelPlaceHolder->setAnchorPoint(Vector2(0, 0.5f)); + _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); _labelPlaceHolder->setColor(Color3B::GRAY); _editBox->addChild(_labelPlaceHolder, kLabelZOrder); @@ -340,8 +340,8 @@ void EditBoxImplIOS::initInactiveLabels(const Size& size) void EditBoxImplIOS::placeInactiveLabels() { - _label->setPosition(Vector2(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f)); - _labelPlaceHolder->setPosition(Vector2(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f)); + _label->setPosition(Vec2(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f)); + _labelPlaceHolder->setPosition(Vec2(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f)); } void EditBoxImplIOS::setInactiveText(const char* pText) @@ -550,15 +550,15 @@ void EditBoxImplIOS::setPlaceHolder(const char* pText) _labelPlaceHolder->setString(pText); } -static CGPoint convertDesignCoordToScreenCoord(const Vector2& designCoord, bool bInRetinaMode) +static CGPoint convertDesignCoordToScreenCoord(const Vec2& designCoord, bool bInRetinaMode) { auto glview = cocos2d::Director::getInstance()->getOpenGLView(); CCEAGLView *eaglview = (CCEAGLView *) glview->getEAGLView(); float viewH = (float)[eaglview getHeight]; - Vector2 visiblePos = Vector2(designCoord.x * glview->getScaleX(), designCoord.y * glview->getScaleY()); - Vector2 screenGLPos = visiblePos + glview->getViewPortRect().origin; + Vec2 visiblePos = Vec2(designCoord.x * glview->getScaleX(), designCoord.y * glview->getScaleY()); + Vec2 screenGLPos = visiblePos + glview->getViewPortRect().origin; CGPoint screenPos = CGPointMake(screenGLPos.x, viewH - screenGLPos.y); @@ -571,7 +571,7 @@ static CGPoint convertDesignCoordToScreenCoord(const Vector2& designCoord, bool return screenPos; } -void EditBoxImplIOS::setPosition(const Vector2& pos) +void EditBoxImplIOS::setPosition(const Vec2& pos) { _position = pos; adjustTextFieldPosition(); @@ -598,7 +598,7 @@ void EditBoxImplIOS::setContentSize(const Size& size) [_systemControl setContentSize:controlSize]; } -void EditBoxImplIOS::setAnchorPoint(const Vector2& anchorPoint) +void EditBoxImplIOS::setAnchorPoint(const Vec2& anchorPoint) { CCLOG("[Edit text] anchor point = (%f, %f)", anchorPoint.x, anchorPoint.y); _anchorPoint = anchorPoint; @@ -633,7 +633,7 @@ void EditBoxImplIOS::adjustTextFieldPosition() Rect rect = Rect(0, 0, contentSize.width, contentSize.height); rect = RectApplyAffineTransform(rect, _editBox->nodeToWorldTransform()); - Vector2 designCoord = Vector2(rect.origin.x, rect.origin.y + rect.size.height); + Vec2 designCoord = Vec2(rect.origin.x, rect.origin.y + rect.size.height); [_systemControl setPosition:convertDesignCoordToScreenCoord(designCoord, _inRetinaMode)]; } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.h b/extensions/GUI/CCEditBox/CCEditBoxImplMac.h index 5578219bde..651e2927c6 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.h @@ -96,10 +96,10 @@ public: virtual void setText(const char* pText); virtual const char* getText(void); virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vector2& pos); + virtual void setPosition(const Vec2& pos); virtual void setVisible(bool visible); virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vector2& anchorPoint); + virtual void setAnchorPoint(const Vec2& anchorPoint); /** * @js NA * @lua NA @@ -115,11 +115,11 @@ public: */ virtual void onEnter(void); private: - NSPoint convertDesignCoordToScreenCoord(const Vector2& designCoord, bool bInRetinaMode); + NSPoint convertDesignCoordToScreenCoord(const Vec2& designCoord, bool bInRetinaMode); void adjustTextFieldPosition(); Size _contentSize; - Vector2 _position; - Vector2 _anchorPoint; + Vec2 _position; + Vec2 _anchorPoint; int _maxTextLength; bool _inRetinaMode; CCEditBoxImplMac* _sysEdit; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm index e9502ca908..dfc3b6d0d0 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm @@ -258,7 +258,7 @@ EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) EditBoxImplMac::EditBoxImplMac(EditBox* pEditText) : EditBoxImpl(pEditText) -, _anchorPoint(Vector2(0.5f, 0.5f)) +, _anchorPoint(Vec2(0.5f, 0.5f)) , _maxTextLength(-1) , _sysEdit(nullptr) { @@ -388,15 +388,15 @@ void EditBoxImplMac::setPlaceHolder(const char* pText) [as release]; } -NSPoint EditBoxImplMac::convertDesignCoordToScreenCoord(const Vector2& designCoord, bool bInRetinaMode) +NSPoint EditBoxImplMac::convertDesignCoordToScreenCoord(const Vec2& designCoord, bool bInRetinaMode) { NSRect frame = [_sysEdit.textField frame]; CGFloat height = frame.size.height; GLViewProtocol* eglView = Director::getInstance()->getOpenGLView(); - Vector2 visiblePos = Vector2(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY()); - Vector2 screenGLPos = visiblePos + eglView->getViewPortRect().origin; + Vec2 visiblePos = Vec2(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY()); + Vec2 screenGLPos = visiblePos + eglView->getViewPortRect().origin; //TODO: I don't know why here needs to substract `height`. NSPoint screenPos = NSMakePoint(screenGLPos.x, screenGLPos.y-height); @@ -425,11 +425,11 @@ void EditBoxImplMac::adjustTextFieldPosition() rect = RectApplyAffineTransform(rect, _editBox->nodeToWorldTransform()); - Vector2 designCoord = Vector2(rect.origin.x, rect.origin.y + rect.size.height); + Vec2 designCoord = Vec2(rect.origin.x, rect.origin.y + rect.size.height); [_sysEdit setPosition:convertDesignCoordToScreenCoord(designCoord, _inRetinaMode)]; } -void EditBoxImplMac::setPosition(const Vector2& pos) +void EditBoxImplMac::setPosition(const Vec2& pos) { _position = pos; adjustTextFieldPosition(); @@ -446,7 +446,7 @@ void EditBoxImplMac::setContentSize(const Size& size) CCLOG("[Edit text] content size = (%f, %f)", size.width, size.height); } -void EditBoxImplMac::setAnchorPoint(const Vector2& anchorPoint) +void EditBoxImplMac::setAnchorPoint(const Vec2& anchorPoint) { CCLOG("[Edit text] anchor point = (%f, %f)", anchorPoint.x, anchorPoint.y); _anchorPoint = anchorPoint; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index 1609c721cf..d98082746f 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -73,16 +73,16 @@ bool EditBoxImplWin::initWithSize(const Size& size) _label = Label::create(); _label->setSystemFontSize(size.height-12); // align the text vertically center - _label->setAnchorPoint(Vector2(0, 0.5f)); - _label->setPosition(Vector2(5, size.height / 2.0f)); + _label->setAnchorPoint(Vec2(0, 0.5f)); + _label->setPosition(Vec2(5, size.height / 2.0f)); _label->setColor(_colText); _editBox->addChild(_label); _labelPlaceHolder = Label::create(); _labelPlaceHolder->setSystemFontSize(size.height-12); // align the text vertically center - _labelPlaceHolder->setAnchorPoint(Vector2(0, 0.5f)); - _labelPlaceHolder->setPosition(Vector2(5, size.height / 2.0f)); + _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); + _labelPlaceHolder->setPosition(Vec2(5, size.height / 2.0f)); _labelPlaceHolder->setVisible(false); _labelPlaceHolder->setColor(_colPlaceHolder); _editBox->addChild(_labelPlaceHolder); @@ -211,7 +211,7 @@ void EditBoxImplWin::setPlaceHolder(const char* pText) } } -void EditBoxImplWin::setPosition(const Vector2& pos) +void EditBoxImplWin::setPosition(const Vec2& pos) { //_label->setPosition(pos); //_labelPlaceHolder->setPosition(pos); @@ -225,7 +225,7 @@ void EditBoxImplWin::setContentSize(const Size& size) { } -void EditBoxImplWin::setAnchorPoint(const Vector2& anchorPoint) +void EditBoxImplWin::setAnchorPoint(const Vec2& anchorPoint) { // don't need to be implemented on win32 platform. } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h b/extensions/GUI/CCEditBox/CCEditBoxImplWin.h index 7972364b58..7b29251644 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.h @@ -65,10 +65,10 @@ public: virtual void setText(const char* pText); virtual const char* getText(void); virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vector2& pos); + virtual void setPosition(const Vec2& pos); virtual void setVisible(bool visible); virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vector2& anchorPoint); + virtual void setAnchorPoint(const Vec2& anchorPoint); /** * @js NA * @lua NA diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp index 1b0c4f68e9..e43d85d746 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp @@ -97,15 +97,15 @@ bool CCEditBoxImplWp8::initWithSize( const Size& size ) //! int fontSize = getFontSizeAccordingHeightJni(size.height-12); m_pLabel = Label::createWithSystemFont("", "", size.height-12); // align the text vertically center - m_pLabel->setAnchorPoint(Vector2(0.0f, 0.5f)); - m_pLabel->setPosition(Vector2(5.0, size.height / 2.0f)); + m_pLabel->setAnchorPoint(Vec2(0.0f, 0.5f)); + m_pLabel->setPosition(Vec2(5.0, size.height / 2.0f)); m_pLabel->setColor(m_colText); _editBox->addChild(m_pLabel); m_pLabelPlaceHolder = Label::createWithSystemFont("", "", size.height-12); // align the text vertically center - m_pLabelPlaceHolder->setAnchorPoint(Vector2(0.0f, 0.5f)); - m_pLabelPlaceHolder->setPosition(Vector2(5.0f, size.height / 2.0f)); + m_pLabelPlaceHolder->setAnchorPoint(Vec2(0.0f, 0.5f)); + m_pLabelPlaceHolder->setPosition(Vec2(5.0f, size.height / 2.0f)); m_pLabelPlaceHolder->setVisible(false); m_pLabelPlaceHolder->setColor(m_colPlaceHolder); _editBox->addChild(m_pLabelPlaceHolder); @@ -234,7 +234,7 @@ void CCEditBoxImplWp8::setPlaceHolder( const char* pText ) } } -void CCEditBoxImplWp8::setPosition( const Vector2& pos ) +void CCEditBoxImplWp8::setPosition( const Vec2& pos ) { } @@ -249,7 +249,7 @@ void CCEditBoxImplWp8::setContentSize( const Size& size ) } -void CCEditBoxImplWp8::setAnchorPoint( const Vector2& anchorPoint ) +void CCEditBoxImplWp8::setAnchorPoint( const Vec2& anchorPoint ) { } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h index 20bb1d8df2..7f1cbb4947 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h @@ -52,10 +52,10 @@ public: virtual void setText(const char* pText); virtual const char* getText(void); virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vector2& pos); + virtual void setPosition(const Vec2& pos); virtual void setVisible(bool visible); virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vector2& anchorPoint); + virtual void setAnchorPoint(const Vec2& anchorPoint); virtual void visit(void); virtual void doAnimationWhenKeyboardMove(float duration, float distance); virtual void openKeyboard(); diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index f69031daa8..020b775a92 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -114,7 +114,7 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/) { _container = Layer::create(); _container->ignoreAnchorPointForPosition(false); - _container->setAnchorPoint(Vector2(0.0f, 0.0f)); + _container->setAnchorPoint(Vec2(0.0f, 0.0f)); } this->setViewSize(size); @@ -128,7 +128,7 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/) _clippingToBounds = true; //_container->setContentSize(Size::ZERO); _direction = Direction::BOTH; - _container->setPosition(Vector2(0.0f, 0.0f)); + _container->setPosition(Vec2(0.0f, 0.0f)); _touchLength = 0.0f; this->addChild(_container); @@ -147,7 +147,7 @@ bool ScrollView::init() bool ScrollView::isNodeVisible(Node* node) { - const Vector2 offset = this->getContentOffset(); + const Vec2 offset = this->getContentOffset(); const Size size = this->getViewSize(); const float scale = this->getZoomScale(); @@ -206,7 +206,7 @@ void ScrollView::setTouchEnabled(bool enabled) } } -void ScrollView::setContentOffset(Vector2 offset, bool animated/* = false*/) +void ScrollView::setContentOffset(Vec2 offset, bool animated/* = false*/) { if (animated) { //animate scrolling @@ -216,8 +216,8 @@ void ScrollView::setContentOffset(Vector2 offset, bool animated/* = false*/) { //set the container position directly if (!_bounceable) { - const Vector2 minOffset = this->minContainerOffset(); - const Vector2 maxOffset = this->maxContainerOffset(); + const Vec2 minOffset = this->minContainerOffset(); + const Vec2 maxOffset = this->maxContainerOffset(); offset.x = MAX(minOffset.x, MIN(maxOffset.x, offset.x)); offset.y = MAX(minOffset.y, MIN(maxOffset.y, offset.y)); @@ -232,7 +232,7 @@ void ScrollView::setContentOffset(Vector2 offset, bool animated/* = false*/) } } -void ScrollView::setContentOffsetInDuration(Vector2 offset, float dt) +void ScrollView::setContentOffsetInDuration(Vec2 offset, float dt) { FiniteTimeAction *scroll, *expire; @@ -242,7 +242,7 @@ void ScrollView::setContentOffsetInDuration(Vector2 offset, float dt) this->schedule(schedule_selector(ScrollView::performedAnimatedScroll)); } -Vector2 ScrollView::getContentOffset() +Vec2 ScrollView::getContentOffset() { return _container->getPosition(); } @@ -251,12 +251,12 @@ void ScrollView::setZoomScale(float s) { if (_container->getScale() != s) { - Vector2 oldCenter, newCenter; - Vector2 center; + Vec2 oldCenter, newCenter; + Vec2 center; if (_touchLength == 0.0f) { - center = Vector2(_viewSize.width*0.5f, _viewSize.height*0.5f); + center = Vec2(_viewSize.width*0.5f, _viewSize.height*0.5f); center = this->convertToWorldSpace(center); } else @@ -268,7 +268,7 @@ void ScrollView::setZoomScale(float s) _container->setScale(MAX(_minScale, MIN(_maxScale, s))); newCenter = _container->convertToWorldSpace(oldCenter); - const Vector2 offset = center - newCenter; + const Vec2 offset = center - newCenter; if (_delegate != NULL) { _delegate->scrollViewDidZoom(this); @@ -338,7 +338,7 @@ void ScrollView::setContainer(Node * pContainer) this->_container = pContainer; this->_container->ignoreAnchorPointForPosition(false); - this->_container->setAnchorPoint(Vector2(0.0f, 0.0f)); + this->_container->setAnchorPoint(Vec2(0.0f, 0.0f)); this->addChild(this->_container); @@ -347,7 +347,7 @@ void ScrollView::setContainer(Node * pContainer) void ScrollView::relocateContainer(bool animated) { - Vector2 oldPoint, min, max; + Vec2 oldPoint, min, max; float newX, newY; min = this->minContainerOffset(); @@ -371,18 +371,18 @@ void ScrollView::relocateContainer(bool animated) if (newY != oldPoint.y || newX != oldPoint.x) { - this->setContentOffset(Vector2(newX, newY), animated); + this->setContentOffset(Vec2(newX, newY), animated); } } -Vector2 ScrollView::maxContainerOffset() +Vec2 ScrollView::maxContainerOffset() { - return Vector2(0.0f, 0.0f); + return Vec2(0.0f, 0.0f); } -Vector2 ScrollView::minContainerOffset() +Vec2 ScrollView::minContainerOffset() { - return Vector2(_viewSize.width - _container->getContentSize().width*_container->getScaleX(), + return Vec2(_viewSize.width - _container->getContentSize().width*_container->getScaleX(), _viewSize.height - _container->getContentSize().height*_container->getScaleY()); } @@ -395,7 +395,7 @@ void ScrollView::deaccelerateScrolling(float dt) } float newX, newY; - Vector2 maxInset, minInset; + Vec2 maxInset, minInset; _container->setPosition(_container->getPosition() + _scrollDistance); @@ -414,7 +414,7 @@ void ScrollView::deaccelerateScrolling(float dt) newY = _container->getPosition().y; _scrollDistance = _scrollDistance * SCROLL_DEACCEL_RATE; - this->setContentOffset(Vector2(newX,newY)); + this->setContentOffset(Vec2(newX,newY)); if ((fabsf(_scrollDistance.x) <= SCROLL_DEACCEL_DIST && fabsf(_scrollDistance.y) <= SCROLL_DEACCEL_DIST) || @@ -470,10 +470,10 @@ void ScrollView::updateInset() if (this->getContainer() != NULL) { _maxInset = this->maxContainerOffset(); - _maxInset = Vector2(_maxInset.x + _viewSize.width * INSET_RATIO, + _maxInset = Vec2(_maxInset.x + _viewSize.width * INSET_RATIO, _maxInset.y + _viewSize.height * INSET_RATIO); _minInset = this->minContainerOffset(); - _minInset = Vector2(_minInset.x - _viewSize.width * INSET_RATIO, + _minInset = Vec2(_minInset.x - _viewSize.width * INSET_RATIO, _minInset.y - _viewSize.height * INSET_RATIO); } } @@ -553,7 +553,7 @@ void ScrollView::onAfterDraw() } } -void ScrollView::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) +void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) { // quick return if not visible if (!isVisible()) @@ -567,7 +567,7 @@ void ScrollView::visit(Renderer *renderer, const Matrix &parentTransform, bool p _transformUpdated = false; // IMPORTANT: - // To ease the migration to v3.0, we still support the Matrix stack, + // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -642,7 +642,7 @@ bool ScrollView::onTouchBegan(Touch* touch, Event* event) _touchPoint = this->convertTouchToNodeSpace(touch); _touchMoved = false; _dragging = true; //dragging started - _scrollDistance = Vector2(0.0f, 0.0f); + _scrollDistance = Vec2(0.0f, 0.0f); _touchLength = 0.0f; } else if (_touches.size() == 2) @@ -669,7 +669,7 @@ void ScrollView::onTouchMoved(Touch* touch, Event* event) { if (_touches.size() == 1 && _dragging) { // scrolling - Vector2 moveDistance, newPoint; + Vec2 moveDistance, newPoint; Rect frame; float newX, newY; @@ -718,7 +718,7 @@ void ScrollView::onTouchMoved(Touch* touch, Event* event) if (!_touchMoved) { - moveDistance = Vector2::ZERO; + moveDistance = Vec2::ZERO; } _touchPoint = newPoint; @@ -729,10 +729,10 @@ void ScrollView::onTouchMoved(Touch* touch, Event* event) switch (_direction) { case Direction::VERTICAL: - moveDistance = Vector2(0.0f, moveDistance.y); + moveDistance = Vec2(0.0f, moveDistance.y); break; case Direction::HORIZONTAL: - moveDistance = Vector2(moveDistance.x, 0.0f); + moveDistance = Vec2(moveDistance.x, 0.0f); break; default: break; @@ -742,7 +742,7 @@ void ScrollView::onTouchMoved(Touch* touch, Event* event) newY = _container->getPosition().y + moveDistance.y; _scrollDistance = moveDistance; - this->setContentOffset(Vector2(newX, newY)); + this->setContentOffset(Vec2(newX, newY)); } } else if (_touches.size() == 2 && !_dragging) @@ -798,7 +798,7 @@ void ScrollView::onTouchCancelled(Touch* touch, Event* event) Rect ScrollView::getViewRect() { - Vector2 screenPos = this->convertToWorldSpace(Vector2::ZERO); + Vec2 screenPos = this->convertToWorldSpace(Vec2::ZERO); float scaleX = this->getScaleX(); float scaleY = this->getScaleY(); diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index 8bd7a5b092..a232833ab0 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -116,8 +116,8 @@ public: * @param offset The new offset. * @param animated If true, the view will scroll to the new offset. */ - void setContentOffset(Vector2 offset, bool animated = false); - Vector2 getContentOffset(); + void setContentOffset(Vec2 offset, bool animated = false); + Vec2 getContentOffset(); /** * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView) * You can override the animation duration with this method. @@ -125,7 +125,7 @@ public: * @param offset The new offset. * @param dt The animation duration. */ - void setContentOffsetInDuration(Vector2 offset, float dt); + void setContentOffsetInDuration(Vec2 offset, float dt); void setZoomScale(float s); /** @@ -148,11 +148,11 @@ public: /** * Returns the current container's minimum offset. You may want this while you animate scrolling by yourself */ - Vector2 minContainerOffset(); + Vec2 minContainerOffset(); /** * Returns the current container's maximum offset. You may want this while you animate scrolling by yourself */ - Vector2 maxContainerOffset(); + Vec2 maxContainerOffset(); /** * Determines if a given node's bounding box is in visible bounds * @@ -225,7 +225,7 @@ public: * @js NA * @lua NA */ - virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; @@ -300,7 +300,7 @@ protected: /** * Content offset. Note that left-bottom point is the origin */ - Vector2 _contentOffset; + Vec2 _contentOffset; /** * Container holds scroll view contents, Sets the scrollable container object of the scroll view @@ -313,11 +313,11 @@ protected: /** * max inset point to limit scrolling by touch */ - Vector2 _maxInset; + Vec2 _maxInset; /** * min inset point to limit scrolling by touch */ - Vector2 _minInset; + Vec2 _minInset; /** * Determines whether the scroll view is allowed to bounce or not. */ @@ -328,11 +328,11 @@ protected: /** * scroll speed */ - Vector2 _scrollDistance; + Vec2 _scrollDistance; /** * Touch point */ - Vector2 _touchPoint; + Vec2 _touchPoint; /** * length between two fingers */ diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 86861e276d..3ba3c9c216 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -289,20 +289,20 @@ void TableView::_updateContentSize() { if (_direction == Direction::HORIZONTAL) { - this->setContentOffset(Vector2(0,0)); + this->setContentOffset(Vec2(0,0)); } else { - this->setContentOffset(Vector2(0,this->minContainerOffset().y)); + this->setContentOffset(Vec2(0,this->minContainerOffset().y)); } _oldDirection = _direction; } } -Vector2 TableView::_offsetFromIndex(ssize_t index) +Vec2 TableView::_offsetFromIndex(ssize_t index) { - Vector2 offset = this->__offsetFromIndex(index); + Vec2 offset = this->__offsetFromIndex(index); const Size cellSize = _dataSource->tableCellSizeForIndex(this, index); if (_vordering == VerticalFillOrder::TOP_DOWN) @@ -312,25 +312,25 @@ Vector2 TableView::_offsetFromIndex(ssize_t index) return offset; } -Vector2 TableView::__offsetFromIndex(ssize_t index) +Vec2 TableView::__offsetFromIndex(ssize_t index) { - Vector2 offset; + Vec2 offset; Size cellSize; switch (this->getDirection()) { case Direction::HORIZONTAL: - offset = Vector2(_vCellsPositions[index], 0.0f); + offset = Vec2(_vCellsPositions[index], 0.0f); break; default: - offset = Vector2(0.0f, _vCellsPositions[index]); + offset = Vec2(0.0f, _vCellsPositions[index]); break; } return offset; } -long TableView::_indexFromOffset(Vector2 offset) +long TableView::_indexFromOffset(Vec2 offset) { long index = 0; const long maxIdx = _dataSource->numberOfCellsInTableView(this) - 1; @@ -352,7 +352,7 @@ long TableView::_indexFromOffset(Vector2 offset) return index; } -long TableView::__indexFromOffset(Vector2 offset) +long TableView::__indexFromOffset(Vec2 offset) { long low = 0; long high = _dataSource->numberOfCellsInTableView(this) - 1; @@ -415,7 +415,7 @@ void TableView::_moveCellOutOfSight(TableViewCell *cell) void TableView::_setIndexForCell(ssize_t index, TableViewCell *cell) { - cell->setAnchorPoint(Vector2(0.0f, 0.0f)); + cell->setAnchorPoint(Vec2(0.0f, 0.0f)); cell->setPosition(this->_offsetFromIndex(index)); cell->setIdx(index); } @@ -469,7 +469,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) } ssize_t startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0; - Vector2 offset = this->getContentOffset() * -1; + Vec2 offset = this->getContentOffset() * -1; maxIdx = MAX(countOfItems-1, 0); if (_vordering == VerticalFillOrder::TOP_DOWN) @@ -601,7 +601,7 @@ bool TableView::onTouchBegan(Touch *pTouch, Event *pEvent) if(_touches.size() == 1) { long index; - Vector2 point; + Vec2 point; point = this->getContainer()->convertTouchToNodeSpace(pTouch); diff --git a/extensions/GUI/CCScrollView/CCTableView.h b/extensions/GUI/CCScrollView/CCTableView.h index 304948bdac..c4d89b33a9 100644 --- a/extensions/GUI/CCScrollView/CCTableView.h +++ b/extensions/GUI/CCScrollView/CCTableView.h @@ -273,10 +273,10 @@ public: virtual void onTouchCancelled(Touch *pTouch, Event *pEvent) override; protected: - long __indexFromOffset(Vector2 offset); - long _indexFromOffset(Vector2 offset); - Vector2 __offsetFromIndex(ssize_t index); - Vector2 _offsetFromIndex(ssize_t index); + long __indexFromOffset(Vec2 offset); + long _indexFromOffset(Vec2 offset); + Vec2 __offsetFromIndex(ssize_t index); + Vec2 _offsetFromIndex(ssize_t index); void _moveCellOutOfSight(TableViewCell *cell); void _setIndexForCell(ssize_t index, TableViewCell *cell); diff --git a/extensions/physics-nodes/CCPhysicsDebugNode.cpp b/extensions/physics-nodes/CCPhysicsDebugNode.cpp index e5da44c451..672895e9ef 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNode.cpp +++ b/extensions/physics-nodes/CCPhysicsDebugNode.cpp @@ -63,15 +63,15 @@ static Color4F ColorForBody(cpBody *body) } } -static Vector2 cpVert2Point(const cpVect &vert) +static Vec2 cpVert2Point(const cpVect &vert) { - return Vector2(vert.x, vert.y); + return Vec2(vert.x, vert.y); } -static Vector2* cpVertArray2ccpArrayN(const cpVect* cpVertArray, unsigned int count) +static Vec2* cpVertArray2ccpArrayN(const cpVect* cpVertArray, unsigned int count) { if (count == 0) return NULL; - Vector2* pPoints = new Vector2[count]; + Vec2* pPoints = new Vec2[count]; for (unsigned int i = 0; i < count; ++i) { @@ -108,7 +108,7 @@ static void DrawShape(cpShape *shape, DrawNode *renderer) cpPolyShape *poly = (cpPolyShape *)shape; Color4F line = color; line.a = cpflerp(color.a, 1.0, 0.5); - Vector2* pPoints = cpVertArray2ccpArrayN(poly->tVerts, poly->numVerts); + Vec2* pPoints = cpVertArray2ccpArrayN(poly->tVerts, poly->numVerts); renderer->drawPolygon(pPoints, poly->numVerts, color, 1.0, line); CC_SAFE_DELETE_ARRAY(pPoints); } @@ -182,7 +182,7 @@ static void DrawConstraint(cpConstraint *constraint, DrawNode *renderer) // implementation of PhysicsDebugNode -void PhysicsDebugNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if (! _spacePtr) { diff --git a/extensions/physics-nodes/CCPhysicsDebugNode.h b/extensions/physics-nodes/CCPhysicsDebugNode.h index 8981cd8ff9..300e796c50 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNode.h +++ b/extensions/physics-nodes/CCPhysicsDebugNode.h @@ -61,7 +61,7 @@ public: void setSpace(cpSpace *space); // Overrides - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: cpSpace *_spacePtr; diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index ac57b234a3..4ee1644382 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -165,7 +165,7 @@ void PhysicsSprite::setIgnoreBodyRotation(bool bIgnoreBodyRotation) } // Override the setters and getters to always reflect the body's properties. -const Vector2& PhysicsSprite::getPosition() const +const Vec2& PhysicsSprite::getPosition() const { return getPosFromPhysics(); } @@ -175,7 +175,7 @@ void PhysicsSprite::getPosition(float* x, float* y) const if (x == NULL || y == NULL) { return; } - const Vector2& pos = getPosFromPhysics(); + const Vec2& pos = getPosFromPhysics(); *x = pos.x; *y = pos.y; } @@ -257,25 +257,25 @@ void PhysicsSprite::setPTMRatio(float fRatio) // Common to Box2d and Chipmunk // -const Vector2& PhysicsSprite::getPosFromPhysics() const +const Vec2& PhysicsSprite::getPosFromPhysics() const { - static Vector2 s_physicPosion; + static Vec2 s_physicPosion; #if CC_ENABLE_CHIPMUNK_INTEGRATION cpVect cpPos = cpBodyGetPos(_CPBody); - s_physicPosion = Vector2(cpPos.x, cpPos.y); + s_physicPosion = Vec2(cpPos.x, cpPos.y); #elif CC_ENABLE_BOX2D_INTEGRATION b2Vec2 pos = _pB2Body->GetPosition(); float x = pos.x * _PTMRatio; float y = pos.y * _PTMRatio; - s_physicPosion = Vector2(x,y); + s_physicPosion = Vec2(x,y); #endif return s_physicPosion; } -void PhysicsSprite::setPosition(const Vector2 &pos) +void PhysicsSprite::setPosition(const Vec2 &pos) { #if CC_ENABLE_CHIPMUNK_INTEGRATION @@ -372,7 +372,7 @@ void PhysicsSprite::syncPhysicsTransform() const float c = cosf(radians); float s = sinf(radians); - if (!_anchorPointInPoints.equals(Vector2::ZERO)) + if (!_anchorPointInPoints.equals(Vec2::ZERO)) { x += ((c * -_anchorPointInPoints.x * _scaleX) + (-s * -_anchorPointInPoints.y * _scaleY)); y += ((s * -_anchorPointInPoints.x * _scaleX) + (c * -_anchorPointInPoints.y * _scaleY)); @@ -390,14 +390,14 @@ void PhysicsSprite::syncPhysicsTransform() const } // returns the transform matrix according the Chipmunk Body values -const Matrix& PhysicsSprite::getNodeToParentTransform() const +const Mat4& PhysicsSprite::getNodeToParentTransform() const { syncPhysicsTransform(); return _transform; } -void PhysicsSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if (isDirty()) { diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index ed817473a4..3f87247deb 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -106,20 +106,20 @@ public: void setPTMRatio(float fPTMRatio); // overrides - virtual const Vector2& getPosition() const override; + virtual const Vec2& getPosition() const override; virtual void getPosition(float* x, float* y) const override; virtual float getPositionX() const override; virtual float getPositionY() const override; - virtual void setPosition(const Vector2 &position) override; + virtual void setPosition(const Vec2 &position) override; virtual float getRotation() const override; virtual void setRotation(float fRotation) override; virtual void syncPhysicsTransform() const; - virtual const Matrix& getNodeToParentTransform() const override; + virtual const Mat4& getNodeToParentTransform() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: - const Vector2& getPosFromPhysics() const; + const Vec2& getPosFromPhysics() const; protected: bool _ignoreBodyRotation; diff --git a/tests/cpp-empty-test/Classes/HelloWorldScene.cpp b/tests/cpp-empty-test/Classes/HelloWorldScene.cpp index 6e4154a626..2750a78bed 100644 --- a/tests/cpp-empty-test/Classes/HelloWorldScene.cpp +++ b/tests/cpp-empty-test/Classes/HelloWorldScene.cpp @@ -42,11 +42,11 @@ bool HelloWorld::init() "CloseSelected.png", CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); - closeItem->setPosition(origin + Vector2(visibleSize) - Vector2(closeItem->getContentSize() / 2)); + closeItem->setPosition(origin + Vec2(visibleSize) - Vec2(closeItem->getContentSize() / 2)); // create menu, it's an autorelease object auto menu = Menu::create(closeItem, NULL); - menu->setPosition(Vector2::ZERO); + menu->setPosition(Vec2::ZERO); this->addChild(menu, 1); ///////////////////////////// @@ -58,7 +58,7 @@ bool HelloWorld::init() auto label = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE); // position the label on the center of the screen - label->setPosition(Vector2(origin.x + visibleSize.width/2, + label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height)); // add the label as a child to this layer @@ -68,7 +68,7 @@ bool HelloWorld::init() auto sprite = Sprite::create("HelloWorld.png"); // position the sprite on the center of the screen - sprite->setPosition(Vector2(visibleSize / 2) + origin); + sprite->setPosition(Vec2(visibleSize / 2) + origin); // add the sprite as a child to this layer this->addChild(sprite); diff --git a/tests/cpp-tests/Classes/AccelerometerTest/AccelerometerTest.cpp b/tests/cpp-tests/Classes/AccelerometerTest/AccelerometerTest.cpp index cd0f1f88d6..b352c5df50 100644 --- a/tests/cpp-tests/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/tests/cpp-tests/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -39,10 +39,10 @@ void AccelerometerTest::onEnter() auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32.0f); addChild(label, 1); - label->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y-50) ); + label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y-50) ); _ball = Sprite::create("Images/ball.png"); - _ball->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y)); + _ball->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y)); addChild(_ball); _ball->retain(); diff --git a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp index ac6a6f55ba..0ae621cd24 100644 --- a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -166,7 +166,7 @@ void LogicTest::onEnter() grossini->setPosition(VisibleRect::center()); grossini->runAction( Sequence::create( - MoveBy::create(1, Vector2(150,0)), + MoveBy::create(1, Vec2(150,0)), CallFuncN::create(CC_CALLBACK_1(LogicTest::bugMe,this)), NULL) ); @@ -200,7 +200,7 @@ void PauseTest::onEnter() auto l = Label::createWithTTF("After 5 seconds grossini should move", "fonts/Thonburi.ttf", 16.0f); addChild(l); - l->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y-75) ); + l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y-75) ); // @@ -210,7 +210,7 @@ void PauseTest::onEnter() addChild(grossini, 0, kTagGrossini); grossini->setPosition(VisibleRect::center() ); - auto action = MoveBy::create(1, Vector2(150,0)); + auto action = MoveBy::create(1, Vec2(150,0)); auto director = Director::getInstance(); director->getActionManager()->addAction(action, grossini, true); @@ -242,9 +242,9 @@ void StopActionTest::onEnter() auto l = Label::createWithTTF("Should not crash", "fonts/Thonburi.ttf", 16.0f); addChild(l); - l->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 75) ); + l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 75) ); - auto pMove = MoveBy::create(2, Vector2(200, 0)); + auto pMove = MoveBy::create(2, Vec2(200, 0)); auto pCallback = CallFunc::create(CC_CALLBACK_0(StopActionTest::stopAction,this)); auto pSequence = Sequence::create(pMove, pCallback, NULL); pSequence->setTag(kTagSequence); @@ -283,7 +283,7 @@ void ResumeTest::onEnter() auto l = Label::createWithTTF("Grossini only rotate/scale in 3 seconds", "fonts/Thonburi.ttf", 16.0f); addChild(l); - l->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 75)); + l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 75)); auto pGrossini = Sprite::create(s_pathGrossini); addChild(pGrossini, 0, kTagGrossini); diff --git a/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp index c689ed692e..7b58bfc1c9 100644 --- a/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -55,19 +55,19 @@ void EaseSpriteDemo::centerSprites(unsigned int numberOfSprites) { _tamara->setVisible(false); _kathia->setVisible(false); - _grossini->setPosition(Vector2(s.width/2, s.height/2)); + _grossini->setPosition(Vec2(s.width/2, s.height/2)); } else if( numberOfSprites == 2 ) { - _kathia->setPosition( Vector2(s.width/3, s.height/2)); - _tamara->setPosition( Vector2(2*s.width/3, s.height/2)); + _kathia->setPosition( Vec2(s.width/3, s.height/2)); + _tamara->setPosition( Vec2(2*s.width/3, s.height/2)); _grossini->setVisible(false); } else if( numberOfSprites == 3 ) { - _grossini->setPosition( Vector2(s.width/2, s.height/2)); - _tamara->setPosition( Vector2(s.width/4, s.height/2)); - _kathia->setPosition( Vector2(3 * s.width/4, s.height/2)); + _grossini->setPosition( Vec2(s.width/2, s.height/2)); + _tamara->setPosition( Vec2(s.width/4, s.height/2)); + _kathia->setPosition( Vec2(3 * s.width/4, s.height/2)); } } @@ -82,7 +82,7 @@ void SpriteEase::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); auto move_back = move->reverse(); auto move_ease_in = EaseIn::create(move->clone(), 2.5f); @@ -135,7 +135,7 @@ void SpriteEaseInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); // id move_back = move->reverse(); auto move_ease_inout1 = EaseInOut::create(move->clone(), 0.65f); @@ -174,7 +174,7 @@ void SpriteEaseExponential::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); auto move_back = move->reverse(); auto move_ease_in = EaseExponentialIn::create(move->clone()); @@ -210,7 +210,7 @@ void SpriteEaseExponentialInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseExponentialInOut::create(move->clone() ); @@ -243,7 +243,7 @@ void SpriteEaseSine::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseSineIn::create(move->clone() ); @@ -280,7 +280,7 @@ void SpriteEaseSineInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); auto move_back = move->reverse(); auto move_ease = EaseSineInOut::create(move->clone() ); @@ -312,7 +312,7 @@ void SpriteEaseElastic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseElasticIn::create(move->clone() ); @@ -348,7 +348,7 @@ void SpriteEaseElasticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_ease_inout1 = EaseElasticInOut::create(move->clone(), 0.3f); auto move_ease_inout_back1 = move_ease_inout1->reverse(); @@ -387,7 +387,7 @@ void SpriteEaseBounce::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseBounceIn::create(move->clone() ); @@ -424,7 +424,7 @@ void SpriteEaseBounceInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseBounceInOut::create(move->clone() ); @@ -457,7 +457,7 @@ void SpriteEaseBack::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseBackIn::create(move->clone()); @@ -493,7 +493,7 @@ void SpriteEaseBackInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseBackInOut::create(move->clone() ); @@ -537,9 +537,9 @@ void SpriteEaseBezier::onEnter() // sprite 1 ccBezierConfig bezier; - bezier.controlPoint_1 = Vector2(0, s.height/2); - bezier.controlPoint_2 = Vector2(300, -s.height/2); - bezier.endPosition = Vector2(300,100); + bezier.controlPoint_1 = Vec2(0, s.height/2); + bezier.controlPoint_2 = Vec2(300, -s.height/2); + bezier.endPosition = Vec2(300,100); auto bezierForward = BezierBy::create(3, bezier); auto bezierEaseForward = EaseBezierAction::create(bezierForward); @@ -550,18 +550,18 @@ void SpriteEaseBezier::onEnter() // sprite 2 - _tamara->setPosition(Vector2(80,160)); + _tamara->setPosition(Vec2(80,160)); ccBezierConfig bezier2; - bezier2.controlPoint_1 = Vector2(100, s.height/2); - bezier2.controlPoint_2 = Vector2(200, -s.height/2); - bezier2.endPosition = Vector2(240,160); + bezier2.controlPoint_1 = Vec2(100, s.height/2); + bezier2.controlPoint_2 = Vec2(200, -s.height/2); + bezier2.endPosition = Vec2(240,160); auto bezierTo1 = BezierTo::create(2, bezier2); auto bezierEaseTo1 = EaseBezierAction::create(bezierTo1); bezierEaseTo1->setBezierParamer(0.5, 0.5, 1.0, 1.0); // sprite 3 - _kathia->setPosition(Vector2(400,160)); + _kathia->setPosition(Vec2(400,160)); auto bezierTo2 = BezierTo::create(2, bezier2); auto bezierEaseTo2 = EaseBezierAction::create(bezierTo2); bezierEaseTo2->setBezierParamer(0.0, 0.5, -5.0, 1.0); @@ -588,7 +588,7 @@ void SpriteEaseQuadratic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseQuadraticActionIn::create(move->clone() ); @@ -623,7 +623,7 @@ void SpriteEaseQuadraticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseQuadraticActionInOut::create(move->clone() ); @@ -656,7 +656,7 @@ void SpriteEaseQuartic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseQuarticActionIn::create(move->clone() ); @@ -691,7 +691,7 @@ void SpriteEaseQuarticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseQuarticActionInOut::create(move->clone() ); @@ -723,7 +723,7 @@ void SpriteEaseQuintic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseQuinticActionIn::create(move->clone() ); @@ -759,7 +759,7 @@ void SpriteEaseQuinticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseQuinticActionInOut::create(move->clone() ); @@ -791,7 +791,7 @@ void SpriteEaseCircle::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseCircleActionIn::create(move->clone() ); @@ -827,7 +827,7 @@ void SpriteEaseCircleInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseCircleActionInOut::create(move->clone() ); @@ -859,7 +859,7 @@ void SpriteEaseCubic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease_in = EaseCubicActionIn::create(move->clone() ); @@ -895,7 +895,7 @@ void SpriteEaseCubicInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vector2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); auto move_back = move->reverse(); auto move_ease = EaseCubicActionInOut::create(move->clone() ); @@ -929,7 +929,7 @@ void SpeedTest::onEnter() auto s = Director::getInstance()->getWinSize(); // rotate and jump - auto jump1 = JumpBy::create(4, Vector2(-s.width+80, 0), 100, 4); + auto jump1 = JumpBy::create(4, Vec2(-s.width+80, 0), 100, 4); auto jump2 = jump1->reverse(); auto rot1 = RotateBy::create(4, 360*2); auto rot2 = rot1->reverse(); @@ -1066,8 +1066,8 @@ EaseSpriteDemo::~EaseSpriteDemo(void) void EaseSpriteDemo::positionForTwo() { - _grossini->setPosition(Vector2(VisibleRect::left().x+60, VisibleRect::bottom().y + VisibleRect::getVisibleRect().size.height*1/5)); - _tamara->setPosition(Vector2( VisibleRect::left().x+60, VisibleRect::bottom().y + VisibleRect::getVisibleRect().size.height*4/5)); + _grossini->setPosition(Vec2(VisibleRect::left().x+60, VisibleRect::bottom().y + VisibleRect::getVisibleRect().size.height*1/5)); + _tamara->setPosition(Vec2( VisibleRect::left().x+60, VisibleRect::bottom().y + VisibleRect::getVisibleRect().size.height*4/5)); _kathia->setVisible(false); } @@ -1090,9 +1090,9 @@ void EaseSpriteDemo::onEnter() addChild( _kathia, 2); addChild( _tamara, 1); - _grossini->setPosition(Vector2(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5)); - _kathia->setPosition(Vector2(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5)); - _tamara->setPosition(Vector2(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5)); + _grossini->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5)); + _kathia->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5)); + _tamara->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5)); } void EaseSpriteDemo::restartCallback(Ref* sender) diff --git a/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp b/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp index 750f886b38..763b7ea587 100644 --- a/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -163,7 +163,7 @@ void SpriteProgressToRadial::onEnter() auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType( ProgressTimer::Type::RADIAL ); addChild(left); - left->setPosition(Vector2(100, s.height/2)); + left->setPosition(Vec2(100, s.height/2)); left->runAction( RepeatForever::create(to1)); auto right = ProgressTimer::create(Sprite::create(s_pathBlock)); @@ -171,7 +171,7 @@ void SpriteProgressToRadial::onEnter() // Makes the ridial CCW right->setReverseProgress(true); addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction( RepeatForever::create(to2)); } @@ -198,21 +198,21 @@ void SpriteProgressToHorizontal::onEnter() auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 0 for the x - left->setMidpoint(Vector2(0,0)); + left->setMidpoint(Vec2(0,0)); // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left->setBarChangeRate(Vector2(1, 0)); + left->setBarChangeRate(Vec2(1, 0)); addChild(left); - left->setPosition(Vector2(100, s.height/2)); + left->setPosition(Vec2(100, s.height/2)); left->runAction( RepeatForever::create(to1)); auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 1 for the x - right->setMidpoint(Vector2(1, 0)); + right->setMidpoint(Vec2(1, 0)); // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right->setBarChangeRate(Vector2(1, 0)); + right->setBarChangeRate(Vec2(1, 0)); addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction( RepeatForever::create(to2)); } @@ -239,21 +239,21 @@ void SpriteProgressToVertical::onEnter() left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidpoint(Vector2(0,0)); + left->setMidpoint(Vec2(0,0)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vector2(0, 1)); + left->setBarChangeRate(Vec2(0, 1)); addChild(left); - left->setPosition(Vector2(100, s.height/2)); + left->setPosition(Vec2(100, s.height/2)); left->runAction( RepeatForever::create(to1)); auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidpoint(Vector2(0, 1)); + right->setMidpoint(Vec2(0, 1)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Vector2(0, 1)); + right->setBarChangeRate(Vec2(0, 1)); addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction( RepeatForever::create(to2)); } @@ -281,8 +281,8 @@ void SpriteProgressToRadialMidpointChanged::onEnter() auto left = ProgressTimer::create(Sprite::create(s_pathBlock)); left->setType(ProgressTimer::Type::RADIAL); addChild(left); - left->setMidpoint(Vector2(0.25f, 0.75f)); - left->setPosition(Vector2(100, s.height/2)); + left->setMidpoint(Vec2(0.25f, 0.75f)); + left->setPosition(Vec2(100, s.height/2)); left->runAction(RepeatForever::create(action->clone())); /** @@ -290,14 +290,14 @@ void SpriteProgressToRadialMidpointChanged::onEnter() */ auto right = ProgressTimer::create(Sprite::create(s_pathBlock)); right->setType(ProgressTimer::Type::RADIAL); - right->setMidpoint(Vector2(0.75f, 0.25f)); + right->setMidpoint(Vec2(0.75f, 0.25f)); /** * Note the reverse property (default=NO) is only added to the right image. That's how * we get a counter clockwise progress. */ addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction(RepeatForever::create(action->clone())); } @@ -323,31 +323,31 @@ void SpriteProgressBarVarious::onEnter() left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidpoint(Vector2(0.5f, 0.5f)); + left->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vector2(1, 0)); + left->setBarChangeRate(Vec2(1, 0)); addChild(left); - left->setPosition(Vector2(100, s.height/2)); + left->setPosition(Vec2(100, s.height/2)); left->runAction(RepeatForever::create(to->clone())); auto middle = ProgressTimer::create(Sprite::create(s_pathSister2)); middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle->setMidpoint(Vector2(0.5f, 0.5f)); + middle->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle->setBarChangeRate(Vector2(1,1)); + middle->setBarChangeRate(Vec2(1,1)); addChild(middle); - middle->setPosition(Vector2(s.width/2, s.height/2)); + middle->setPosition(Vec2(s.width/2, s.height/2)); middle->runAction(RepeatForever::create(to->clone())); auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidpoint(Vector2(0.5f, 0.5f)); + right->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Vector2(0, 1)); + right->setBarChangeRate(Vec2(0, 1)); addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction(RepeatForever::create(to->clone())); } @@ -380,11 +380,11 @@ void SpriteProgressBarTintAndFade::onEnter() left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidpoint(Vector2(0.5f, 0.5f)); + left->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vector2(1, 0)); + left->setBarChangeRate(Vec2(1, 0)); addChild(left); - left->setPosition(Vector2(100, s.height/2)); + left->setPosition(Vec2(100, s.height/2)); left->runAction(RepeatForever::create(to->clone())); left->runAction(RepeatForever::create(tint->clone())); @@ -393,11 +393,11 @@ void SpriteProgressBarTintAndFade::onEnter() auto middle = ProgressTimer::create(Sprite::create(s_pathSister2)); middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle->setMidpoint(Vector2(0.5f, 0.5f)); + middle->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle->setBarChangeRate(Vector2(1, 1)); + middle->setBarChangeRate(Vec2(1, 1)); addChild(middle); - middle->setPosition(Vector2(s.width/2, s.height/2)); + middle->setPosition(Vec2(s.width/2, s.height/2)); middle->runAction(RepeatForever::create(to->clone())); middle->runAction(RepeatForever::create(fade->clone())); @@ -406,11 +406,11 @@ void SpriteProgressBarTintAndFade::onEnter() auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidpoint(Vector2(0.5f, 0.5f)); + right->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Vector2(0, 1)); + right->setBarChangeRate(Vec2(0, 1)); addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction(RepeatForever::create(to->clone())); right->runAction(RepeatForever::create(tint->clone())); right->runAction(RepeatForever::create(fade->clone())); @@ -441,31 +441,31 @@ void SpriteProgressWithSpriteFrame::onEnter() auto left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png")); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidpoint(Vector2(0.5f, 0.5f)); + left->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vector2(1, 0)); + left->setBarChangeRate(Vec2(1, 0)); addChild(left); - left->setPosition(Vector2(100, s.height/2)); + left->setPosition(Vec2(100, s.height/2)); left->runAction(RepeatForever::create(to->clone())); auto middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png")); middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle->setMidpoint(Vector2(0.5f, 0.5f)); + middle->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle->setBarChangeRate(Vector2(1, 1)); + middle->setBarChangeRate(Vec2(1, 1)); addChild(middle); - middle->setPosition(Vector2(s.width/2, s.height/2)); + middle->setPosition(Vec2(s.width/2, s.height/2)); middle->runAction(RepeatForever::create(to->clone())); auto right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png")); right->setType(ProgressTimer::Type::RADIAL); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidpoint(Vector2(0.5f, 0.5f)); + right->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Vector2(0, 1)); + right->setBarChangeRate(Vec2(0, 1)); addChild(right); - right->setPosition(Vector2(s.width-100, s.height/2)); + right->setPosition(Vec2(s.width-100, s.height/2)); right->runAction(RepeatForever::create(to->clone())); } diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp index ad0cd4c39a..952404bddb 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp @@ -150,9 +150,9 @@ void ActionsDemo::onEnter() addChild(_tamara, 2); addChild(_kathia, 3); - _grossini->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3)); - _tamara->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3)); - _kathia->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2)); + _grossini->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3)); + _tamara->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3)); + _kathia->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2)); } void ActionsDemo::onExit() @@ -202,19 +202,19 @@ void ActionsDemo::centerSprites(unsigned int numberOfSprites) { _tamara->setVisible(false); _kathia->setVisible(false); - _grossini->setPosition(Vector2(s.width/2, s.height/2)); + _grossini->setPosition(Vec2(s.width/2, s.height/2)); } else if( numberOfSprites == 2 ) { - _kathia->setPosition( Vector2(s.width/3, s.height/2)); - _tamara->setPosition( Vector2(2*s.width/3, s.height/2)); + _kathia->setPosition( Vec2(s.width/3, s.height/2)); + _tamara->setPosition( Vec2(2*s.width/3, s.height/2)); _grossini->setVisible(false); } else if( numberOfSprites == 3 ) { - _grossini->setPosition( Vector2(s.width/2, s.height/2)); - _tamara->setPosition( Vector2(s.width/4, s.height/2)); - _kathia->setPosition( Vector2(3 * s.width/4, s.height/2)); + _grossini->setPosition( Vec2(s.width/2, s.height/2)); + _tamara->setPosition( Vec2(s.width/4, s.height/2)); + _kathia->setPosition( Vec2(3 * s.width/4, s.height/2)); } } @@ -226,19 +226,19 @@ void ActionsDemo::alignSpritesLeft(unsigned int numberOfSprites) { _tamara->setVisible(false); _kathia->setVisible(false); - _grossini->setPosition(Vector2(60, s.height/2)); + _grossini->setPosition(Vec2(60, s.height/2)); } else if( numberOfSprites == 2 ) { - _kathia->setPosition( Vector2(60, s.height/3)); - _tamara->setPosition( Vector2(60, 2*s.height/3)); + _kathia->setPosition( Vec2(60, s.height/3)); + _tamara->setPosition( Vec2(60, 2*s.height/3)); _grossini->setVisible( false ); } else if( numberOfSprites == 3 ) { - _grossini->setPosition( Vector2(60, s.height/2)); - _tamara->setPosition( Vector2(60, 2*s.height/3)); - _kathia->setPosition( Vector2(60, s.height/3)); + _grossini->setPosition( Vec2(60, s.height/2)); + _tamara->setPosition( Vec2(60, 2*s.height/3)); + _kathia->setPosition( Vec2(60, s.height/3)); } } @@ -255,14 +255,14 @@ void ActionManual::onEnter() _tamara->setScaleX( 2.5f); _tamara->setScaleY( -1.0f); - _tamara->setPosition( Vector2(100,70) ); + _tamara->setPosition( Vec2(100,70) ); _tamara->setOpacity( 128); _grossini->setRotation( 120); - _grossini->setPosition( Vector2(s.width/2, s.height/2)); + _grossini->setPosition( Vec2(s.width/2, s.height/2)); _grossini->setColor( Color3B( 255,0,0)); - _kathia->setPosition( Vector2(s.width-100, s.height/2)); + _kathia->setPosition( Vec2(s.width-100, s.height/2)); _kathia->setColor( Color3B::BLUE); } @@ -284,13 +284,13 @@ void ActionMove::onEnter() auto s = Director::getInstance()->getWinSize(); - auto actionTo = MoveTo::create(2, Vector2(s.width-40, s.height-40)); - auto actionBy = MoveBy::create(2, Vector2(80,80)); + auto actionTo = MoveTo::create(2, Vec2(s.width-40, s.height-40)); + auto actionBy = MoveBy::create(2, Vec2(80,80)); auto actionByBack = actionBy->reverse(); _tamara->runAction( actionTo); _grossini->runAction( Sequence::create(actionBy, actionByBack, NULL)); - _kathia->runAction(MoveTo::create(1, Vector2(40,40))); + _kathia->runAction(MoveTo::create(1, Vec2(40,40))); } std::string ActionMove::subtitle() const @@ -392,14 +392,14 @@ void ActionRotationalSkewVSStandardSkew::onEnter() Size boxSize(100.0f, 100.0f); auto box = LayerColor::create(Color4B(255,255,0,255)); - box->setAnchorPoint(Vector2(0.5,0.5)); + box->setAnchorPoint(Vec2(0.5,0.5)); box->setContentSize( boxSize ); box->ignoreAnchorPointForPosition(false); - box->setPosition(Vector2(s.width/2, s.height - 100 - box->getContentSize().height/2)); + box->setPosition(Vec2(s.width/2, s.height - 100 - box->getContentSize().height/2)); this->addChild(box); auto label = Label::createWithTTF("Standard cocos2d Skew", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2(s.width/2, s.height - 100 + label->getContentSize().height)); + label->setPosition(Vec2(s.width/2, s.height - 100 + label->getContentSize().height)); this->addChild(label); auto actionTo = SkewBy::create(2, 360, 0); @@ -408,14 +408,14 @@ void ActionRotationalSkewVSStandardSkew::onEnter() box->runAction(Sequence::create(actionTo, actionToBack, NULL)); box = LayerColor::create(Color4B(255,255,0,255)); - box->setAnchorPoint(Vector2(0.5,0.5)); + box->setAnchorPoint(Vec2(0.5,0.5)); box->setContentSize(boxSize); box->ignoreAnchorPointForPosition(false); - box->setPosition(Vector2(s.width/2, s.height - 250 - box->getContentSize().height/2)); + box->setPosition(Vec2(s.width/2, s.height - 250 - box->getContentSize().height/2)); this->addChild(box); label = Label::createWithTTF("Rotational Skew", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2(s.width/2, s.height - 250 + label->getContentSize().height/2)); + label->setPosition(Vec2(s.width/2, s.height - 250 + label->getContentSize().height/2)); this->addChild(label); auto actionTo2 = RotateBy::create(2, 360, 0); auto actionToBack2 = RotateBy::create(2, -360, 0); @@ -438,22 +438,22 @@ void ActionSkewRotateScale::onEnter() Size boxSize(100.0f, 100.0f); auto box = LayerColor::create(Color4B(255, 255, 0, 255)); - box->setAnchorPoint(Vector2(0, 0)); - box->setPosition(Vector2(190, 110)); + box->setAnchorPoint(Vec2(0, 0)); + box->setPosition(Vec2(190, 110)); box->setContentSize(boxSize); static float markrside = 10.0f; auto uL = LayerColor::create(Color4B(255, 0, 0, 255)); box->addChild(uL); uL->setContentSize(Size(markrside, markrside)); - uL->setPosition(Vector2(0.f, boxSize.height - markrside)); - uL->setAnchorPoint(Vector2(0, 0)); + uL->setPosition(Vec2(0.f, boxSize.height - markrside)); + uL->setAnchorPoint(Vec2(0, 0)); auto uR = LayerColor::create(Color4B(0, 0, 255, 255)); box->addChild(uR); uR->setContentSize(Size(markrside, markrside)); - uR->setPosition(Vector2(boxSize.width - markrside, boxSize.height - markrside)); - uR->setAnchorPoint(Vector2(0, 0)); + uR->setPosition(Vec2(boxSize.width - markrside, boxSize.height - markrside)); + uR->setAnchorPoint(Vec2(0, 0)); addChild(box); auto actionTo = SkewTo::create(2, 0.f, 2.f); @@ -513,9 +513,9 @@ void ActionRotateBy3D::onEnter() centerSprites(3); - auto actionBy1 = RotateBy::create(4, Vector3(360, 0, 0)); - auto actionBy2 = RotateBy::create(4, Vector3(0, 360, 0)); - auto actionBy3 = RotateBy::create(4 ,Vector3(0, 0, 360)); + auto actionBy1 = RotateBy::create(4, Vec3(360, 0, 0)); + auto actionBy2 = RotateBy::create(4, Vec3(0, 360, 0)); + auto actionBy3 = RotateBy::create(4 ,Vec3(0, 0, 360)); _tamara->runAction( Sequence::create(actionBy1, actionBy1->reverse(), nullptr)); _grossini->runAction( Sequence::create(actionBy2, actionBy2->reverse(), nullptr)); @@ -538,9 +538,9 @@ void ActionJump::onEnter() centerSprites(3); - auto actionTo = JumpTo::create(2, Vector2(300,300), 50, 4); - auto actionBy = JumpBy::create(2, Vector2(300,0), 50, 4); - auto actionUp = JumpBy::create(2, Vector2(0,0), 80, 4); + auto actionTo = JumpTo::create(2, Vec2(300,300), 50, 4); + auto actionBy = JumpBy::create(2, Vec2(300,0), 50, 4); + auto actionUp = JumpBy::create(2, Vec2(0,0), 80, 4); auto actionByBack = actionBy->reverse(); _tamara->runAction( actionTo); @@ -572,9 +572,9 @@ void ActionBezier::onEnter() // sprite 1 ccBezierConfig bezier; - bezier.controlPoint_1 = Vector2(0, s.height/2); - bezier.controlPoint_2 = Vector2(300, -s.height/2); - bezier.endPosition = Vector2(300,100); + bezier.controlPoint_1 = Vec2(0, s.height/2); + bezier.controlPoint_2 = Vec2(300, -s.height/2); + bezier.endPosition = Vec2(300,100); auto bezierForward = BezierBy::create(3, bezier); auto bezierBack = bezierForward->reverse(); @@ -582,16 +582,16 @@ void ActionBezier::onEnter() // sprite 2 - _tamara->setPosition(Vector2(80,160)); + _tamara->setPosition(Vec2(80,160)); ccBezierConfig bezier2; - bezier2.controlPoint_1 = Vector2(100, s.height/2); - bezier2.controlPoint_2 = Vector2(200, -s.height/2); - bezier2.endPosition = Vector2(240,160); + bezier2.controlPoint_1 = Vec2(100, s.height/2); + bezier2.controlPoint_2 = Vec2(200, -s.height/2); + bezier2.endPosition = Vec2(240,160); auto bezierTo1 = BezierTo::create(2, bezier2); // sprite 3 - _kathia->setPosition(Vector2(400,160)); + _kathia->setPosition(Vec2(400,160)); auto bezierTo2 = BezierTo::create(2, bezier2); _grossini->runAction( rep); @@ -771,7 +771,7 @@ void ActionSequence::onEnter() alignSpritesLeft(1); auto action = Sequence::create( - MoveBy::create( 2, Vector2(240,0)), + MoveBy::create( 2, Vec2(240,0)), RotateBy::create( 2, 540), NULL); @@ -797,9 +797,9 @@ void ActionSequence2::onEnter() _grossini->setVisible(false); auto action = Sequence::create( - Place::create(Vector2(200,200)), + Place::create(Vec2(200,200)), Show::create(), - MoveBy::create(1, Vector2(100,0)), + MoveBy::create(1, Vec2(100,0)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback1,this)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback2,this,_grossini)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback3,this,_grossini,0xbebabeba)), @@ -812,7 +812,7 @@ void ActionSequence2::callback1() { auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("callback 1 called", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*1,s.height/2)); + label->setPosition(Vec2( s.width/4*1,s.height/2)); addChild(label); } @@ -821,7 +821,7 @@ void ActionSequence2::callback2(Node* sender) { auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("callback 2 called", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*2,s.height/2)); + label->setPosition(Vec2( s.width/4*2,s.height/2)); addChild(label); } @@ -830,7 +830,7 @@ void ActionSequence2::callback3(Node* sender, long data) { auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("callback 3 called", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*3,s.height/2)); + label->setPosition(Vec2( s.width/4*3,s.height/2)); addChild(label); } @@ -852,7 +852,7 @@ void ActionCallFuncN::onEnter() centerSprites(1); auto action = Sequence::create( - MoveBy::create(2.0f, Vector2(150,0)), + MoveBy::create(2.0f, Vec2(150,0)), CallFuncN::create( CC_CALLBACK_1(ActionCallFuncN::callback, this)), NULL); @@ -871,7 +871,7 @@ std::string ActionCallFuncN::subtitle() const void ActionCallFuncN::callback(Node* sender ) { - auto a = JumpBy::create(5, Vector2(0,0), 100, 5); + auto a = JumpBy::create(5, Vec2(0,0), 100, 5); sender->runAction(a); } //------------------------------------------------------------------ @@ -887,7 +887,7 @@ void ActionCallFuncND::onEnter() centerSprites(1); auto action = Sequence::create( - MoveBy::create(2.0f, Vector2(200,0)), + MoveBy::create(2.0f, Vec2(200,0)), CallFuncN::create( CC_CALLBACK_1(ActionCallFuncND::doRemoveFromParentAndCleanup, this, true)), NULL); @@ -922,7 +922,7 @@ void ActionCallFuncO::onEnter() centerSprites(1); auto action = Sequence::create( - MoveBy::create(2.0f, Vector2(200,0)), + MoveBy::create(2.0f, Vec2(200,0)), CallFunc::create( CC_CALLBACK_0(ActionCallFuncO::callback, this, _grossini, true)), NULL); _grossini->runAction(action); @@ -956,14 +956,14 @@ void ActionCallFunction::onEnter() auto action1 = Sequence::create( - MoveBy::create(2, Vector2(200,0)), + MoveBy::create(2, Vec2(200,0)), CallFunc::create( std::bind(&ActionCallFunction::callback1, this) ), CallFunc::create( // lambda [&](){ auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("called:lambda callback", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*1,s.height/2-40)); + label->setPosition(Vec2( s.width/4*1,s.height/2-40)); this->addChild(label); } ), NULL); @@ -990,7 +990,7 @@ void ActionCallFunction::callback1() { auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("callback 1 called", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*1,s.height/2)); + label->setPosition(Vec2( s.width/4*1,s.height/2)); addChild(label); } @@ -999,7 +999,7 @@ void ActionCallFunction::callback2(Node* sender) { auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("callback 2 called", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*2,s.height/2)); + label->setPosition(Vec2( s.width/4*2,s.height/2)); addChild(label); @@ -1010,7 +1010,7 @@ void ActionCallFunction::callback3(Node* sender, long data) { auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("callback 3 called", "fonts/Marker Felt.ttf", 16.0f); - label->setPosition(Vector2( s.width/4*3,s.height/2)); + label->setPosition(Vec2( s.width/4*3,s.height/2)); addChild(label); CCLOG("target is: %p, data is: %ld", sender, data); @@ -1033,7 +1033,7 @@ void ActionSpawn::onEnter() alignSpritesLeft(1); auto action = Spawn::create( - JumpBy::create(2, Vector2(300,0), 50, 4), + JumpBy::create(2, Vec2(300,0), 50, 4), RotateBy::create( 2, 720), NULL); @@ -1144,7 +1144,7 @@ void ActionReverse::onEnter() alignSpritesLeft(1); - auto jump = JumpBy::create(2, Vector2(300,0), 50, 4); + auto jump = JumpBy::create(2, Vec2(300,0), 50, 4); auto action = Sequence::create( jump, jump->reverse(), NULL); _grossini->runAction(action); @@ -1167,7 +1167,7 @@ void ActionDelayTime::onEnter() alignSpritesLeft(1); - auto move = MoveBy::create(1, Vector2(150,0)); + auto move = MoveBy::create(1, Vec2(150,0)); auto action = Sequence::create( move, DelayTime::create(2), move, NULL); _grossini->runAction(action); @@ -1190,8 +1190,8 @@ void ActionReverseSequence::onEnter() alignSpritesLeft(1); - auto move1 = MoveBy::create(1, Vector2(250,0)); - auto move2 = MoveBy::create(1, Vector2(0,50)); + auto move1 = MoveBy::create(1, Vec2(250,0)); + auto move2 = MoveBy::create(1, Vec2(0,50)); auto seq = Sequence::create( move1, move2, move1->reverse(), NULL); auto action = Sequence::create( seq, seq->reverse(), NULL); @@ -1218,8 +1218,8 @@ void ActionReverseSequence2::onEnter() // Test: // Sequence should work both with IntervalAction and InstantActions - auto move1 = MoveBy::create(1, Vector2(250,0)); - auto move2 = MoveBy::create(1, Vector2(0,50)); + auto move1 = MoveBy::create(1, Vec2(250,0)); + auto move2 = MoveBy::create(1, Vec2(0,50)); auto tog1 = ToggleVisibility::create(); auto tog2 = ToggleVisibility::create(); auto seq = Sequence::create( move1, tog1, move2, tog2, move1->reverse(), NULL); @@ -1230,8 +1230,8 @@ void ActionReverseSequence2::onEnter() // Also test that the reverse of Hide is Show, and vice-versa _kathia->runAction(action); - auto move_tamara = MoveBy::create(1, Vector2(100,0)); - auto move_tamara2 = MoveBy::create(1, Vector2(50,0)); + auto move_tamara = MoveBy::create(1, Vec2(100,0)); + auto move_tamara2 = MoveBy::create(1, Vec2(50,0)); auto hide = Hide::create(); auto seq_tamara = Sequence::create( move_tamara, hide, move_tamara2, NULL); auto seq_back = seq_tamara->reverse(); @@ -1254,9 +1254,9 @@ void ActionRepeat::onEnter() alignSpritesLeft(2); - auto a1 = MoveBy::create(1, Vector2(150,0)); + auto a1 = MoveBy::create(1, Vec2(150,0)); auto action1 = Repeat::create( - Sequence::create( Place::create(Vector2(60,60)), a1, NULL) , + Sequence::create( Place::create(Vec2(60,60)), a1, NULL) , 3); auto action2 = RepeatForever::create( Sequence::create(a1->clone(), a1->reverse(), NULL) @@ -1305,7 +1305,7 @@ void ActionOrbit::onEnter() _tamara->runAction(RepeatForever::create(action2)); _grossini->runAction(RepeatForever::create(action3)); - auto move = MoveBy::create(3, Vector2(100,-100)); + auto move = MoveBy::create(3, Vec2(100,-100)); auto move_back = move->reverse(); auto seq = Sequence::create(move, move_back, NULL); auto rfe = RepeatForever::create(seq); @@ -1338,8 +1338,8 @@ void ActionFollow::onEnter() centerSprites(1); auto s = Director::getInstance()->getWinSize(); - _grossini->setPosition(Vector2(-200, s.height / 2)); - auto move = MoveBy::create(2, Vector2(s.width * 3, 0)); + _grossini->setPosition(Vec2(-200, s.height / 2)); + auto move = MoveBy::create(2, Vec2(s.width * 3, 0)); auto move_back = move->reverse(); auto seq = Sequence::create(move, move_back, NULL); auto rep = RepeatForever::create(seq); @@ -1349,7 +1349,7 @@ void ActionFollow::onEnter() this->runAction(Follow::create(_grossini, Rect(0, 0, s.width * 2 - 100, s.height))); } -void ActionFollow::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ActionFollow::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this, transform, transformUpdated); @@ -1357,7 +1357,7 @@ void ActionFollow::draw(Renderer *renderer, const Matrix &transform, bool transf renderer->addCommand(&_customCommand); } -void ActionFollow::onDraw(const Matrix &transform, bool transformUpdated) +void ActionFollow::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1369,7 +1369,7 @@ void ActionFollow::onDraw(const Matrix &transform, bool transformUpdated) float x = winSize.width*2 - 100; float y = winSize.height; - Vector2 vertices[] = { Vector2(5,5), Vector2(x-5,5), Vector2(x-5,y-5), Vector2(5,y-5) }; + Vec2 vertices[] = { Vec2(5,5), Vec2(x-5,5), Vec2(x-5,y-5), Vec2(5,y-5) }; DrawPrimitives::drawPoly(vertices, 4, true); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -1386,7 +1386,7 @@ void ActionTargeted::onEnter() centerSprites(2); - auto jump1 = JumpBy::create(2,Vector2::ZERO,100,3); + auto jump1 = JumpBy::create(2,Vec2::ZERO,100,3); auto jump2 = jump1->clone(); auto rot1 = RotateBy::create(1, 360); auto rot2 = rot1->clone(); @@ -1417,7 +1417,7 @@ void ActionTargetedReverse::onEnter() centerSprites(2); - auto jump1 = JumpBy::create(2,Vector2::ZERO,100,3); + auto jump1 = JumpBy::create(2,Vec2::ZERO,100,3); auto jump2 = jump1->clone(); auto rot1 = RotateBy::create(1, 360); auto rot2 = rot1->clone(); @@ -1454,10 +1454,10 @@ void ActionStacked::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto s = Director::getInstance()->getWinSize(); - this->addNewSpriteWithCoords(Vector2(s.width/2, s.height/2)); + this->addNewSpriteWithCoords(Vec2(s.width/2, s.height/2)); } -void ActionStacked::addNewSpriteWithCoords(Vector2 p) +void ActionStacked::addNewSpriteWithCoords(Vec2 p) { int idx = CCRANDOM_0_1() * 1400 / 100; int x = (idx%5) * 85; @@ -1503,11 +1503,11 @@ void ActionMoveStacked::runActionsInSprite(Sprite *sprite) sprite->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,10)), - MoveBy::create(0.05f, Vector2(-10,-10)), + MoveBy::create(0.05f, Vec2(10,10)), + MoveBy::create(0.05f, Vec2(-10,-10)), NULL))); - auto action = MoveBy::create(2.0f, Vector2(400,0)); + auto action = MoveBy::create(2.0f, Vec2(400,0)); auto action_back = action->reverse(); sprite->runAction( @@ -1529,11 +1529,11 @@ void ActionMoveJumpStacked::runActionsInSprite(Sprite *sprite) sprite->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,2)), - MoveBy::create(0.05f, Vector2(-10,-2)), + MoveBy::create(0.05f, Vec2(10,2)), + MoveBy::create(0.05f, Vec2(-10,-2)), NULL))); - auto jump = JumpBy::create(2.0f, Vector2(400,0), 100, 5); + auto jump = JumpBy::create(2.0f, Vec2(400,0), 100, 5); auto jump_back = jump->reverse(); sprite->runAction( @@ -1555,9 +1555,9 @@ void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) // sprite 1 ccBezierConfig bezier; - bezier.controlPoint_1 = Vector2(0, s.height/2); - bezier.controlPoint_2 = Vector2(300, -s.height/2); - bezier.endPosition = Vector2(300,100); + bezier.controlPoint_1 = Vec2(0, s.height/2); + bezier.controlPoint_2 = Vec2(300, -s.height/2); + bezier.endPosition = Vec2(300,100); auto bezierForward = BezierBy::create(3, bezier); auto bezierBack = bezierForward->reverse(); @@ -1568,8 +1568,8 @@ void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) sprite->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,0)), - MoveBy::create(0.05f, Vector2(-10,0)), + MoveBy::create(0.05f, Vec2(10,0)), + MoveBy::create(0.05f, Vec2(-10,0)), NULL))); } @@ -1596,17 +1596,17 @@ void ActionCatmullRomStacked::onEnter() // is relative to the Catmull Rom curve, it is better to start with (0,0). // - _tamara->setPosition(Vector2(50,50)); + _tamara->setPosition(Vec2(50,50)); auto array = PointArray::create(20); - array->addControlPoint(Vector2(0,0)); - array->addControlPoint(Vector2(80,80)); - array->addControlPoint(Vector2(s.width-80,80)); - array->addControlPoint(Vector2(s.width-80,s.height-80)); - array->addControlPoint(Vector2(80,s.height-80)); - array->addControlPoint(Vector2(80,80)); - array->addControlPoint(Vector2(s.width/2, s.height/2)); + array->addControlPoint(Vec2(0,0)); + array->addControlPoint(Vec2(80,80)); + array->addControlPoint(Vec2(s.width-80,80)); + array->addControlPoint(Vec2(s.width-80,s.height-80)); + array->addControlPoint(Vec2(80,s.height-80)); + array->addControlPoint(Vec2(80,80)); + array->addControlPoint(Vec2(s.width/2, s.height/2)); auto action = CatmullRomBy::create(3, array); auto reverse = action->reverse(); @@ -1618,8 +1618,8 @@ void ActionCatmullRomStacked::onEnter() _tamara->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,0)), - MoveBy::create(0.05f, Vector2(-10,0)), + MoveBy::create(0.05f, Vec2(10,0)), + MoveBy::create(0.05f, Vec2(-10,0)), NULL))); // @@ -1631,11 +1631,11 @@ void ActionCatmullRomStacked::onEnter() auto array2 = PointArray::create(20); - array2->addControlPoint(Vector2(s.width/2, 30)); - array2->addControlPoint(Vector2(s.width-80,30)); - array2->addControlPoint(Vector2(s.width-80,s.height-80)); - array2->addControlPoint(Vector2(s.width/2,s.height-80)); - array2->addControlPoint(Vector2(s.width/2, 30)); + array2->addControlPoint(Vec2(s.width/2, 30)); + array2->addControlPoint(Vec2(s.width-80,30)); + array2->addControlPoint(Vec2(s.width-80,s.height-80)); + array2->addControlPoint(Vec2(s.width/2,s.height-80)); + array2->addControlPoint(Vec2(s.width/2, 30)); auto action2 = CatmullRomTo::create(3, array2); auto reverse2 = action2->reverse(); @@ -1647,8 +1647,8 @@ void ActionCatmullRomStacked::onEnter() _kathia->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,0)), - MoveBy::create(0.05f, Vector2(-10,0)), + MoveBy::create(0.05f, Vec2(10,0)), + MoveBy::create(0.05f, Vec2(-10,0)), NULL))); array->retain(); @@ -1663,7 +1663,7 @@ ActionCatmullRomStacked::~ActionCatmullRomStacked() CC_SAFE_RELEASE(_array2); } -void ActionCatmullRomStacked::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { ActionsDemo::draw(renderer, transform, transformUpdated); @@ -1672,10 +1672,10 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const Matrix &transform, CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - Matrix translation; + Mat4 translation; //Create a rotation matrix using the axis and the angle - Matrix::createTranslation(50, 50, 0, &translation); + Mat4::createTranslation(50, 50, 0, &translation); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation); _modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -1687,12 +1687,12 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const Matrix &transform, renderer->addCommand(&_customCommand); } -void ActionCatmullRomStacked::onDraw(const Matrix &transform, bool transformUpdated) +void ActionCatmullRomStacked::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix oldMat; + Mat4 oldMat; oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1); DrawPrimitives::drawCatmullRom(_array1,50); @@ -1724,11 +1724,11 @@ void ActionCardinalSplineStacked::onEnter() auto array = PointArray::create(20); - array->addControlPoint(Vector2(0, 0)); - array->addControlPoint(Vector2(s.width/2-30,0)); - array->addControlPoint(Vector2(s.width/2-30,s.height-80)); - array->addControlPoint(Vector2(0, s.height-80)); - array->addControlPoint(Vector2(0, 0)); + array->addControlPoint(Vec2(0, 0)); + array->addControlPoint(Vec2(s.width/2-30,0)); + array->addControlPoint(Vec2(s.width/2-30,s.height-80)); + array->addControlPoint(Vec2(0, s.height-80)); + array->addControlPoint(Vec2(0, 0)); // @@ -1742,14 +1742,14 @@ void ActionCardinalSplineStacked::onEnter() auto seq = Sequence::create(action, reverse, NULL); - _tamara->setPosition(Vector2(50,50)); + _tamara->setPosition(Vec2(50,50)); _tamara->runAction(seq); _tamara->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,0)), - MoveBy::create(0.05f, Vector2(-10,0)), + MoveBy::create(0.05f, Vec2(10,0)), + MoveBy::create(0.05f, Vec2(-10,0)), NULL))); // @@ -1763,15 +1763,15 @@ void ActionCardinalSplineStacked::onEnter() auto seq2 = Sequence::create(action2, reverse2, NULL); - _kathia->setPosition(Vector2(s.width/2,50)); + _kathia->setPosition(Vec2(s.width/2,50)); _kathia->runAction(seq2); _kathia->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vector2(10,0)), - MoveBy::create(0.05f, Vector2(-10,0)), + MoveBy::create(0.05f, Vec2(10,0)), + MoveBy::create(0.05f, Vec2(-10,0)), NULL))); array->retain(); @@ -1783,7 +1783,7 @@ ActionCardinalSplineStacked::~ActionCardinalSplineStacked() CC_SAFE_RELEASE(_array); } -void ActionCardinalSplineStacked::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { ActionsDemo::draw(renderer, transform, transformUpdated); @@ -1792,10 +1792,10 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const Matrix &transfo CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - Matrix translation; + Mat4 translation; //Create a rotation matrix using the axis and the angle - Matrix::createTranslation(50, 50, 0, &translation); + Mat4::createTranslation(50, 50, 0, &translation); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation); _modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -1806,7 +1806,7 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const Matrix &transfo director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); //Create a rotation matrix using the axis and the angle - Matrix::createTranslation(s.width/2, 50, 0, &translation); + Mat4::createTranslation(s.width/2, 50, 0, &translation); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation); _modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -1817,12 +1817,12 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const Matrix &transfo renderer->addCommand(&_customCommand); } -void ActionCardinalSplineStacked::onDraw(const Matrix &transform, bool transformUpdated) +void ActionCardinalSplineStacked::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix oldMat; + Mat4 oldMat; oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1); DrawPrimitives::drawCardinalSpline(_array, 0, 100); @@ -1874,7 +1874,7 @@ void Issue1305::onExit() void Issue1305::addSprite(float dt) { - _spriteTmp->setPosition(Vector2(250,250)); + _spriteTmp->setPosition(Vec2(250,250)); addChild(_spriteTmp); } @@ -1894,34 +1894,34 @@ void Issue1305_2::onEnter() centerSprites(0); auto spr = Sprite::create("Images/grossini.png"); - spr->setPosition(Vector2(200,200)); + spr->setPosition(Vec2(200,200)); addChild(spr); - auto act1 = MoveBy::create(2 ,Vector2(0, 100)); + auto act1 = MoveBy::create(2 ,Vec2(0, 100)); /* c++ can't support block, so we use CallFuncN instead. id act2 = [CallBlock actionWithBlock:^{ NSLog(@"1st block"); }); - id act3 = [MoveBy create:2, Vector2(0, -100)); + id act3 = [MoveBy create:2, Vec2(0, -100)); id act4 = [CallBlock actionWithBlock:^{ NSLog(@"2nd block"); }); - id act5 = [MoveBy create:2, Vector2(100, -100)); + id act5 = [MoveBy create:2, Vec2(100, -100)); id act6 = [CallBlock actionWithBlock:^{ NSLog(@"3rd block"); }); - id act7 = [MoveBy create:2, Vector2(-100, 0)); + id act7 = [MoveBy create:2, Vec2(-100, 0)); id act8 = [CallBlock actionWithBlock:^{ NSLog(@"4th block"); }); */ auto act2 = CallFunc::create( std::bind( &Issue1305_2::printLog1, this)); - auto act3 = MoveBy::create(2, Vector2(0, -100)); + auto act3 = MoveBy::create(2, Vec2(0, -100)); auto act4 = CallFunc::create( std::bind( &Issue1305_2::printLog2, this)); - auto act5 = MoveBy::create(2, Vector2(100, -100)); + auto act5 = MoveBy::create(2, Vec2(100, -100)); auto act6 = CallFunc::create( std::bind( &Issue1305_2::printLog3, this)); - auto act7 = MoveBy::create(2, Vector2(-100, 0)); + auto act7 = MoveBy::create(2, Vec2(-100, 0)); auto act8 = CallFunc::create( std::bind( &Issue1305_2::printLog4, this)); auto actF = Sequence::create(act1, act2, act3, act4, act5, act6, act7, act8, NULL); @@ -1967,10 +1967,10 @@ void Issue1288::onEnter() centerSprites(0); auto spr = Sprite::create("Images/grossini.png"); - spr->setPosition(Vector2(100, 100)); + spr->setPosition(Vec2(100, 100)); addChild(spr); - auto act1 = MoveBy::create(0.5, Vector2(100, 0)); + auto act1 = MoveBy::create(0.5, Vec2(100, 0)); auto act2 = act1->reverse(); auto act3 = Sequence::create(act1, act2, NULL); auto act4 = Repeat::create(act3, 2); @@ -1994,10 +1994,10 @@ void Issue1288_2::onEnter() centerSprites(0); auto spr = Sprite::create("Images/grossini.png"); - spr->setPosition(Vector2(100, 100)); + spr->setPosition(Vec2(100, 100)); addChild(spr); - auto act1 = MoveBy::create(0.5, Vector2(100, 0)); + auto act1 = MoveBy::create(0.5, Vec2(100, 0)); spr->runAction(Repeat::create(act1, 1)); } @@ -2018,7 +2018,7 @@ void Issue1327::onEnter() centerSprites(0); auto spr = Sprite::create("Images/grossini.png"); - spr->setPosition(Vector2(100, 100)); + spr->setPosition(Vec2(100, 100)); addChild(spr); auto act1 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); @@ -2111,17 +2111,17 @@ void ActionCatmullRom::onEnter() // is relative to the Catmull Rom curve, it is better to start with (0,0). // - _tamara->setPosition(Vector2(50, 50)); + _tamara->setPosition(Vec2(50, 50)); auto array = PointArray::create(20); - array->addControlPoint(Vector2(0, 0)); - array->addControlPoint(Vector2(80, 80)); - array->addControlPoint(Vector2(s.width - 80, 80)); - array->addControlPoint(Vector2(s.width - 80, s.height - 80)); - array->addControlPoint(Vector2(80, s.height - 80)); - array->addControlPoint(Vector2(80, 80)); - array->addControlPoint(Vector2(s.width / 2, s.height / 2)); + array->addControlPoint(Vec2(0, 0)); + array->addControlPoint(Vec2(80, 80)); + array->addControlPoint(Vec2(s.width - 80, 80)); + array->addControlPoint(Vec2(s.width - 80, s.height - 80)); + array->addControlPoint(Vec2(80, s.height - 80)); + array->addControlPoint(Vec2(80, 80)); + array->addControlPoint(Vec2(s.width / 2, s.height / 2)); auto action = CatmullRomBy::create(3, array); auto reverse = action->reverse(); @@ -2140,11 +2140,11 @@ void ActionCatmullRom::onEnter() auto array2 = PointArray::create(20); - array2->addControlPoint(Vector2(s.width / 2, 30)); - array2->addControlPoint(Vector2(s.width -80, 30)); - array2->addControlPoint(Vector2(s.width - 80, s.height - 80)); - array2->addControlPoint(Vector2(s.width / 2, s.height - 80)); - array2->addControlPoint(Vector2(s.width / 2, 30)); + array2->addControlPoint(Vec2(s.width / 2, 30)); + array2->addControlPoint(Vec2(s.width -80, 30)); + array2->addControlPoint(Vec2(s.width - 80, s.height - 80)); + array2->addControlPoint(Vec2(s.width / 2, s.height - 80)); + array2->addControlPoint(Vec2(s.width / 2, 30)); auto action2 = CatmullRomTo::create(3, array2); auto reverse2 = action2->reverse(); @@ -2165,7 +2165,7 @@ ActionCatmullRom::~ActionCatmullRom() _array2->release(); } -void ActionCatmullRom::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { ActionsDemo::draw(renderer, transform, transformUpdated); @@ -2174,10 +2174,10 @@ void ActionCatmullRom::draw(Renderer *renderer, const Matrix &transform, bool tr CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - Matrix translation; + Mat4 translation; //Create a rotation matrix using the axis and the angle - Matrix::createTranslation(50, 50, 0, &translation); + Mat4::createTranslation(50, 50, 0, &translation); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation); _modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -2190,12 +2190,12 @@ void ActionCatmullRom::draw(Renderer *renderer, const Matrix &transform, bool tr } -void ActionCatmullRom::onDraw(const Matrix &transform, bool transformUpdated) +void ActionCatmullRom::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix oldMat; + Mat4 oldMat; oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1); DrawPrimitives::drawCatmullRom(_array1, 50); @@ -2227,11 +2227,11 @@ void ActionCardinalSpline::onEnter() auto array = PointArray::create(20); - array->addControlPoint(Vector2(0, 0)); - array->addControlPoint(Vector2(s.width/2-30, 0)); - array->addControlPoint(Vector2(s.width/2-30, s.height-80)); - array->addControlPoint(Vector2(0, s.height-80)); - array->addControlPoint(Vector2(0, 0)); + array->addControlPoint(Vec2(0, 0)); + array->addControlPoint(Vec2(s.width/2-30, 0)); + array->addControlPoint(Vec2(s.width/2-30, s.height-80)); + array->addControlPoint(Vec2(0, s.height-80)); + array->addControlPoint(Vec2(0, 0)); // // sprite 1 (By) @@ -2244,7 +2244,7 @@ void ActionCardinalSpline::onEnter() auto seq = Sequence::create(action, reverse, NULL); - _tamara->setPosition(Vector2(50, 50)); + _tamara->setPosition(Vec2(50, 50)); _tamara->runAction(seq); // @@ -2258,7 +2258,7 @@ void ActionCardinalSpline::onEnter() auto seq2 = Sequence::create(action2, reverse2, NULL); - _kathia->setPosition(Vector2(s.width/2, 50)); + _kathia->setPosition(Vec2(s.width/2, 50)); _kathia->runAction(seq2); _array = array; @@ -2270,7 +2270,7 @@ ActionCardinalSpline::~ActionCardinalSpline() _array->release(); } -void ActionCardinalSpline::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { ActionsDemo::draw(renderer, transform, transformUpdated); @@ -2279,10 +2279,10 @@ void ActionCardinalSpline::draw(Renderer *renderer, const Matrix &transform, boo CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - Matrix translation; + Mat4 translation; //Create a rotation matrix using the axis and the angle - Matrix::createTranslation(50, 50, 0, &translation); + Mat4::createTranslation(50, 50, 0, &translation); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation); _modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -2292,7 +2292,7 @@ void ActionCardinalSpline::draw(Renderer *renderer, const Matrix &transform, boo director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); //Create a rotation matrix using the axis and the angle - Matrix::createTranslation(s.width/2, 50, 0, &translation); + Mat4::createTranslation(s.width/2, 50, 0, &translation); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation); _modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -2302,12 +2302,12 @@ void ActionCardinalSpline::draw(Renderer *renderer, const Matrix &transform, boo renderer->addCommand(&_customCommand); } -void ActionCardinalSpline::onDraw(const Matrix &transform, bool transformUpdated) +void ActionCardinalSpline::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix oldMat; + Mat4 oldMat; oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1); DrawPrimitives::drawCardinalSpline(_array, 0, 100); @@ -2391,7 +2391,7 @@ void ActionRemoveSelf::onEnter() alignSpritesLeft(1); auto action = Sequence::create( - MoveBy::create( 2, Vector2(240,0)), + MoveBy::create( 2, Vec2(240,0)), RotateBy::create( 2, 540), ScaleTo::create(1,0.1f), RemoveSelf::create(), diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h index 9b6a77e9be..7aa1de92ca 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h @@ -379,11 +379,11 @@ public: CREATE_FUNC(ActionFollow); virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string subtitle() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); CustomCommand _customCommand; }; @@ -416,7 +416,7 @@ public: virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void addNewSpriteWithCoords(Vector2 p); + virtual void addNewSpriteWithCoords(Vec2 p); virtual void runActionsInSprite(Sprite* sprite); void onTouchesEnded(const std::vector& touches, Event* event); }; @@ -454,17 +454,17 @@ public: CREATE_FUNC(ActionCatmullRomStacked); virtual ~ActionCatmullRomStacked(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); //cached data and callback - Matrix _modelViewMV1; - Matrix _modelViewMV2; + Mat4 _modelViewMV1; + Mat4 _modelViewMV2; PointArray* _array1; PointArray* _array2; CustomCommand _customCommand; @@ -476,16 +476,16 @@ public: CREATE_FUNC(ActionCardinalSplineStacked); virtual ~ActionCardinalSplineStacked(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated); virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); - Matrix _modelViewMV1; - Matrix _modelViewMV2; + Mat4 _modelViewMV1; + Mat4 _modelViewMV2; CustomCommand _customCommand; PointArray* _array; }; @@ -572,15 +572,15 @@ public: ~ActionCatmullRom(); virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string subtitle() const override; virtual std::string title() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); - Matrix _modelViewMV1; - Matrix _modelViewMV2; + Mat4 _modelViewMV1; + Mat4 _modelViewMV2; CustomCommand _customCommand; PointArray *_array1; PointArray *_array2; @@ -594,16 +594,16 @@ public: ~ActionCardinalSpline(); virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string subtitle() const override; virtual std::string title() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); PointArray *_array; - Matrix _modelViewMV1; - Matrix _modelViewMV2; + Mat4 _modelViewMV1; + Mat4 _modelViewMV2; CustomCommand _customCommand; }; diff --git a/tests/cpp-tests/Classes/BaseTest.cpp b/tests/cpp-tests/Classes/BaseTest.cpp index 10b59ed403..75c4bc275a 100644 --- a/tests/cpp-tests/Classes/BaseTest.cpp +++ b/tests/cpp-tests/Classes/BaseTest.cpp @@ -40,7 +40,7 @@ void BaseTest::onEnter() TTFConfig ttfConfig("fonts/arial.ttf", 32); auto label = Label::createWithTTF(ttfConfig,pTitle); addChild(label, 9999); - label->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 30) ); + label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) @@ -49,7 +49,7 @@ void BaseTest::onEnter() ttfConfig.fontSize = 16; auto l = Label::createWithTTF(ttfConfig,strSubtitle.c_str()); addChild(l, 9999); - l->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 60) ); + l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) ); } // add menu @@ -60,10 +60,10 @@ void BaseTest::onEnter() auto menu = Menu::create(item1, item2, item3, NULL); - menu->setPosition(Vector2::ZERO); - item1->setPosition(Vector2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vector2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + menu->setPosition(Vec2::ZERO); + item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 9999); } diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp index 44cb115fd5..dafd39c8d4 100644 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp +++ b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp @@ -46,7 +46,7 @@ Box2DTestLayer::Box2DTestLayer() auto label = Label::createWithTTF("Tap screen", "fonts/Marker Felt.ttf", 32.0f); addChild(label, 0); label->setColor(Color3B(0,0,255)); - label->setPosition(Vector2( VisibleRect::center().x, VisibleRect::top().y-50)); + label->setPosition(Vec2( VisibleRect::center().x, VisibleRect::top().y-50)); scheduleUpdate(); #else @@ -54,7 +54,7 @@ Box2DTestLayer::Box2DTestLayer() "fonts/arial.ttf", 18); auto size = Director::getInstance()->getWinSize(); - label->setPosition(Vector2(size.width/2, size.height/2)); + label->setPosition(Vec2(size.width/2, size.height/2)); addChild(label); #endif @@ -132,12 +132,12 @@ void Box2DTestLayer::createResetButton() auto menu = Menu::create(reset, NULL); - menu->setPosition(Vector2(VisibleRect::bottom().x, VisibleRect::bottom().y + 30)); + menu->setPosition(Vec2(VisibleRect::bottom().x, VisibleRect::bottom().y + 30)); this->addChild(menu, -1); } -void Box2DTestLayer::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Box2DTestLayer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { // // IMPORTANT: @@ -168,7 +168,7 @@ void Box2DTestLayer::onDraw() Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - Matrix oldMV; + Mat4 oldMV; oldMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV); world->DrawDebugData(); @@ -176,7 +176,7 @@ void Box2DTestLayer::onDraw() } #endif -void Box2DTestLayer::addNewSpriteAtPosition(Vector2 p) +void Box2DTestLayer::addNewSpriteAtPosition(Vec2 p) { CCLOG("Add sprite %0.2f x %02.f",p.x,p.y); @@ -210,7 +210,7 @@ void Box2DTestLayer::addNewSpriteAtPosition(Vector2 p) parent->addChild(sprite); sprite->setB2Body(body); sprite->setPTMRatio(PTM_RATIO); - sprite->setPosition( Vector2( p.x, p.y) ); + sprite->setPosition( Vec2( p.x, p.y) ); #endif } diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h index d64d2096aa..1109577a04 100644 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h +++ b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h @@ -17,15 +17,15 @@ public: void initPhysics(); void createResetButton(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; - void addNewSpriteAtPosition(Vector2 p); + void addNewSpriteAtPosition(Vec2 p); void update(float dt); void onTouchesEnded(const std::vector& touches, Event* event); #if CC_ENABLE_BOX2D_INTEGRATION protected: - Matrix _modelViewMV; + Mat4 _modelViewMV; void onDraw(); CustomCommand _customCommand; #endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp index b27a9996d8..28e0540835 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp @@ -49,7 +49,7 @@ MenuLayer* MenuLayer::menuWithEntryID(int entryId) bool MenuLayer::initWithEntryID(int entryId) { auto director = Director::getInstance(); - Vector2 visibleOrigin = director->getVisibleOrigin(); + Vec2 visibleOrigin = director->getVisibleOrigin(); Size visibleSize = director->getVisibleSize(); m_entryID = entryId; @@ -57,11 +57,11 @@ bool MenuLayer::initWithEntryID(int entryId) Box2DView* view = Box2DView::viewWithEntryID( entryId ); addChild(view, 0, kTagBox2DNode); view->setScale(15); - view->setAnchorPoint( Vector2(0,0) ); - view->setPosition( Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3) ); + view->setAnchorPoint( Vec2(0,0) ); + view->setPosition( Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3) ); auto label = Label::createWithTTF(view->title().c_str(), "fonts/arial.ttf", 28); addChild(label, 1); - label->setPosition( Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) ); + label->setPosition( Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) ); auto item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(MenuLayer::backCallback, this) ); auto item2 = MenuItemImage::create("Images/r1.png","Images/r2.png", CC_CALLBACK_1( MenuLayer::restartCallback, this) ); @@ -69,10 +69,10 @@ bool MenuLayer::initWithEntryID(int entryId) auto menu = Menu::create(item1, item2, item3, NULL); - menu->setPosition( Vector2::ZERO ); - item1->setPosition(Vector2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vector2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + menu->setPosition( Vec2::ZERO ); + item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 1); @@ -202,7 +202,7 @@ std::string Box2DView::title() const return std::string(m_entry->name); } -void Box2DView::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Box2DView::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Layer::draw(renderer, transform, transformUpdated); @@ -211,7 +211,7 @@ void Box2DView::draw(Renderer *renderer, const Matrix &transform, bool transform renderer->addCommand(&_customCmd); } -void Box2DView::onDraw(const Matrix &transform, bool transformUpdated) +void Box2DView::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h index 8c1b4470ce..23446adbc9 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h +++ b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h @@ -42,7 +42,7 @@ public: bool initWithEntryID(int entryId); std::string title() const; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; // virtual void registerWithTouchDispatcher(); bool onTouchBegan(Touch* touch, Event* event); @@ -55,7 +55,7 @@ public: static Box2DView* viewWithEntryID(int entryId); protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); CustomCommand _customCmd; }; diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-1159.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-1159.cpp index f12eba9f68..2a6ef994e9 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-1159.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-1159.cpp @@ -29,25 +29,25 @@ bool Bug1159Layer::init() addChild(background); auto sprite_a = LayerColor::create(Color4B(255, 0, 0, 255), 700, 700); - sprite_a->setAnchorPoint(Vector2(0.5f, 0.5f)); + sprite_a->setAnchorPoint(Vec2(0.5f, 0.5f)); sprite_a->ignoreAnchorPointForPosition(false); - sprite_a->setPosition(Vector2(0.0f, s.height/2)); + sprite_a->setPosition(Vec2(0.0f, s.height/2)); addChild(sprite_a); sprite_a->runAction(RepeatForever::create(Sequence::create( - MoveTo::create(1.0f, Vector2(1024.0f, 384.0f)), - MoveTo::create(1.0f, Vector2(0.0f, 384.0f)), + MoveTo::create(1.0f, Vec2(1024.0f, 384.0f)), + MoveTo::create(1.0f, Vec2(0.0f, 384.0f)), NULL))); auto sprite_b = LayerColor::create(Color4B(0, 0, 255, 255), 400, 400); - sprite_b->setAnchorPoint(Vector2(0.5f, 0.5f)); + sprite_b->setAnchorPoint(Vec2(0.5f, 0.5f)); sprite_b->ignoreAnchorPointForPosition(false); - sprite_b->setPosition(Vector2(s.width/2, s.height/2)); + sprite_b->setPosition(Vec2(s.width/2, s.height/2)); addChild(sprite_b); auto label = MenuItemLabel::create(Label::createWithSystemFont("Flip Me", "Helvetica", 24), CC_CALLBACK_1(Bug1159Layer::callBack, this) ); auto menu = Menu::create(label, NULL); - menu->setPosition(Vector2(s.width - 200.0f, 50.0f)); + menu->setPosition(Vec2(s.width - 200.0f, 50.0f)); addChild(menu); return true; diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-1174.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-1174.cpp index 70aca61a40..051607f2ce 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-1174.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-1174.cpp @@ -5,9 +5,9 @@ #include "Bug-1174.h" -int check_for_error( Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float s, float t ); +int check_for_error( Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float s, float t ); -int check_for_error( Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float s, float t ) +int check_for_error( Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float s, float t ) { // the hit point is p3 + t * (p4 - p3); // the hit point also is p1 + s * (p2 - p1); @@ -37,7 +37,7 @@ bool Bug1174Layer::init() // // seed // srand(0); - Vector2 A,B,C,D,p1,p2,p3,p4; + Vec2 A,B,C,D,p1,p2,p3,p4; float s,t; int err=0; @@ -73,11 +73,11 @@ bool Bug1174Layer::init() float cx = CCRANDOM_0_1() * -5000; float cy = CCRANDOM_0_1() * -5000; - A = Vector2(ax,ay); - B = Vector2(bx,by); - C = Vector2(cx,cy); - D = Vector2(dx,dy); - if( Vector2::isLineIntersect( A, D, B, C, &s, &t) ) { + A = Vec2(ax,ay); + B = Vec2(bx,by); + C = Vec2(cx,cy); + D = Vec2(dx,dy); + if( Vec2::isLineIntersect( A, D, B, C, &s, &t) ) { if( check_for_error(A, D, B, C, s, t) ) err++; else @@ -91,13 +91,13 @@ bool Bug1174Layer::init() // log("Test2 - Start"); - p1 = Vector2(220,480); - p2 = Vector2(304,325); - p3 = Vector2(264,416); - p4 = Vector2(186,416); + p1 = Vec2(220,480); + p2 = Vec2(304,325); + p3 = Vec2(264,416); + p4 = Vec2(186,416); s = 0.0f; t = 0.0f; - if( Vector2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) + if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) check_for_error(p1, p2, p3, p4, s,t ); log("Test2 - End"); @@ -117,14 +117,14 @@ bool Bug1174Layer::init() // c | d float ax = CCRANDOM_0_1() * -500; float ay = CCRANDOM_0_1() * 500; - p1 = Vector2(ax,ay); + p1 = Vec2(ax,ay); // a | b // ----- // c | D float dx = CCRANDOM_0_1() * 500; float dy = CCRANDOM_0_1() * -500; - p2 = Vector2(dx,dy); + p2 = Vec2(dx,dy); ////// @@ -135,17 +135,17 @@ bool Bug1174Layer::init() // ----- // C | d float cx = CCRANDOM_0_1() * -500; - p3 = Vector2(cx,y); + p3 = Vec2(cx,y); // a | B // ----- // c | d float bx = CCRANDOM_0_1() * 500; - p4 = Vector2(bx,y); + p4 = Vec2(bx,y); s = 0.0f; t = 0.0f; - if( Vector2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) { + if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) { if( check_for_error(p1, p2, p3, p4, s,t ) ) err++; else diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-350.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-350.cpp index 124da50dd6..e210c643b8 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-350.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-350.cpp @@ -11,7 +11,7 @@ bool Bug350Layer::init() { auto size = Director::getInstance()->getWinSize(); auto background = Sprite::create("Hello.png"); - background->setPosition(Vector2(size.width/2, size.height/2)); + background->setPosition(Vec2(size.width/2, size.height/2)); addChild(background); return true; } diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-422.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-422.cpp index 9d6c01f05a..70897f806d 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-422.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-422.cpp @@ -39,7 +39,7 @@ void Bug422Layer::reset() float x = CCRANDOM_0_1() * 50; float y = CCRANDOM_0_1() * 50; - menu->setPosition(menu->getPosition() + Vector2(x,y)); + menu->setPosition(menu->getPosition() + Vec2(x,y)); addChild(menu, 0, localtag); //[self check:self]; diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.cpp index 2c63d3dc68..46d61358cc 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.cpp @@ -30,7 +30,7 @@ bool Bug458Layer::init() auto sprite2 = MenuItemSprite::create(layer, layer2, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) ); auto menu = Menu::create(sprite, sprite2, NULL); menu->alignItemsVerticallyWithPadding(100); - menu->setPosition(Vector2(size.width / 2, size.height / 2)); + menu->setPosition(Vec2(size.width / 2, size.height / 2)); // add the label as a child to this Layer addChild(menu); diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp index 855444bbde..5924628790 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp @@ -19,7 +19,7 @@ bool QuestionContainerSprite::init() int width = size.width * 0.9f - (corner->getContentSize().width * 2); int height = size.height * 0.15f - (corner->getContentSize().height * 2); auto layer = LayerColor::create(Color4B(255, 255, 255, 255 * .75), width, height); - layer->setPosition(Vector2(-width / 2, -height / 2)); + layer->setPosition(Vec2(-width / 2, -height / 2)); //First button is blue, //Second is red @@ -36,46 +36,46 @@ bool QuestionContainerSprite::init() a++; addChild(layer); - corner->setPosition(Vector2(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2))); + corner->setPosition(Vec2(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2))); addChild(corner); auto corner2 = Sprite::create("Images/bugs/corner.png"); - corner2->setPosition(Vector2(-corner->getPosition().x, corner->getPosition().y)); + corner2->setPosition(Vec2(-corner->getPosition().x, corner->getPosition().y)); corner2->setFlippedX(true); addChild(corner2); auto corner3 = Sprite::create("Images/bugs/corner.png"); - corner3->setPosition(Vector2(corner->getPosition().x, -corner->getPosition().y)); + corner3->setPosition(Vec2(corner->getPosition().x, -corner->getPosition().y)); corner3->setFlippedY(true); addChild(corner3); auto corner4 = Sprite::create("Images/bugs/corner.png"); - corner4->setPosition(Vector2(corner2->getPosition().x, -corner2->getPosition().y)); + corner4->setPosition(Vec2(corner2->getPosition().x, -corner2->getPosition().y)); corner4->setFlippedX(true); corner4->setFlippedY(true); addChild(corner4); auto edge = Sprite::create("Images/bugs/edge.png"); edge->setScaleX(width); - edge->setPosition(Vector2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y)); + edge->setPosition(Vec2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y)); addChild(edge); auto edge2 = Sprite::create("Images/bugs/edge.png"); edge2->setScaleX(width); - edge2->setPosition(Vector2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y)); + edge2->setPosition(Vec2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y)); edge2->setFlippedY(true); addChild(edge2); auto edge3 = Sprite::create("Images/bugs/edge.png"); edge3->setRotation(90); edge3->setScaleX(height); - edge3->setPosition(Vector2(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); + edge3->setPosition(Vec2(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); addChild(edge3); auto edge4 = Sprite::create("Images/bugs/edge.png"); edge4->setRotation(270); edge4->setScaleX(height); - edge4->setPosition(Vector2(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); + edge4->setPosition(Vec2(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); addChild(edge4); addChild(label); diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-624.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-624.cpp index 074d7864eb..b7509953e6 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-624.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-624.cpp @@ -22,7 +22,7 @@ bool Bug624Layer::init() auto size = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("Layer1", "fonts/Marker Felt.ttf", 36.0f); - label->setPosition(Vector2(size.width/2, size.height/2)); + label->setPosition(Vec2(size.width/2, size.height/2)); addChild(label); Device::setAccelerometerEnabled(true); @@ -68,7 +68,7 @@ bool Bug624Layer2::init() auto size = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("Layer2", "fonts/Marker Felt.ttf", 36.0f); - label->setPosition(Vector2(size.width/2, size.height/2)); + label->setPosition(Vec2(size.width/2, size.height/2)); addChild(label); Device::setAccelerometerEnabled(true); diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-886.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-886.cpp index 58c1420c2f..23cae12f1b 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-886.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-886.cpp @@ -13,15 +13,15 @@ bool Bug886Layer::init() // auto size = [[Director sharedDirector] winSize]; auto sprite = Sprite::create("Images/bugs/bug886.jpg"); - sprite->setAnchorPoint(Vector2::ZERO); - sprite->setPosition(Vector2::ZERO); + sprite->setAnchorPoint(Vec2::ZERO); + sprite->setPosition(Vec2::ZERO); sprite->setScaleX(0.6f); addChild(sprite); auto sprite2 = Sprite::create("Images/bugs/bug886.png"); - sprite2->setAnchorPoint(Vector2::ZERO); + sprite2->setAnchorPoint(Vec2::ZERO); sprite2->setScaleX(0.6f); - sprite2->setPosition(Vector2(sprite->getContentSize().width * 0.6f + 10, 0)); + sprite2->setPosition(Vec2(sprite->getContentSize().width * 0.6f + 10, 0)); addChild(sprite2); return true; diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-899.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-899.cpp index 812e9e5861..80179ae490 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-899.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-899.cpp @@ -14,7 +14,7 @@ bool Bug899Layer::init() { auto bg = Sprite::create("Images/bugs/RetinaDisplay.jpg"); addChild(bg, 0); - bg->setAnchorPoint(Vector2::ZERO); + bg->setAnchorPoint(Vec2::ZERO); return true; } diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp index 83e3533c87..75c601d90f 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp @@ -42,8 +42,8 @@ bool Bug914Layer::init() { layer = LayerColor::create(Color4B(i*20, i*20, i*20,255)); layer->setContentSize(Size(i*100, i*100)); - layer->setPosition(Vector2(size.width/2, size.height/2)); - layer->setAnchorPoint(Vector2(0.5f, 0.5f)); + layer->setPosition(Vec2(size.width/2, size.height/2)); + layer->setAnchorPoint(Vec2(0.5f, 0.5f)); layer->ignoreAnchorPointForPosition(false); addChild(layer, -1-i); } @@ -54,11 +54,11 @@ bool Bug914Layer::init() auto menu = Menu::create(item1, NULL); menu->alignItemsVertically(); - menu->setPosition(Vector2(size.width/2, 100)); + menu->setPosition(Vec2(size.width/2, 100)); addChild(menu); // position the label on the center of the screen - label->setPosition(Vector2( size.width /2 , size.height/2 )); + label->setPosition(Vec2( size.width /2 , size.height/2 )); // add the label as a child to this Layer addChild(label); diff --git a/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp b/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp index 17c89890db..63ed76bcc5 100644 --- a/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp +++ b/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp @@ -26,7 +26,7 @@ enum kItemTagBasic = 5432, }; -static Vector2 s_tCurPos = Vector2::ZERO; +static Vec2 s_tCurPos = Vec2::ZERO; struct { const char *test_name; @@ -63,7 +63,7 @@ void BugsTestMainLayer::onEnter() for (int i = 0; i < g_maxitems; ++i) { auto pItem = MenuItemFont::create(g_bugs[i].test_name, g_bugs[i].callback); - pItem->setPosition(Vector2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); + pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itmeMenu->addChild(pItem, kItemTagBasic + i); } @@ -88,17 +88,17 @@ void BugsTestMainLayer::onTouchesMoved(const std::vector& touches, Event float nMoveY = touchLocation.y - _beginPos.y; auto curPos = _itmeMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); auto winSize = Director::getInstance()->getWinSize(); if (nextPos.y < 0.0f) { - _itmeMenu->setPosition(Vector2::ZERO); + _itmeMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_maxitems + 1)* LINE_SPACE - winSize.height)) { - _itmeMenu->setPosition(Vector2(0, ((g_maxitems + 1)* LINE_SPACE - winSize.height))); + _itmeMenu->setPosition(Vec2(0, ((g_maxitems + 1)* LINE_SPACE - winSize.height))); return; } @@ -119,9 +119,9 @@ void BugsTestBaseLayer::onEnter() MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(24); auto pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(BugsTestBaseLayer::backCallback, this)); - pMainItem->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + pMainItem->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menu = Menu::create(pMainItem, NULL); - menu->setPosition( Vector2::ZERO ); + menu->setPosition( Vec2::ZERO ); addChild(menu); } diff --git a/tests/cpp-tests/Classes/BugsTest/BugsTest.h b/tests/cpp-tests/Classes/BugsTest/BugsTest.h index e23f25155b..4ec70a54c6 100644 --- a/tests/cpp-tests/Classes/BugsTest/BugsTest.h +++ b/tests/cpp-tests/Classes/BugsTest/BugsTest.h @@ -12,7 +12,7 @@ public: void onTouchesMoved(const std::vector&touches, Event *event); protected: - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itmeMenu; }; diff --git a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp index d1267f5cbb..6db9ab2492 100644 --- a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -32,7 +32,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() // title auto label = Label::createWithTTF("Multi touch the screen", "fonts/Marker Felt.ttf", 36.0f); - label->setPosition(cocos2d::Vector2( VisibleRect::center().x, VisibleRect::top().y - 30)); + label->setPosition(cocos2d::Vec2( VisibleRect::center().x, VisibleRect::top().y - 30)); this->addChild(label, -1); // reset button @@ -52,7 +52,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() #endif addChild(parent, 0, kTagParentNode); - addNewSpriteAtPosition(cocos2d::Vector2(200,200)); + addNewSpriteAtPosition(cocos2d::Vec2(200,200)); // menu for debug layer MenuItemFont::setFontSize(18); @@ -60,7 +60,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() auto menu = Menu::create(item, NULL); this->addChild(menu); - menu->setPosition(cocos2d::Vector2(VisibleRect::right().x-100, VisibleRect::top().y-60)); + menu->setPosition(cocos2d::Vec2(VisibleRect::right().x-100, VisibleRect::top().y-60)); scheduleUpdate(); #else @@ -68,7 +68,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() "fonts/arial.ttf", 18); auto size = Director::getInstance()->getWinSize(); - label->setPosition(Vector2(size.width/2, size.height/2)); + label->setPosition(Vec2(size.width/2, size.height/2)); addChild(label); @@ -160,7 +160,7 @@ void ChipmunkTestLayer::createResetButton() auto menu = Menu::create(reset, NULL); - menu->setPosition(cocos2d::Vector2(VisibleRect::center().x, VisibleRect::bottom().y + 30)); + menu->setPosition(cocos2d::Vec2(VisibleRect::center().x, VisibleRect::bottom().y + 30)); this->addChild(menu, -1); } @@ -174,7 +174,7 @@ void ChipmunkTestLayer::reset(Ref* sender) s->release(); } -void ChipmunkTestLayer::addNewSpriteAtPosition(cocos2d::Vector2 pos) +void ChipmunkTestLayer::addNewSpriteAtPosition(cocos2d::Vec2 pos) { #if CC_ENABLE_CHIPMUNK_INTEGRATION int posx, posy; @@ -242,7 +242,7 @@ void ChipmunkTestLayer::onAcceleration(Acceleration* acc, Event* event) prevX = accelX; prevY = accelY; - auto v = cocos2d::Vector2( accelX, accelY); + auto v = cocos2d::Vec2( accelX, accelY); v = v * 200; _space->gravity = cpv(v.x, v.y); } diff --git a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.h b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.h index eebc2ccba7..3d9a8c589a 100644 --- a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.h +++ b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.h @@ -21,7 +21,7 @@ public: void createResetButton(); void reset(Ref* sender); - void addNewSpriteAtPosition(cocos2d::Vector2 p); + void addNewSpriteAtPosition(cocos2d::Vec2 p); void update(float dt); void toggleDebugCallback(Ref* sender); void onTouchesEnded(const std::vector& touches, Event* event); diff --git a/tests/cpp-tests/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp b/tests/cpp-tests/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp index 1dc6cddc1d..aadceb2063 100644 --- a/tests/cpp-tests/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp +++ b/tests/cpp-tests/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp @@ -28,9 +28,9 @@ MainLayer::MainLayer() addChild(layer, -1); addChild(sprite, 0, kTagSprite); - sprite->setPosition( Vector2(20,150) ); + sprite->setPosition( Vec2(20,150) ); - sprite->runAction( JumpTo::create(4, Vector2(300,48), 100, 4) ); + sprite->runAction( JumpTo::create(4, Vec2(300,48), 100, 4) ); layer->runAction( RepeatForever::create( Sequence::create( @@ -51,7 +51,7 @@ void MainLayer::onTouchEnded(Touch* touch, Event *event) auto s = getChildByTag(kTagSprite); s->stopAllActions(); - s->runAction( MoveTo::create(1, Vector2(location.x, location.y) ) ); + s->runAction( MoveTo::create(1, Vec2(location.x, location.y) ) ); float o = location.x - s->getPosition().x; float a = location.y - s->getPosition().y; float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) ); diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 27fcede20a..c6ca186378 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -75,8 +75,8 @@ bool BaseClippingNodeTest::init() if (BaseTest::init()) { auto background = Sprite::create(s_back3); - background->setAnchorPoint( Vector2::ZERO ); - background->setPosition( Vector2::ZERO ); + background->setAnchorPoint( Vec2::ZERO ); + background->setPosition( Vec2::ZERO ); this->addChild(background, -1); this->setup(); @@ -148,17 +148,17 @@ void BasicTest::setup() auto stencil = this->stencil(); stencil->setTag( kTagStencilNode ); - stencil->setPosition( Vector2(50, 50) ); + stencil->setPosition( Vec2(50, 50) ); auto clipper = this->clipper(); clipper->setTag( kTagClipperNode ); - clipper->setAnchorPoint(Vector2(0.5, 0.5)); - clipper->setPosition( Vector2(s.width / 2 - 50, s.height / 2 - 50) ); + clipper->setAnchorPoint(Vec2(0.5, 0.5)); + clipper->setPosition( Vec2(s.width / 2 - 50, s.height / 2 - 50) ); clipper->setStencil(stencil); this->addChild(clipper); auto content = this->content(); - content->setPosition( Vector2(50, 50) ); + content->setPosition( Vec2(50, 50) ); clipper->addChild(content); } @@ -176,10 +176,10 @@ Action* BasicTest::actionScale() DrawNode* BasicTest::shape() { auto shape = DrawNode::create(); - static Vector2 triangle[3]; - triangle[0] = Vector2(-100, -100); - triangle[1] = Vector2(100, -100); - triangle[2] = Vector2(0, 100); + static Vec2 triangle[3]; + triangle[0] = Vec2(-100, -100); + triangle[1] = Vec2(100, -100); + triangle[2] = Vec2(0, 100); static Color4F green(0, 1, 0, 1); shape->drawPolygon(triangle, 3, green, 0, green); @@ -351,16 +351,16 @@ void NestedTest::setup() auto clipper = ClippingNode::create(); clipper->setContentSize(Size(size, size)); - clipper->setAnchorPoint(Vector2(0.5, 0.5)); - clipper->setPosition( Vector2(parent->getContentSize().width / 2, parent->getContentSize().height / 2) ); + clipper->setAnchorPoint(Vec2(0.5, 0.5)); + clipper->setPosition( Vec2(parent->getContentSize().width / 2, parent->getContentSize().height / 2) ); clipper->setAlphaThreshold(0.05f); clipper->runAction(RepeatForever::create(RotateBy::create(i % 3 ? 1.33 : 1.66, i % 2 ? 90 : -90))); parent->addChild(clipper); auto stencil = Sprite::create(s_pathGrossini); stencil->setScale( 2.5 - (i * (2.5 / depth)) ); - stencil->setAnchorPoint( Vector2(0.5, 0.5) ); - stencil->setPosition( Vector2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); + stencil->setAnchorPoint( Vec2(0.5, 0.5) ); + stencil->setPosition( Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); stencil->setVisible(false); stencil->runAction(Sequence::createWithTwoActions(DelayTime::create(i), Show::create())); clipper->setStencil(stencil); @@ -394,7 +394,7 @@ std::string HoleDemo::subtitle() const void HoleDemo::setup() { auto target = Sprite::create(s_pathBlock); - target->setAnchorPoint(Vector2::ZERO); + target->setAnchorPoint(Vec2::ZERO); target->setScale(3); _outerClipper = ClippingNode::create(); @@ -403,8 +403,8 @@ void HoleDemo::setup() tranform = AffineTransformScale(tranform, target->getScale(), target->getScale()); _outerClipper->setContentSize( SizeApplyAffineTransform(target->getContentSize(), tranform)); - _outerClipper->setAnchorPoint( Vector2(0.5, 0.5) ); - _outerClipper->setPosition(Vector2(this->getContentSize()) * 0.5f); + _outerClipper->setAnchorPoint( Vec2(0.5, 0.5) ); + _outerClipper->setPosition(Vec2(this->getContentSize()) * 0.5f); _outerClipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); _outerClipper->setStencil( target ); @@ -434,7 +434,7 @@ void HoleDemo::setup() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); } -void HoleDemo::pokeHoleAtPoint(Vector2 point) +void HoleDemo::pokeHoleAtPoint(Vec2 point) { float scale = CCRANDOM_0_1() * 0.2 + 0.9; float rotation = CCRANDOM_0_1() * 360; @@ -461,7 +461,7 @@ void HoleDemo::pokeHoleAtPoint(Vector2 point) void HoleDemo::onTouchesBegan(const std::vector& touches, Event* event) { Touch *touch = (Touch *)touches[0]; - Vector2 point = _outerClipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); + Vec2 point = _outerClipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); auto rect = Rect(0, 0, _outerClipper->getContentSize().width, _outerClipper->getContentSize().height); if (!rect.containsPoint(point)) return; this->pokeHoleAtPoint(point); @@ -484,17 +484,17 @@ void ScrollViewDemo::setup() auto clipper = ClippingNode::create(); clipper->setTag( kTagClipperNode ); clipper->setContentSize( Size(200, 200) ); - clipper->setAnchorPoint( Vector2(0.5, 0.5) ); - clipper->setPosition( Vector2(this->getContentSize().width / 2, this->getContentSize().height / 2) ); + clipper->setAnchorPoint( Vec2(0.5, 0.5) ); + clipper->setPosition( Vec2(this->getContentSize().width / 2, this->getContentSize().height / 2) ); clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); this->addChild(clipper); auto stencil = DrawNode::create(); - Vector2 rectangle[4]; - rectangle[0] = Vector2(0, 0); - rectangle[1] = Vector2(clipper->getContentSize().width, 0); - rectangle[2] = Vector2(clipper->getContentSize().width, clipper->getContentSize().height); - rectangle[3] = Vector2(0, clipper->getContentSize().height); + Vec2 rectangle[4]; + rectangle[0] = Vec2(0, 0); + rectangle[1] = Vec2(clipper->getContentSize().width, 0); + rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height); + rectangle[3] = Vec2(0, clipper->getContentSize().height); Color4F white(1, 1, 1, 1); stencil->drawPolygon(rectangle, 4, white, 1, white); @@ -502,8 +502,8 @@ void ScrollViewDemo::setup() auto content = Sprite::create(s_back2); content->setTag( kTagContentNode ); - content->setAnchorPoint( Vector2(0.5, 0.5) ); - content->setPosition( Vector2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); + content->setAnchorPoint( Vec2(0.5, 0.5) ); + content->setPosition( Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); clipper->addChild(content); _scrolling = false; @@ -519,7 +519,7 @@ void ScrollViewDemo::onTouchesBegan(const std::vector& touches, Event * { Touch *touch = touches[0]; auto clipper = this->getChildByTag(kTagClipperNode); - Vector2 point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); + Vec2 point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); auto rect = Rect(0, 0, clipper->getContentSize().width, clipper->getContentSize().height); _scrolling = rect.containsPoint(point); _lastPoint = point; @@ -531,7 +531,7 @@ void ScrollViewDemo::onTouchesMoved(const std::vector& touches, Event * Touch *touch = touches[0]; auto clipper = this->getChildByTag(kTagClipperNode); auto point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); - Vector2 diff = point - _lastPoint; + Vec2 diff = point - _lastPoint; auto content = clipper->getChildByTag(kTagContentNode); content->setPosition(content->getPosition() + diff); _lastPoint = point; @@ -588,12 +588,12 @@ void RawStencilBufferTest::setup() for(int i = 0; i < _planeCount; ++i) { Sprite* sprite = Sprite::create(s_pathGrossini); - sprite->setAnchorPoint( Vector2(0.5, 0) ); + sprite->setAnchorPoint( Vec2(0.5, 0) ); sprite->setScale( 2.5f ); _sprites.pushBack(sprite); Sprite* sprite2 = Sprite::create(s_pathGrossini); - sprite2->setAnchorPoint( Vector2(0.5, 0) ); + sprite2->setAnchorPoint( Vec2(0.5, 0) ); sprite2->setScale( 2.5f ); _spritesStencil.pushBack(sprite2); } @@ -601,9 +601,9 @@ void RawStencilBufferTest::setup() Director::getInstance()->setAlphaBlending(true); } -void RawStencilBufferTest::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { - auto winPoint = Vector2(Director::getInstance()->getWinSize()); + auto winPoint = Vec2(Director::getInstance()->getWinSize()); auto planeSize = winPoint * (1.0 / _planeCount); @@ -672,19 +672,19 @@ void RawStencilBufferTest::onDisableStencil() CHECK_GL_ERROR_DEBUG(); } -void RawStencilBufferTest::onBeforeDrawClip(int planeIndex, const Vector2& pt) +void RawStencilBufferTest::onBeforeDrawClip(int planeIndex, const Vec2& pt) { this->setupStencilForClippingOnPlane(planeIndex); CHECK_GL_ERROR_DEBUG(); - DrawPrimitives::drawSolidRect(Vector2::ZERO, pt, Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Vec2::ZERO, pt, Color4F(1, 1, 1, 1)); } -void RawStencilBufferTest::onBeforeDrawSprite(int planeIndex, const Vector2& pt) +void RawStencilBufferTest::onBeforeDrawSprite(int planeIndex, const Vec2& pt) { this->setupStencilForDrawingOnPlane(planeIndex); CHECK_GL_ERROR_DEBUG(); - DrawPrimitives::drawSolidRect(Vector2::ZERO, pt, _planeColor[planeIndex]); + DrawPrimitives::drawSolidRect(Vec2::ZERO, pt, _planeColor[planeIndex]); } void RawStencilBufferTest::setupStencilForClippingOnPlane(GLint plane) @@ -831,7 +831,7 @@ void RawStencilBufferTest6::setup() { RawStencilBufferTestAlphaTest::setup(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - auto winPoint = Vector2(Director::getInstance()->getWinSize()); + auto winPoint = Vec2(Director::getInstance()->getWinSize()); //by default, glReadPixels will pack data with 4 bytes allignment unsigned char bits[4] = {0,0,0,0}; glStencilMask(~0); @@ -840,7 +840,7 @@ void RawStencilBufferTest6::setup() glFlush(); glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &bits); auto clearToZeroLabel = Label::createWithTTF(String::createWithFormat("00=%02x", bits[0])->getCString(), "fonts/arial.ttf", 20); - clearToZeroLabel->setPosition( Vector2((winPoint.x / 3) * 1, winPoint.y - 10) ); + clearToZeroLabel->setPosition( Vec2((winPoint.x / 3) * 1, winPoint.y - 10) ); this->addChild(clearToZeroLabel); glStencilMask(0x0F); glClearStencil(0xAA); @@ -848,7 +848,7 @@ void RawStencilBufferTest6::setup() glFlush(); glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &bits); auto clearToMaskLabel = Label::createWithTTF(String::createWithFormat("0a=%02x", bits[0])->getCString(), "fonts/arial.ttf", 20); - clearToMaskLabel->setPosition( Vector2((winPoint.x / 3) * 2, winPoint.y - 10) ); + clearToMaskLabel->setPosition( Vec2((winPoint.x / 3) * 2, winPoint.y - 10) ); this->addChild(clearToMaskLabel); #endif glStencilMask(~0); @@ -860,7 +860,7 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) glStencilMask(planeMask); glStencilFunc(GL_NEVER, 0, planeMask); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); - DrawPrimitives::drawSolidRect(Vector2::ZERO, Vector2(Director::getInstance()->getWinSize()), Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Vec2::ZERO, Vec2(Director::getInstance()->getWinSize()), Color4F(1, 1, 1, 1)); glStencilFunc(GL_NEVER, planeMask, planeMask); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); glDisable(GL_DEPTH_TEST); diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h index f5b7dcbb8a..df93852059 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -117,7 +117,7 @@ public: virtual void setup(); virtual std::string title() const override; virtual std::string subtitle() const override; - void pokeHoleAtPoint(Vector2 point); + void pokeHoleAtPoint(Vec2 point); void onTouchesBegan(const std::vector& touches, Event *event); private: ClippingNode* _outerClipper; @@ -138,7 +138,7 @@ public: void onTouchesEnded(const std::vector& touches, Event *event); private: bool _scrolling; - Vector2 _lastPoint; + Vec2 _lastPoint; }; //#if COCOS2D_DEBUG > 1 @@ -153,7 +153,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void setup(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual void setupStencilForClippingOnPlane(GLint plane); virtual void setupStencilForDrawingOnPlane(GLint plane); @@ -162,8 +162,8 @@ protected: std::list _renderCmds; void onEnableStencil(); void onDisableStencil(); - void onBeforeDrawClip(int planeIndex, const Vector2& pt); - void onBeforeDrawSprite(int planeIndex, const Vector2& pt); + void onBeforeDrawClip(int planeIndex, const Vec2& pt); + void onBeforeDrawSprite(int planeIndex, const Vec2& pt); protected: Vector _sprites; Vector _spritesStencil; diff --git a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 8c856ce437..7e81abb0db 100644 --- a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -174,9 +174,9 @@ public: _lblMinValue = Label::createWithTTF(buffer, "fonts/arial.ttf", 8); addChild(_lblMinValue); if (_direction == Vertical) - _lblMinValue->setPosition(Vector2(12.0, -50.0)); + _lblMinValue->setPosition(Vec2(12.0, -50.0)); else - _lblMinValue->setPosition(Vector2(-50, 12.0)); + _lblMinValue->setPosition(Vec2(-50, 12.0)); } else { _lblMinValue->setString(buffer); } @@ -186,9 +186,9 @@ public: _lblMaxValue = Label::createWithTTF(buffer, "fonts/arial.ttf", 8); addChild(_lblMaxValue); if (_direction == Vertical) - _lblMaxValue->setPosition(Vector2(12.0, 50.0)); + _lblMaxValue->setPosition(Vec2(12.0, 50.0)); else - _lblMaxValue->setPosition(Vector2(50, 12.0)); + _lblMaxValue->setPosition(Vec2(50, 12.0)); } else { _lblMaxValue->setString(buffer); } @@ -397,7 +397,7 @@ void CocosDenshionTest::addSliders() void CocosDenshionTest::addChildAt(Node *node, float percentageX, float percentageY) { const Size size = VisibleRect::getVisibleRect().size; - node->setPosition(Vector2(percentageX * size.width, percentageY * size.height)); + node->setPosition(Vec2(percentageX * size.width, percentageY * size.height)); addChild(node); } diff --git a/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp b/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp index 7a3f9d4803..0da3d1df6d 100644 --- a/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp +++ b/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp @@ -7,7 +7,7 @@ CurlTest::CurlTest() { auto label = Label::createWithTTF("Curl Test", "fonts/arial.ttf", 28); addChild(label, 0); - label->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y-50) ); + label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y-50) ); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(CurlTest::onTouchesEnded, this); diff --git a/tests/cpp-tests/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp b/tests/cpp-tests/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp index ba32ed421e..24e8047356 100644 --- a/tests/cpp-tests/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp +++ b/tests/cpp-tests/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp @@ -4,7 +4,7 @@ CurrentLanguageTest::CurrentLanguageTest() { auto label = Label::createWithTTF("Current language Test", "fonts/arial.ttf", 28); addChild(label, 0); - label->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y-50) ); + label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y-50) ); auto labelLanguage = Label::createWithTTF("", "fonts/arial.ttf", 20); labelLanguage->setPosition(VisibleRect::center()); diff --git a/tests/cpp-tests/Classes/DataVisitorTest/DataVisitorTest.cpp b/tests/cpp-tests/Classes/DataVisitorTest/DataVisitorTest.cpp index 0af7397268..00d2b7b044 100644 --- a/tests/cpp-tests/Classes/DataVisitorTest/DataVisitorTest.cpp +++ b/tests/cpp-tests/Classes/DataVisitorTest/DataVisitorTest.cpp @@ -21,11 +21,11 @@ void PrettyPrinterDemo::addSprite() auto s4 = Sprite::create("Images/grossini_dance_03.png"); auto s5 = Sprite::create("Images/grossini_dance_04.png"); - s1->setPosition(Vector2(50, 50)); - s2->setPosition(Vector2(60, 50)); - s3->setPosition(Vector2(70, 50)); - s4->setPosition(Vector2(80, 50)); - s5->setPosition(Vector2(90, 50)); + s1->setPosition(Vec2(50, 50)); + s2->setPosition(Vec2(60, 50)); + s3->setPosition(Vec2(70, 50)); + s4->setPosition(Vec2(80, 50)); + s5->setPosition(Vec2(90, 50)); this->addChild(s1); this->addChild(s2); @@ -40,14 +40,14 @@ void PrettyPrinterDemo::onEnter() auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 28); - label->setPosition( Vector2(s.width/2, s.height * 4/5) ); + label->setPosition( Vec2(s.width/2, s.height * 4/5) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { auto subLabel = Label::createWithTTF(strSubtitle.c_str(), "fonts/Thonburi.ttf", 16); - subLabel->setPosition( Vector2(s.width/2, s.height * 3/5) ); + subLabel->setPosition( Vec2(s.width/2, s.height * 3/5) ); this->addChild(subLabel, 1); } diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 4e5e4a100c..5687d00818 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -114,14 +114,14 @@ DrawPrimitivesTest::DrawPrimitivesTest() { } -void DrawPrimitivesTest::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void DrawPrimitivesTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated) +void DrawPrimitivesTest::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -165,7 +165,7 @@ void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated) CHECK_GL_ERROR_DEBUG(); // draw 4 small points - Vector2 points[] = { Vector2(60,60), Vector2(70,70), Vector2(60,70), Vector2(70,60) }; + Vec2 points[] = { Vec2(60,60), Vec2(70,70), Vec2(60,70), Vec2(70,60) }; DrawPrimitives::setPointSize(4); DrawPrimitives::setDrawColor4B(0,255,255,255); DrawPrimitives::drawPoints( points, 4); @@ -189,28 +189,28 @@ void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated) // draw a pink solid circle with 50 segments glLineWidth(2); DrawPrimitives::setDrawColor4B(255, 0, 255, 255); - DrawPrimitives::drawSolidCircle( VisibleRect::center() + Vector2(140,0), 40, CC_DEGREES_TO_RADIANS(90), 50, 1.0f, 1.0f); + DrawPrimitives::drawSolidCircle( VisibleRect::center() + Vec2(140,0), 40, CC_DEGREES_TO_RADIANS(90), 50, 1.0f, 1.0f); CHECK_GL_ERROR_DEBUG(); // open yellow poly DrawPrimitives::setDrawColor4B(255, 255, 0, 255); glLineWidth(10); - Vector2 vertices[] = { Vector2(0,0), Vector2(50,50), Vector2(100,50), Vector2(100,100), Vector2(50,100) }; + Vec2 vertices[] = { Vec2(0,0), Vec2(50,50), Vec2(100,50), Vec2(100,100), Vec2(50,100) }; DrawPrimitives::drawPoly( vertices, 5, false); CHECK_GL_ERROR_DEBUG(); // filled poly glLineWidth(1); - Vector2 filledVertices[] = { Vector2(0,120), Vector2(50,120), Vector2(50,170), Vector2(25,200), Vector2(0,170) }; + Vec2 filledVertices[] = { Vec2(0,120), Vec2(50,120), Vec2(50,170), Vec2(25,200), Vec2(0,170) }; DrawPrimitives::drawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) ); // closed purble poly DrawPrimitives::setDrawColor4B(255, 0, 255, 255); glLineWidth(2); - Vector2 vertices2[] = { Vector2(30,130), Vector2(30,230), Vector2(50,200) }; + Vec2 vertices2[] = { Vec2(30,130), Vec2(30,230), Vec2(50,200) }; DrawPrimitives::drawPoly( vertices2, 3, true); CHECK_GL_ERROR_DEBUG(); @@ -221,12 +221,12 @@ void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated) CHECK_GL_ERROR_DEBUG(); // draw cubic bezier path - DrawPrimitives::drawCubicBezier(VisibleRect::center(), Vector2(VisibleRect::center().x+30,VisibleRect::center().y+50), Vector2(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100); + DrawPrimitives::drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x+30,VisibleRect::center().y+50), Vec2(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100); CHECK_GL_ERROR_DEBUG(); //draw a solid polygon - Vector2 vertices3[] = {Vector2(60,160), Vector2(70,190), Vector2(100,190), Vector2(90,160)}; + Vec2 vertices3[] = {Vec2(60,160), Vec2(70,190), Vec2(100,190), Vec2(90,160)}; DrawPrimitives::drawSolidPoly( vertices3, 4, Color4F(1,1,0,1) ); // restore original values @@ -261,11 +261,11 @@ DrawNodeTest::DrawNodeTest() // Draw 10 circles for( int i=0; i < 10; i++) { - draw->drawDot(Vector2(s.width/2, s.height/2), 10*(10-i), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + draw->drawDot(Vec2(s.width/2, s.height/2), 10*(10-i), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); } // Draw polygons - Vector2 points[] = { Vector2(s.height/4,0), Vector2(s.width,s.height/5), Vector2(s.width/3*2,s.height) }; + Vec2 points[] = { Vec2(s.height/4,0), Vec2(s.width,s.height/5), Vec2(s.width/3*2,s.height) }; draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), Color4F(1,0,0,0.5), 4, Color4F(0,0,1,1)); // star poly (triggers buggs) @@ -273,9 +273,9 @@ DrawNodeTest::DrawNodeTest() const float o=80; const float w=20; const float h=50; - Vector2 star[] = { - Vector2(o+w,o-h), Vector2(o+w*2, o), // lower spike - Vector2(o + w*2 + h, o+w ), Vector2(o + w*2, o+w*2), // right spike + Vec2 star[] = { + Vec2(o+w,o-h), Vec2(o+w*2, o), // lower spike + Vec2(o + w*2 + h, o+w ), Vec2(o + w*2, o+w*2), // right spike // {o +w, o+w*2+h}, {o,o+w*2}, // top spike // {o -h, o+w}, {o,o}, // left spike }; @@ -288,11 +288,11 @@ DrawNodeTest::DrawNodeTest() const float o=180; const float w=20; const float h=50; - Vector2 star[] = { - Vector2(o,o), Vector2(o+w,o-h), Vector2(o+w*2, o), // lower spike - Vector2(o + w*2 + h, o+w ), Vector2(o + w*2, o+w*2), // right spike - Vector2(o +w, o+w*2+h), Vector2(o,o+w*2), // top spike - Vector2(o -h, o+w), // left spike + Vec2 star[] = { + Vec2(o,o), Vec2(o+w,o-h), Vec2(o+w*2, o), // lower spike + Vec2(o + w*2 + h, o+w ), Vec2(o + w*2, o+w*2), // right spike + Vec2(o +w, o+w*2+h), Vec2(o,o+w*2), // top spike + Vec2(o -h, o+w), // left spike }; draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1)); @@ -300,17 +300,17 @@ DrawNodeTest::DrawNodeTest() // Draw segment - draw->drawSegment(Vector2(20,s.height), Vector2(20,s.height/2), 10, Color4F(0, 1, 0, 1)); + draw->drawSegment(Vec2(20,s.height), Vec2(20,s.height/2), 10, Color4F(0, 1, 0, 1)); - draw->drawSegment(Vector2(10,s.height/2), Vector2(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5)); + draw->drawSegment(Vec2(10,s.height/2), Vec2(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5)); // Draw triangle - draw->drawTriangle(Vector2(10, 10), Vector2(70, 30), Vector2(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawTriangle(Vec2(10, 10), Vec2(70, 30), Vec2(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); // Draw some beziers - draw->drawQuadraticBezier(Vector2(s.width - 150, s.height - 150), Vector2(s.width - 70, s.height - 10), Vector2(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawQuadraticBezier(Vec2(s.width - 150, s.height - 150), Vec2(s.width - 70, s.height - 10), Vec2(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); - draw->drawCubicBezier(Vector2(s.width - 250, 40), Vector2(s.width - 70, 100), Vector2(s.width - 30, 250), Vector2(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawCubicBezier(Vec2(s.width - 250, 40), Vec2(s.width - 70, 100), Vec2(s.width - 30, 250), Vec2(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); } string DrawNodeTest::title() const diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h index 0e1980f05f..a5c0041204 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h @@ -27,10 +27,10 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); CustomCommand _customCommand; }; diff --git a/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 7af5898df7..f6b936ac1a 100644 --- a/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -28,7 +28,7 @@ void Effect1::onEnter() // Waves3D is Grid3D and it's size is (15,10) auto size = Director::getInstance()->getWinSize(); - auto lens = Lens3D::create(0.0f, Size(15,10), Vector2(size.width/2,size.height/2), 240); + auto lens = Lens3D::create(0.0f, Size(15,10), Vec2(size.width/2,size.height/2), 240); auto waves = Waves3D::create(10, Size(15,10), 18, 15); auto reuse = ReuseGrid::create(1); @@ -106,7 +106,7 @@ void Effect3::onEnter() _target2->runAction( RepeatForever::create( shaky ) ); // moving background. Testing issue #244 - auto move = MoveBy::create(3, Vector2(200,0) ); + auto move = MoveBy::create(3, Vec2(200,0) ); _bgNode->runAction(RepeatForever::create( Sequence::create(move, move->reverse(), NULL) )); } @@ -125,12 +125,12 @@ std::string Effect3::title() const class Lens3DTarget : public Node { public: - virtual void setPosition(const Vector2& var) + virtual void setPosition(const Vec2& var) { _lens3D->setPosition(var); } - virtual const Vector2& getPosition() const + virtual const Vec2& getPosition() const { return _lens3D->getPosition(); } @@ -156,8 +156,8 @@ void Effect4::onEnter() EffectAdvanceTextLayer::onEnter(); //Node* gridNode = NodeGrid::create(); - auto lens = Lens3D::create(10, Size(32,24), Vector2(100,180), 150); - auto move = JumpBy::create(5, Vector2(380,0), 100, 4); + auto lens = Lens3D::create(10, Size(32,24), Vec2(100,180), 150); + auto move = JumpBy::create(5, Vec2(380,0), 100, 4); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); @@ -238,7 +238,7 @@ void Issue631::onEnter() auto layer = LayerColor::create( Color4B(255,0,0,255) ); addChild(layer, -10); auto sprite = Sprite::create("Images/grossini.png"); - sprite->setPosition( Vector2(50,80) ); + sprite->setPosition( Vec2(50,80) ); layer->addChild(sprite, 10); // foreground @@ -339,7 +339,7 @@ void EffectAdvanceTextLayer::onEnter(void) BaseTest::onEnter(); _bgNode = NodeGrid::create(); - _bgNode->setAnchorPoint(Vector2(0.5,0.5)); + _bgNode->setAnchorPoint(Vec2(0.5,0.5)); addChild(_bgNode); //_bgNode->setPosition( VisibleRect::center() ); auto bg = Sprite::create("Images/background3.png"); @@ -349,22 +349,22 @@ void EffectAdvanceTextLayer::onEnter(void) _bgNode->addChild(bg); _target1 = NodeGrid::create(); - _target1->setAnchorPoint(Vector2(0.5,0.5)); + _target1->setAnchorPoint(Vec2(0.5,0.5)); auto grossini = Sprite::create("Images/grossinis_sister2.png"); _target1->addChild(grossini); _bgNode->addChild(_target1); - _target1->setPosition( Vector2(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) ); + _target1->setPosition( Vec2(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) ); auto sc = ScaleBy::create(2, 5); auto sc_back = sc->reverse(); _target1->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); _target2 = NodeGrid::create(); - _target2->setAnchorPoint(Vector2(0.5,0.5)); + _target2->setAnchorPoint(Vec2(0.5,0.5)); auto tamara = Sprite::create("Images/grossinis_sister1.png"); _target2->addChild(tamara); _bgNode->addChild(_target2); - _target2->setPosition( Vector2(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); + _target2->setPosition( Vec2(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); auto sc2 = ScaleBy::create(2, 5); auto sc2_back = sc2->reverse(); _target2->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL) ) ); diff --git a/tests/cpp-tests/Classes/EffectsTest/EffectsTest.cpp b/tests/cpp-tests/Classes/EffectsTest/EffectsTest.cpp index ec12291ef7..4ef67521fe 100644 --- a/tests/cpp-tests/Classes/EffectsTest/EffectsTest.cpp +++ b/tests/cpp-tests/Classes/EffectsTest/EffectsTest.cpp @@ -86,7 +86,7 @@ public: static ActionInterval* create(float t) { auto size = Director::getInstance()->getWinSize(); - return Lens3D::create(t, Size(15,10), Vector2(size.width/2,size.height/2), 240); + return Lens3D::create(t, Size(15,10), Vec2(size.width/2,size.height/2), 240); } }; @@ -97,7 +97,7 @@ public: static ActionInterval* create(float t) { auto size = Director::getInstance()->getWinSize(); - return Ripple3D::create(t, Size(32,24), Vector2(size.width/2,size.height/2), 240, 4, 160); + return Ripple3D::create(t, Size(32,24), Vec2(size.width/2,size.height/2), 240, 4, 160); } }; @@ -128,7 +128,7 @@ public: static ActionInterval* create(float t) { auto size = Director::getInstance()->getWinSize(); - return Twirl::create(t, Size(12,8), Vector2(size.width/2, size.height/2), 1, 2.5f); + return Twirl::create(t, Size(12,8), Vec2(size.width/2, size.height/2), 1, 2.5f); } }; @@ -349,26 +349,26 @@ TextLayer::TextLayer(void) auto bg = Sprite::create(s_back3); _gridNodeTarget->addChild(bg, 0); -// bg->setAnchorPoint( Vector2::ZERO ); +// bg->setAnchorPoint( Vec2::ZERO ); bg->setPosition(VisibleRect::center()); auto grossini = Sprite::create(s_pathSister2); _gridNodeTarget->addChild(grossini, 1); - grossini->setPosition( Vector2(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); + grossini->setPosition( Vec2(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); auto sc = ScaleBy::create(2, 5); auto sc_back = sc->reverse(); grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); auto tamara = Sprite::create(s_pathSister1); _gridNodeTarget->addChild(tamara, 1); - tamara->setPosition( Vector2(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); + tamara->setPosition( Vec2(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); auto sc2 = ScaleBy::create(2, 5); auto sc2_back = sc2->reverse(); tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL)) ); auto label = Label::createWithTTF((effectsList[actionIdx]).c_str(), "fonts/Marker Felt.ttf", 32); - label->setPosition( Vector2(VisibleRect::center().x,VisibleRect::top().y-80) ); + label->setPosition( Vec2(VisibleRect::center().x,VisibleRect::top().y-80) ); addChild(label); label->setTag( kTagLabel ); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index ee8705c9e2..03c7d031a1 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -160,7 +160,7 @@ void ArmatureTestLayer::onEnter() auto label = Label::createWithTTF(pTitle, "fonts/arial.ttf", 18); label->setColor(Color3B::BLACK); addChild(label, 1, 10000); - label->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 30) ); + label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) @@ -168,7 +168,7 @@ void ArmatureTestLayer::onEnter() auto l = Label::createWithTTF(strSubtitle.c_str(), "fonts/arial.ttf", 18); l->setColor(Color3B::BLACK); addChild(l, 1, 10001); - l->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 60) ); + l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) ); } // add menu @@ -178,10 +178,10 @@ void ArmatureTestLayer::onEnter() Menu *menu = Menu::create(backItem, restartItem, nextItem, nullptr); - menu->setPosition(Vector2::ZERO); - backItem->setPosition(Vector2(VisibleRect::center().x - restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); - restartItem->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); - nextItem->setPosition(Vector2(VisibleRect::center().x + restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + menu->setPosition(Vec2::ZERO); + backItem->setPosition(Vec2(VisibleRect::center().x - restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + restartItem->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + nextItem->setPosition(Vec2(VisibleRect::center().x + restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); addChild(menu, 100); @@ -303,7 +303,7 @@ void TestDirectLoading::onEnter() Armature *armature = Armature::create("bear"); armature->getAnimation()->playWithIndex(0); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y)); addChild(armature); } std::string TestDirectLoading::title() const @@ -320,7 +320,7 @@ void TestCSWithSkeleton::onEnter() armature->getAnimation()->playWithIndex(0); armature->setScale(0.2f); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); addChild(armature); } @@ -370,7 +370,7 @@ void TestPerformance::onEnter() Menu *menu = Menu::create(decrease, increase, nullptr); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height-100)); + menu->setPosition(Vec2(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height-100)); addChild(menu, 10000); armatureCount = frames = times = lastTimes = 0; @@ -468,7 +468,7 @@ void TestChangeZorder::onEnter() armature = Armature::create("Knight_f/Knight"); armature->getAnimation()->playWithIndex(0); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y - 100)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y - 100)); ++currentTag; armature->setScale(0.6f); addChild(armature, currentTag, currentTag); @@ -476,13 +476,13 @@ void TestChangeZorder::onEnter() armature = Armature::create("Cowboy"); armature->getAnimation()->playWithIndex(0); armature->setScale(0.24f); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y - 100)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y - 100)); ++currentTag; addChild(armature, currentTag, currentTag); armature = Armature::create("Dragon"); armature->getAnimation()->playWithIndex(0); - armature->setPosition(Vector2(VisibleRect::center().x , VisibleRect::center().y - 100)); + armature->setPosition(Vec2(VisibleRect::center().x , VisibleRect::center().y - 100)); ++currentTag; armature->setScale(0.6f); addChild(armature, currentTag, currentTag); @@ -516,7 +516,7 @@ void TestAnimationEvent::onEnter() armature->getAnimation()->play("Fire"); armature->setScaleX(-0.24f); armature->setScaleY(0.24f); - armature->setPosition(Vector2(VisibleRect::left().x + 50, VisibleRect::left().y)); + armature->setPosition(Vec2(VisibleRect::left().x + 50, VisibleRect::left().y)); /* * Set armature's movement event callback function @@ -535,14 +535,14 @@ void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType mo { if (movementID == "Fire") { - ActionInterval *actionToRight = MoveTo::create(2, Vector2(VisibleRect::right().x - 50, VisibleRect::right().y)); + ActionInterval *actionToRight = MoveTo::create(2, Vec2(VisibleRect::right().x - 50, VisibleRect::right().y)); armature->stopAllActions(); armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), nullptr)); armature->getAnimation()->play("Walk"); } else if (movementID == "FireMax") { - ActionInterval *actionToLeft = MoveTo::create(2, Vector2(VisibleRect::left().x + 50, VisibleRect::left().y)); + ActionInterval *actionToLeft = MoveTo::create(2, Vec2(VisibleRect::left().x + 50, VisibleRect::left().y)); armature->stopAllActions(); armature->runAction(Sequence::create(actionToLeft, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback2, this)), nullptr)); armature->getAnimation()->play("Walk"); @@ -571,7 +571,7 @@ void TestFrameEvent::onEnter() Armature *armature = Armature::create("HeroAnimation"); armature->getAnimation()->play("attack"); armature->getAnimation()->setSpeedScale(0.5); - armature->setPosition(Vector2(VisibleRect::center().x - 50, VisibleRect::center().y -100)); + armature->setPosition(Vec2(VisibleRect::center().x - 50, VisibleRect::center().y -100)); /* * Set armature's frame event callback function @@ -681,7 +681,7 @@ void TestUseMutiplePicture::onEnter() armature = Armature::create("Knight_f/Knight"); armature->getAnimation()->playWithIndex(0); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::left().y)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::left().y)); armature->setScale(1.2f); addChild(armature); @@ -701,7 +701,7 @@ void TestUseMutiplePicture::onEnter() // } auto l = Label::createWithTTF("This is a weapon!", "fonts/arial.ttf", 18); - l->setAnchorPoint(Vector2(0.2f, 0.5f)); + l->setAnchorPoint(Vec2(0.2f, 0.5f)); armature->getBone("weapon")->addDisplay(l, 7); } @@ -741,7 +741,7 @@ void TestColliderDetector::onEnter() armature->getAnimation()->setSpeedScale(0.2f); armature->setScaleX(-0.2f); armature->setScaleY(0.2f); - armature->setPosition(Vector2(VisibleRect::left().x + 70, VisibleRect::left().y)); + armature->setPosition(Vec2(VisibleRect::left().x + 70, VisibleRect::left().y)); /* * Set armature's frame event callback function @@ -754,7 +754,7 @@ void TestColliderDetector::onEnter() armature2->getAnimation()->play("Walk"); armature2->setScaleX(-0.2f); armature2->setScaleY(0.2f); - armature2->setPosition(Vector2(VisibleRect::right().x - 60, VisibleRect::left().y)); + armature2->setPosition(Vec2(VisibleRect::right().x - 60, VisibleRect::left().y)); addChild(armature2); #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT @@ -780,11 +780,11 @@ void TestColliderDetector::onFrameEvent(Bone *bone, const std::string& evt, int * frame event may be delay emit, so originFrameIndex may be different from currentFrameIndex. */ - Vector2 p = armature->getBone("Layer126")->getDisplayRenderNode()->convertToWorldSpaceAR(Vector2(0, 0)); - bullet->setPosition(Vector2(p.x + 60, p.y)); + Vec2 p = armature->getBone("Layer126")->getDisplayRenderNode()->convertToWorldSpaceAR(Vec2(0, 0)); + bullet->setPosition(Vec2(p.x + 60, p.y)); bullet->stopAllActions(); - bullet->runAction(CCMoveBy::create(1.5f, Vector2(350, 0))); + bullet->runAction(CCMoveBy::create(1.5f, Vec2(350, 0))); } @@ -842,7 +842,7 @@ void TestColliderDetector::onExit() ArmatureTestLayer::onExit(); } -void TestColliderDetector::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); Director* director = Director::getInstance(); @@ -909,7 +909,7 @@ void TestColliderDetector::initWorld() bullet->setB2Body(body); bullet->setPTMRatio(PT_RATIO); - bullet->setPosition( Vector2( -100, -100) ); + bullet->setPosition( Vec2( -100, -100) ); body = world->CreateBody(&bodyDef); armature2->setBody(body); @@ -1036,13 +1036,13 @@ void TestColliderDetector::update(float delta) for (const auto& object : bodyList) { ColliderBody *body = static_cast(object); - const std::vector &vertexList = body->getCalculatedVertexList(); + const std::vector &vertexList = body->getCalculatedVertexList(); float minx = 0, miny = 0, maxx = 0, maxy = 0; size_t length = vertexList.size(); for (size_t i = 0; iaddCommand(&_customCommand); } -void TestColliderDetector::onDraw(const Matrix &transform, bool transformUpdated) +void TestColliderDetector::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1106,7 +1106,7 @@ std::string TestBoundingBox::title() const { return "Test BoundingBox"; } -void TestBoundingBox::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TestBoundingBox::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this, transform, transformUpdated); @@ -1114,7 +1114,7 @@ void TestBoundingBox::draw(Renderer *renderer, const Matrix &transform, bool tra } -void TestBoundingBox::onDraw(const Matrix &transform, bool transformUpdated) +void TestBoundingBox::onDraw(const Mat4 &transform, bool transformUpdated) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -1122,7 +1122,7 @@ void TestBoundingBox::onDraw(const Matrix &transform, bool transformUpdated) rect = armature->getBoundingBox(); DrawPrimitives::setDrawColor4B(100, 100, 100, 255); - DrawPrimitives::drawRect(rect.origin, Vector2(rect.getMaxX(), rect.getMaxY())); + DrawPrimitives::drawRect(rect.origin, Vec2(rect.getMaxX(), rect.getMaxY())); } void TestAnchorPoint::onEnter() @@ -1138,11 +1138,11 @@ void TestAnchorPoint::onEnter() addChild(armature, 0, i); } - getChildByTag(0)->setAnchorPoint(Vector2(0, 0)); - getChildByTag(1)->setAnchorPoint(Vector2(0, 1)); - getChildByTag(2)->setAnchorPoint(Vector2(1, 0)); - getChildByTag(3)->setAnchorPoint(Vector2(1, 1)); - getChildByTag(4)->setAnchorPoint(Vector2(0.5, 0.5)); + getChildByTag(0)->setAnchorPoint(Vec2(0, 0)); + getChildByTag(1)->setAnchorPoint(Vec2(0, 1)); + getChildByTag(2)->setAnchorPoint(Vec2(1, 0)); + getChildByTag(3)->setAnchorPoint(Vec2(1, 1)); + getChildByTag(4)->setAnchorPoint(Vec2(0.5, 0.5)); } std::string TestAnchorPoint::title() const @@ -1247,7 +1247,7 @@ void Hero::changeMount(Armature *armature) bone->changeDisplayWithIndex(0, true); bone->setIgnoreMovementBoneData(true); - setPosition(Vector2(0,0)); + setPosition(Vec2(0,0)); //Change animation playWithIndex(1); @@ -1282,8 +1282,8 @@ void TestArmatureNesting2::onEnter() Menu* pMenu =Menu::create(pMenuItem, nullptr); - pMenu->setPosition( Vector2() ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 67, VisibleRect::bottom().y + 50) ); + pMenu->setPosition( Vec2() ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 67, VisibleRect::bottom().y + 50) ); addChild(pMenu, 2); @@ -1291,16 +1291,16 @@ void TestArmatureNesting2::onEnter() hero = Hero::create("hero"); hero->setLayer(this); hero->playWithIndex(0); - hero->setPosition(Vector2(VisibleRect::left().x + 20, VisibleRect::left().y)); + hero->setPosition(Vec2(VisibleRect::left().x + 20, VisibleRect::left().y)); addChild(hero); //Create 3 mount horse = createMount("horse", VisibleRect::center()); - horse2 = createMount("horse", Vector2(120, 200)); + horse2 = createMount("horse", Vec2(120, 200)); horse2->setOpacity(200); - bear = createMount("bear", Vector2(300,70)); + bear = createMount("bear", Vec2(300,70)); } void TestArmatureNesting2::onExit() { @@ -1316,7 +1316,7 @@ std::string TestArmatureNesting2::subtitle() const } void TestArmatureNesting2::onTouchesEnded(const std::vector& touches, Event* event) { - Vector2 point = touches[0]->getLocation(); + Vec2 point = touches[0]->getLocation(); Armature *armature = hero->getMount() == nullptr ? hero : hero->getMount(); @@ -1360,7 +1360,7 @@ void TestArmatureNesting2::changeMountCallback(Ref* pSender) } } -Armature * TestArmatureNesting2::createMount(const char *name, Vector2 position) +Armature * TestArmatureNesting2::createMount(const char *name, Vec2 position) { Armature *armature = Armature::create(name); armature->getAnimation()->playWithIndex(0); @@ -1390,7 +1390,7 @@ void TestPlaySeveralMovement::onEnter() // armature->getAnimation()->playWithIndexes(indexes); armature->setScale(0.2f); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); addChild(armature); } std::string TestPlaySeveralMovement::title() const @@ -1418,7 +1418,7 @@ void TestEasing::onEnter() armature->getAnimation()->playWithIndex(0); armature->setScale(0.8f); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y)); addChild(armature); updateSubTitle(); @@ -1460,7 +1460,7 @@ void TestChangeAnimationInternal::onEnter() armature->getAnimation()->playWithIndex(0); armature->setScale(0.2f); - armature->setPosition(Vector2(VisibleRect::center().x, VisibleRect::center().y)); + armature->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y)); addChild(armature); } void TestChangeAnimationInternal::onExit() diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index a084255f0e..7d939d594a 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -211,7 +211,7 @@ public: virtual void onEnter() override; virtual void onExit() override; virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual void update(float delta); void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); @@ -270,8 +270,8 @@ public: virtual void onEnter() override; virtual std::string title() const override; virtual void update(float delta); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; - void onDraw(const Matrix &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + void onDraw(const Mat4 &transform, bool transformUpdated); void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); @@ -293,13 +293,13 @@ class TestBoundingBox : public ArmatureTestLayer public: virtual void onEnter() override; virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; cocostudio::Armature *armature; Rect rect; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); CustomCommand _customCommand; }; @@ -346,7 +346,7 @@ public: void onTouchesEnded(const std::vector& touches, Event* event); void changeMountCallback(Ref* pSender); - virtual cocostudio::Armature *createMount(const char *name, Vector2 position); + virtual cocostudio::Armature *createMount(const char *name, Vec2 position); private: Hero *hero; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp index 644d792173..b30693dff6 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp @@ -73,7 +73,7 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() auto player = Sprite::create("components/Player.png", Rect(0, 0, 27, 40) ); - player->setPosition( Vector2(origin.x + player->getContentSize().width/2, + player->setPosition( Vec2(origin.x + player->getContentSize().width/2, origin.y + visibleSize.height/2) ); root = cocos2d::Node::create(); @@ -87,9 +87,9 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() }); itemBack->setColor(Color3B(0, 0, 0)); - itemBack->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + itemBack->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menuBack = Menu::create(itemBack, nullptr); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); }while (0); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp index f36c884d0e..43bfdb1fd1 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp @@ -32,7 +32,7 @@ void EnemyController::onEnter() // Create the target slightly off-screen along the right edge, // and along a random position along the Y axis as calculated _owner->setPosition( - Vector2(winSize.width + (getOwner()->getContentSize().width/2), + Vec2(winSize.width + (getOwner()->getContentSize().width/2), Director::getInstance()->getVisibleOrigin().y + actualY) ); @@ -45,7 +45,7 @@ void EnemyController::onEnter() // Create the actions FiniteTimeAction* actionMove = MoveTo::create( actualDuration, - Vector2(0 - getOwner()->getContentSize().width/2, actualY) ); + Vec2(0 - getOwner()->getContentSize().width/2, actualY) ); FiniteTimeAction* actionMoveDone = CallFuncN::create( CC_CALLBACK_1(SceneController::spriteMoveFinished, static_cast( getOwner()->getParent()->getComponent("SceneController") ))); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp index 0aee850835..b3fdffb35c 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp @@ -63,7 +63,7 @@ bool GameOverLayer::init() this->_label = Label::createWithTTF("","fonts/arial.ttf", 32); _label->retain(); _label->setColor( Color3B(0, 0, 0) ); - _label->setPosition( Vector2(winSize.width/2, winSize.height/2) ); + _label->setPosition( Vec2(winSize.width/2, winSize.height/2) ); this->addChild(_label); this->runAction( Sequence::create( @@ -79,9 +79,9 @@ bool GameOverLayer::init() }); itemBack->setColor(Color3B(0, 0, 0)); - itemBack->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + itemBack->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menuBack = Menu::create(itemBack, nullptr); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); return true; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp index fb9df333e9..4eb202ee0e 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp @@ -40,7 +40,7 @@ void PlayerController::onTouchesEnded(const std::vector& touches, Event { // Choose one of the touches to work with Touch* touch = touches[0]; - Vector2 location = touch->getLocation(); + Vec2 location = touch->getLocation(); Sprite *projectile = Sprite::create("components/Projectile.png", Rect(0, 0, 20, 20)); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp index bf9ffaf9b3..8953849118 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp @@ -24,7 +24,7 @@ void ProjectileController::onEnter() ComController::onEnter(); auto winSize = Director::getInstance()->getVisibleSize(); auto origin = Director::getInstance()->getVisibleOrigin(); - _owner->setPosition( Vector2(origin.x+20, origin.y+winSize.height/2) ); + _owner->setPosition( Vec2(origin.x+20, origin.y+winSize.height/2) ); _owner->setTag(3); auto com = _owner->getParent()->getComponent("SceneController"); static_cast(com)->getProjectiles().pushBack(_owner); @@ -113,7 +113,7 @@ void ProjectileController::move(float flocationX, float flocationY) float realX = origin.x + winSize.width + (_owner->getContentSize().width/2); float ratio = offY / offX; float realY = (realX * ratio) + _owner->getPosition().y; - Vector2 realDest = Vector2(realX, realY); + Vec2 realDest = Vec2(realX, realY); // Determine the length of how far we're shooting float offRealX = realX - _owner->getPosition().x; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index db2c88bb4f..6a7cf9c5fd 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -117,7 +117,7 @@ void SceneEditorTestLayer::onEnter() auto label = Label::createWithTTF(pTitle, "fonts/arial.ttf", 18); label->setTextColor(Color4B::WHITE); addChild(label, 1, 10000); - label->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 30) ); + label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) @@ -125,7 +125,7 @@ void SceneEditorTestLayer::onEnter() auto l = Label::createWithTTF(strSubtitle.c_str(), "fonts/arial.ttf", 18); l->setTextColor(Color4B::BLACK); addChild(l, 1, 10001); - l->setPosition(Vector2(VisibleRect::center().x, VisibleRect::top().y - 60) ); + l->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) ); } // add menu @@ -138,14 +138,14 @@ void SceneEditorTestLayer::onEnter() float fScale = 0.5f; - menu->setPosition(Vector2(0, 0)); - backItem->setPosition(Vector2(VisibleRect::center().x - restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + menu->setPosition(Vec2(0, 0)); + backItem->setPosition(Vec2(VisibleRect::center().x - restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); backItem->setScale(fScale); - restartItem->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + restartItem->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); restartItem->setScale(fScale); - nextItem->setPosition(Vector2(VisibleRect::center().x + restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + nextItem->setPosition(Vec2(VisibleRect::center().x + restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); nextItem->setScale(fScale); addChild(menu, 100); @@ -194,7 +194,7 @@ void SceneEditorTestLayer::backCallback(Ref *pSender) s->release(); } -void SceneEditorTestLayer::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { Layer::draw(renderer, transform, transformUpdated); } @@ -344,10 +344,10 @@ cocos2d::Node* ArmatureComponentTest::createGameScene() return nullptr; } ComRender *pBlowFish = static_cast(node->getChildByTag(10007)->getComponent("CCArmature")); - pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vector2(-1000.0f, 0))); + pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0))); ComRender *pButterflyfish = static_cast(node->getChildByTag(10008)->getComponent("CCArmature")); - pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vector2(-1000.0f, 0))); + pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0))); return node; } @@ -412,10 +412,10 @@ void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type) case ui::Widget::TouchEventType::BEGAN: { ComRender *pBlowFish = static_cast(_node->getChildByTag(10010)->getComponent("CCArmature")); - pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vector2(-1000.0f, 0))); + pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0))); ComRender *pButterflyfish = static_cast(_node->getChildByTag(10011)->getComponent("CCArmature")); - pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vector2(-1000.0f, 0))); + pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0))); } break; default: @@ -523,7 +523,7 @@ cocos2d::Node* ParticleComponentTest::createGameScene() } ComRender* Particle = static_cast(node->getChildByTag(10020)->getComponent("CCParticleSystemQuad")); - ActionInterval* jump = JumpBy::create(5, Vector2(-500,0), 50, 4); + ActionInterval* jump = JumpBy::create(5, Vec2(-500,0), 50, 4); FiniteTimeAction* action = Sequence::create( jump, jump->reverse(), nullptr); Particle->getNode()->runAction(action); return node; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index 3b3704e474..76a5ceedfa 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -43,7 +43,7 @@ public: virtual void nextCallback(cocos2d::Ref* pSender); virtual void backCallback(cocos2d::Ref* pSender); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: MenuItemImage *restartItem; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h index ed3512efde..08ffae0b2a 100755 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h @@ -36,7 +36,7 @@ public: private: int _tag; float _duration; - cocos2d::Vector2 _pos; + cocos2d::Vec2 _pos; }; @@ -54,7 +54,7 @@ public: private: int _tag; float _duration; - cocos2d::Vector2 _pos; + cocos2d::Vec2 _pos; bool _reverse; }; @@ -110,7 +110,7 @@ public: private: int _tag; float _duration; - cocos2d::Vector2 _scale; + cocos2d::Vec2 _scale; }; @@ -128,7 +128,7 @@ public: private: int _tag; float _duration; - cocos2d::Vector2 _scale; + cocos2d::Vec2 _scale; bool _reverse; }; @@ -148,7 +148,7 @@ public: private: int _tag; float _duration; - cocos2d::Vector2 _skew; + cocos2d::Vec2 _skew; }; @@ -166,7 +166,7 @@ public: private: int _tag; float _duration; - cocos2d::Vector2 _skew; + cocos2d::Vec2 _skew; bool _reverse; }; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h index a7400d0c20..6fb23a0195 100755 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h @@ -59,7 +59,7 @@ public: virtual void removeAll(); private: int _tag; - cocos2d::Vector2 _origin; + cocos2d::Vec2 _origin; cocos2d::Size _size; }; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index 818e96e25e..73cda0fae7 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -65,7 +65,7 @@ bool ControlButtonTest_HelloVariableSize::init() button->setColor(Color3B(0, 0, 255)); } - button->setPosition(Vector2 (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2)); + button->setPosition(Vec2 (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2)); layer->addChild(button); // Compute the size of the layer @@ -74,14 +74,14 @@ bool ControlButtonTest_HelloVariableSize::init() i++; } - layer->setAnchorPoint(Vector2 (0.5, 0.5)); + layer->setAnchorPoint(Vec2 (0.5, 0.5)); layer->setContentSize(Size(total_width, height)); - layer->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + layer->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(total_width + 14, height + 14)); - background->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + background->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); return true; } @@ -126,13 +126,13 @@ bool ControlButtonTest_Event::init() // Add a label in which the button events will be displayed setDisplayValueLabel(Label::createWithTTF("No Event", "fonts/Marker Felt.ttf", 32)); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1)); - _displayValueLabel->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(_displayValueLabel, 1); setDisplayBitmaskLabel(Label::createWithTTF("No bitmask event", "fonts/Marker Felt.ttf", 24)); - _displayBitmaskLabel->setAnchorPoint(Vector2(0.5f, -1)); - Vector2 bitmaskLabelPos = _displayValueLabel->getPosition() - Vector2(0, _displayBitmaskLabel->getBoundingBox().size.height); + _displayBitmaskLabel->setAnchorPoint(Vec2(0.5f, -1)); + Vec2 bitmaskLabelPos = _displayValueLabel->getPosition() - Vec2(0, _displayBitmaskLabel->getBoundingBox().size.height); _displayBitmaskLabel->setPosition(bitmaskLabelPos); addChild(_displayBitmaskLabel, 1); @@ -148,14 +148,14 @@ bool ControlButtonTest_Event::init() controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED); controlButton->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED); - controlButton->setAnchorPoint(Vector2(0.5f, 1)); - controlButton->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + controlButton->setAnchorPoint(Vec2(0.5f, 1)); + controlButton->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(controlButton, 1); // Add the black background auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(300, 170)); - background->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + background->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); // Sets up event handlers @@ -244,7 +244,7 @@ bool ControlButtonTest_Styling::init() ControlButton *button = standardButtonWithTitle(String::createWithFormat("%d",rand() % 30)->getCString()); button->setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust // It'll use the prefered size of the background image - button->setPosition(Vector2(button->getContentSize().width / 2 + (button->getContentSize().width + space) * i, + button->setPosition(Vec2(button->getContentSize().width / 2 + (button->getContentSize().width + space) * i, button->getContentSize().height / 2 + (button->getContentSize().height + space) * j)); layer->addChild(button); @@ -253,14 +253,14 @@ bool ControlButtonTest_Styling::init() } } - layer->setAnchorPoint(Vector2(0.5, 0.5)); + layer->setAnchorPoint(Vec2(0.5, 0.5)); layer->setContentSize(Size(max_w, max_h)); - layer->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + layer->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background auto backgroundButton = Scale9Sprite::create("extensions/buttonBackground.png"); backgroundButton->setContentSize(Size(max_w + 14, max_h + 14)); - backgroundButton->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + backgroundButton->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(backgroundButton); return true; } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index 7efc9fe23d..5a53c8c1ab 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -39,7 +39,7 @@ bool ControlColourPickerTest::init() auto screenSize = Director::getInstance()->getWinSize(); auto layer = Node::create(); - layer->setPosition(Vector2 (screenSize.width / 2, screenSize.height / 2)); + layer->setPosition(Vec2 (screenSize.width / 2, screenSize.height / 2)); addChild(layer, 1); double layer_width = 0; @@ -47,7 +47,7 @@ bool ControlColourPickerTest::init() // Create the colour picker ControlColourPicker *colourPicker = ControlColourPicker::create(); colourPicker->setColor(Color3B(37, 46, 252)); - colourPicker->setPosition(Vector2 (colourPicker->getContentSize().width / 2, 0)); + colourPicker->setPosition(Vec2 (colourPicker->getContentSize().width / 2, 0)); // Add it to the layer layer->addChild(colourPicker); @@ -61,7 +61,7 @@ bool ControlColourPickerTest::init() // Add the black background for the text auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(150, 50)); - background->setPosition(Vector2(layer_width + background->getContentSize().width / 2.0f, 0)); + background->setPosition(Vec2(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); layer_width += background->getContentSize().width; @@ -74,7 +74,7 @@ bool ControlColourPickerTest::init() // Set the layer size layer->setContentSize(Size(layer_width, 0)); - layer->setAnchorPoint(Vector2 (0.5f, 0.5f)); + layer->setAnchorPoint(Vec2 (0.5f, 0.5f)); // Update the color text colourValueChanged(colourPicker, Control::EventType::VALUE_CHANGED); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp index ca499c4562..2c69b440b0 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp @@ -42,7 +42,7 @@ bool ControlPotentiometerTest::init() auto screenSize = Director::getInstance()->getWinSize(); auto layer = Node::create(); - layer->setPosition(Vector2(screenSize.width / 2, screenSize.height / 2)); + layer->setPosition(Vec2(screenSize.width / 2, screenSize.height / 2)); this->addChild(layer, 1); double layer_width = 0; @@ -50,7 +50,7 @@ bool ControlPotentiometerTest::init() // Add the black background for the text auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(80, 50)); - background->setPosition(Vector2(layer_width + background->getContentSize().width / 2.0f, 0)); + background->setPosition(Vec2(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); layer_width += background->getContentSize().width; @@ -64,7 +64,7 @@ bool ControlPotentiometerTest::init() ControlPotentiometer *potentiometer = ControlPotentiometer::create("extensions/potentiometerTrack.png" ,"extensions/potentiometerProgress.png" ,"extensions/potentiometerButton.png"); - potentiometer->setPosition(Vector2(layer_width + 10 + potentiometer->getContentSize().width / 2, 0)); + potentiometer->setPosition(Vec2(layer_width + 10 + potentiometer->getContentSize().width / 2, 0)); // When the value of the slider will change, the given selector will be call potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlPotentiometerTest::valueChanged), Control::EventType::VALUE_CHANGED); @@ -75,7 +75,7 @@ bool ControlPotentiometerTest::init() // Set the layer size layer->setContentSize(Size(layer_width, 0)); - layer->setAnchorPoint(Vector2(0.5f, 0.5f)); + layer->setAnchorPoint(Vec2(0.5f, 0.5f)); // Update the value label this->valueChanged(potentiometer, Control::EventType::VALUE_CHANGED); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp index f4275160f9..53f0a9028c 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp @@ -43,9 +43,9 @@ bool ControlScene::init() if (Layer::init()) { auto pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(ControlScene::toExtensionsMainLayer, this)); - pBackItem->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + pBackItem->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto pBackMenu = Menu::create(pBackItem, NULL); - pBackMenu->setPosition( Vector2::ZERO ); + pBackMenu->setPosition( Vec2::ZERO ); addChild(pBackMenu, 10); // Add the generated background @@ -56,12 +56,12 @@ bool ControlScene::init() // Add the ribbon auto ribbon = Scale9Sprite::create("extensions/ribbon.png", Rect(1, 1, 48, 55)); ribbon->setContentSize(Size(VisibleRect::getVisibleRect().size.width, 57)); - ribbon->setPosition(Vector2(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f)); + ribbon->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f)); addChild(ribbon); // Add the title setSceneTitleLabel(Label::createWithTTF("Title", "fonts/arial.ttf", 12)); - _sceneTitleLabel->setPosition(Vector2 (VisibleRect::center().x, VisibleRect::top().y - _sceneTitleLabel->getContentSize().height / 2 - 5)); + _sceneTitleLabel->setPosition(Vec2 (VisibleRect::center().x, VisibleRect::top().y - _sceneTitleLabel->getContentSize().height / 2 - 5)); addChild(_sceneTitleLabel, 1); // Add the menu @@ -70,10 +70,10 @@ bool ControlScene::init() auto item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(ControlScene::nextCallback, this)); auto menu = Menu::create(item1, item3, item2, NULL); - menu->setPosition(Vector2::ZERO); - item1->setPosition(Vector2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vector2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + menu->setPosition(Vec2::ZERO); + item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu ,1); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 0cdfad7b9b..57383bab4d 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -45,29 +45,29 @@ bool ControlSliderTest::init() // Add a label in which the slider value will be displayed _displayValueLabel = Label::createWithTTF("Move the slider thumb!\nThe lower slider is restricted." ,"fonts/Marker Felt.ttf", 32); _displayValueLabel->retain(); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(screenSize.width / 1.7f, screenSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(screenSize.width / 1.7f, screenSize.height / 2.0f)); addChild(_displayValueLabel); // Add the slider ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); - slider->setAnchorPoint(Vector2(0.5f, 1.0f)); + slider->setAnchorPoint(Vec2(0.5f, 1.0f)); slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(5.0f); // Sets the max value of range - slider->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + 16)); + slider->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + 16)); slider->setTag(1); // When the value of the slider will change, the given selector will be call slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED); ControlSlider *restrictSlider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); - restrictSlider->setAnchorPoint(Vector2(0.5f, 1.0f)); + restrictSlider->setAnchorPoint(Vec2(0.5f, 1.0f)); restrictSlider->setMinimumValue(0.0f); // Sets the min value of range restrictSlider->setMaximumValue(5.0f); // Sets the max value of range restrictSlider->setMaximumAllowedValue(4.0f); restrictSlider->setMinimumAllowedValue(1.5f); restrictSlider->setValue(3.0f); - restrictSlider->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f - 24)); + restrictSlider->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - 24)); restrictSlider->setTag(2); //same with restricted diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp index 33fa3e2f20..51b8a9723c 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp @@ -43,7 +43,7 @@ bool ControlStepperTest::init() auto screenSize = Director::getInstance()->getWinSize(); auto layer = Node::create(); - layer->setPosition(Vector2 (screenSize.width / 2, screenSize.height / 2)); + layer->setPosition(Vec2 (screenSize.width / 2, screenSize.height / 2)); this->addChild(layer, 1); double layer_width = 0; @@ -51,7 +51,7 @@ bool ControlStepperTest::init() // Add the black background for the text auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(100, 50)); - background->setPosition(Vector2(layer_width + background->getContentSize().width / 2.0f, 0)); + background->setPosition(Vec2(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); this->setDisplayValueLabel(Label::createWithSystemFont("0", "HelveticaNeue-Bold", 30)); @@ -62,7 +62,7 @@ bool ControlStepperTest::init() layer_width += background->getContentSize().width; ControlStepper *stepper = this->makeControlStepper(); - stepper->setPosition(Vector2(layer_width + 10 + stepper->getContentSize().width / 2, 0)); + stepper->setPosition(Vec2(layer_width + 10 + stepper->getContentSize().width / 2, 0)); stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlStepperTest::valueChanged), Control::EventType::VALUE_CHANGED); layer->addChild(stepper); @@ -70,7 +70,7 @@ bool ControlStepperTest::init() // Set the layer size layer->setContentSize(Size(layer_width, 0)); - layer->setAnchorPoint(Vector2(0.5f, 0.5f)); + layer->setAnchorPoint(Vec2(0.5f, 0.5f)); // Update the value label this->valueChanged(stepper, Control::EventType::VALUE_CHANGED); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 95bed9d8c0..7b4f03e288 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -38,7 +38,7 @@ bool ControlSwitchTest::init() auto screenSize = Director::getInstance()->getWinSize(); auto layer = Node::create(); - layer->setPosition(Vector2(screenSize.width / 2, screenSize.height / 2)); + layer->setPosition(Vec2(screenSize.width / 2, screenSize.height / 2)); addChild(layer, 1); double layer_width = 0; @@ -46,7 +46,7 @@ bool ControlSwitchTest::init() // Add the black background for the text auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(80, 50)); - background->setPosition(Vector2(layer_width + background->getContentSize().width / 2.0f, 0)); + background->setPosition(Vec2(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); layer_width += background->getContentSize().width; @@ -67,14 +67,14 @@ bool ControlSwitchTest::init() Label::createWithSystemFont("On", "Arial-BoldMT", 16), Label::createWithSystemFont("Off", "Arial-BoldMT", 16) ); - switchControl->setPosition(Vector2(layer_width + 10 + switchControl->getContentSize().width / 2, 0)); + switchControl->setPosition(Vec2(layer_width + 10 + switchControl->getContentSize().width / 2, 0)); layer->addChild(switchControl); switchControl->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSwitchTest::valueChanged), Control::EventType::VALUE_CHANGED); // Set the layer size layer->setContentSize(Size(layer_width, 0)); - layer->setAnchorPoint(Vector2(0.5f, 0.5f)); + layer->setAnchorPoint(Vec2(0.5f, 0.5f)); // Update the value label valueChanged(switchControl, Control::EventType::VALUE_CHANGED); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index c5a132f706..8d465d6390 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -20,25 +20,25 @@ EditBoxTest::EditBoxTest() auto visibleSize = glview->getVisibleSize(); auto pBg = Sprite::create("Images/HelloWorld.png"); - pBg->setPosition(Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); + pBg->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); addChild(pBg); _TTFShowEditReturn = Label::createWithSystemFont("No edit control return!", "", 30); - _TTFShowEditReturn->setPosition(Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)); + _TTFShowEditReturn->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)); addChild(_TTFShowEditReturn); // Back Menu auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(EditBoxTest::toExtensionsMainLayer, this)); - itemBack->setPosition(Vector2(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25)); + itemBack->setPosition(Vec2(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25)); auto menuBack = Menu::create(itemBack, NULL); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); auto editBoxSize = Size(visibleSize.width - 100, 60); // top _editName = EditBox::create(editBoxSize, Scale9Sprite::create("extensions/green_edit.png")); - _editName->setPosition(Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)); + _editName->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)); _editName->setFontName("Paint Boy"); _editName->setFontSize(25); _editName->setFontColor(Color3B::RED); @@ -51,7 +51,7 @@ EditBoxTest::EditBoxTest() // middle _editPassword = EditBox::create(editBoxSize, Scale9Sprite::create("extensions/orange_edit.png")); - _editPassword->setPosition(Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); + _editPassword->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) _editPassword->setFont("American Typewriter", 30); #else @@ -68,14 +68,14 @@ EditBoxTest::EditBoxTest() // bottom _editEmail = EditBox::create(Size(editBoxSize.width, editBoxSize.height), Scale9Sprite::create("extensions/yellow_edit.png")); - _editEmail->setPosition(Vector2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)); - _editEmail->setAnchorPoint(Vector2(0.5, 1.0f)); + _editEmail->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)); + _editEmail->setAnchorPoint(Vec2(0.5, 1.0f)); _editEmail->setPlaceHolder("Email:"); _editEmail->setInputMode(EditBox::InputMode::EMAIL_ADDRESS); _editEmail->setDelegate(this); addChild(_editEmail); - this->setPosition(Vector2(10, 20)); + this->setPosition(Vec2(10, 20)); } EditBoxTest::~EditBoxTest() diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp index 0052503d2a..0f1d1dd795 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -89,7 +89,7 @@ static struct { static const int g_maxTests = sizeof(g_extensionsTests) / sizeof(g_extensionsTests[0]); -static Vector2 s_tCurPos = Vector2::ZERO; +static Vec2 s_tCurPos = Vec2::ZERO; //////////////////////////////////////////////////////// // @@ -103,13 +103,13 @@ void ExtensionsMainLayer::onEnter() auto s = Director::getInstance()->getWinSize(); _itemMenu = Menu::create(); - _itemMenu->setPosition( Vector2::ZERO ); + _itemMenu->setPosition( Vec2::ZERO ); MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(24); for (int i = 0; i < g_maxTests; ++i) { auto pItem = MenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback); - pItem->setPosition(Vector2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); + pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -143,17 +143,17 @@ void ExtensionsMainLayer::onTouchesMoved(const std::vector& touches, Eve float nMoveY = touchLocation.y - _beginPos.y; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } @@ -168,17 +168,17 @@ void ExtensionsMainLayer::onMouseScroll(Event* event) float nMoveY = mouseEvent->getScrollY() * 6; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.h b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.h index 0b30b1a886..de785ce3ca 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.h @@ -11,7 +11,7 @@ public: void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; int _testcount; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index 9aa98f9213..e2d1187fc9 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -15,53 +15,53 @@ HttpClientTest::HttpClientTest() const int SPACE = 35; auto label = Label::createWithTTF("Http Request Test", "fonts/arial.ttf", 28); - label->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN)); + label->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN)); addChild(label, 0); auto menuRequest = Menu::create(); - menuRequest->setPosition(Vector2::ZERO); + menuRequest->setPosition(Vec2::ZERO); addChild(menuRequest); // Get auto labelGet = Label::createWithTTF("Test Get", "fonts/arial.ttf", 22); auto itemGet = MenuItemLabel::create(labelGet, CC_CALLBACK_1(HttpClientTest::onMenuGetTestClicked, this)); - itemGet->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - SPACE)); + itemGet->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemGet); // Post auto labelPost = Label::createWithTTF("Test Post", "fonts/arial.ttf", 22); auto itemPost = MenuItemLabel::create(labelPost, CC_CALLBACK_1(HttpClientTest::onMenuPostTestClicked, this)); - itemPost->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)); + itemPost->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemPost); // Post Binary auto labelPostBinary = Label::createWithTTF("Test Post Binary", "fonts/arial.ttf", 22); auto itemPostBinary = MenuItemLabel::create(labelPostBinary, CC_CALLBACK_1(HttpClientTest::onMenuPostBinaryTestClicked, this)); - itemPostBinary->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - 3 * SPACE)); + itemPostBinary->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - 3 * SPACE)); menuRequest->addChild(itemPostBinary); // Put auto labelPut = Label::createWithTTF("Test Put", "fonts/arial.ttf", 22); auto itemPut = MenuItemLabel::create(labelPut, CC_CALLBACK_1(HttpClientTest::onMenuPutTestClicked, this)); - itemPut->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - 4 * SPACE)); + itemPut->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemPut); // Delete auto labelDelete = Label::createWithTTF("Test Delete", "fonts/arial.ttf", 22); auto itemDelete = MenuItemLabel::create(labelDelete, CC_CALLBACK_1(HttpClientTest::onMenuDeleteTestClicked, this)); - itemDelete->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - 5 * SPACE)); + itemDelete->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - 5 * SPACE)); menuRequest->addChild(itemDelete); // Response Code Label _labelStatusCode = Label::createWithTTF("HTTP Status Code", "fonts/arial.ttf", 22); - _labelStatusCode->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - 6 * SPACE)); + _labelStatusCode->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - 6 * SPACE)); addChild(_labelStatusCode); // Back Menu auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(HttpClientTest::toExtensionsMainLayer, this)); - itemBack->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + itemBack->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menuBack = Menu::create(itemBack, NULL); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index 5efafb8a26..8d6688c96f 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -26,72 +26,72 @@ SocketIOTestLayer::SocketIOTestLayer(void) const int SPACE = 35; auto label = Label::createWithTTF("SocketIO Extension Test", "fonts/arial.ttf", 28); - label->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN)); + label->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN)); addChild(label, 0); auto menuRequest = Menu::create(); - menuRequest->setPosition(Vector2::ZERO); + menuRequest->setPosition(Vec2::ZERO); addChild(menuRequest); // Test to create basic client in the default namespace auto labelSIOClient = Label::createWithTTF("Open SocketIO Client", "fonts/arial.ttf", 22); auto itemSIOClient = MenuItemLabel::create(labelSIOClient, CC_CALLBACK_1(SocketIOTestLayer::onMenuSIOClientClicked, this)); - itemSIOClient->setPosition(Vector2(VisibleRect::left().x + labelSIOClient->getContentSize().width / 2 + 5, winSize.height - MARGIN - SPACE)); + itemSIOClient->setPosition(Vec2(VisibleRect::left().x + labelSIOClient->getContentSize().width / 2 + 5, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemSIOClient); // Test to create a client at the endpoint '/testpoint' auto labelSIOEndpoint = Label::createWithTTF("Open SocketIO Endpoint", "fonts/arial.ttf", 22); auto itemSIOEndpoint = MenuItemLabel::create(labelSIOEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuSIOEndpointClicked, this)); - itemSIOEndpoint->setPosition(Vector2(VisibleRect::right().x - labelSIOEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - SPACE)); + itemSIOEndpoint->setPosition(Vec2(VisibleRect::right().x - labelSIOEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemSIOEndpoint); // Test sending message to default namespace auto labelTestMessage = Label::createWithTTF("Send Test Message", "fonts/arial.ttf", 22); auto itemTestMessage = MenuItemLabel::create(labelTestMessage, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestMessageClicked, this)); - itemTestMessage->setPosition(Vector2(VisibleRect::left().x + labelTestMessage->getContentSize().width / 2 + 5, winSize.height - MARGIN - 2 * SPACE)); + itemTestMessage->setPosition(Vec2(VisibleRect::left().x + labelTestMessage->getContentSize().width / 2 + 5, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemTestMessage); // Test sending message to the endpoint '/testpoint' auto labelTestMessageEndpoint = Label::createWithTTF("Test Endpoint Message", "fonts/arial.ttf", 22); auto itemTestMessageEndpoint = MenuItemLabel::create(labelTestMessageEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestMessageEndpointClicked, this)); - itemTestMessageEndpoint->setPosition(Vector2(VisibleRect::right().x - labelTestMessageEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 2 * SPACE)); + itemTestMessageEndpoint->setPosition(Vec2(VisibleRect::right().x - labelTestMessageEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemTestMessageEndpoint); // Test sending event 'echotest' to default namespace auto labelTestEvent = Label::createWithTTF("Send Test Event", "fonts/arial.ttf", 22); auto itemTestEvent = MenuItemLabel::create(labelTestEvent, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEventClicked, this)); - itemTestEvent->setPosition(Vector2(VisibleRect::left().x + labelTestEvent->getContentSize().width / 2 + 5, winSize.height - MARGIN - 3 * SPACE)); + itemTestEvent->setPosition(Vec2(VisibleRect::left().x + labelTestEvent->getContentSize().width / 2 + 5, winSize.height - MARGIN - 3 * SPACE)); menuRequest->addChild(itemTestEvent); // Test sending event 'echotest' to the endpoint '/testpoint' auto labelTestEventEndpoint = Label::createWithTTF("Test Endpoint Event", "fonts/arial.ttf", 22); auto itemTestEventEndpoint = MenuItemLabel::create(labelTestEventEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEventEndpointClicked, this)); - itemTestEventEndpoint->setPosition(Vector2(VisibleRect::right().x - labelTestEventEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 3 * SPACE)); + itemTestEventEndpoint->setPosition(Vec2(VisibleRect::right().x - labelTestEventEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 3 * SPACE)); menuRequest->addChild(itemTestEventEndpoint); // Test disconnecting basic client auto labelTestClientDisconnect = Label::createWithTTF("Disconnect Socket", "fonts/arial.ttf", 22); auto itemClientDisconnect = MenuItemLabel::create(labelTestClientDisconnect, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestClientDisconnectClicked, this)); - itemClientDisconnect->setPosition(Vector2(VisibleRect::left().x + labelTestClientDisconnect->getContentSize().width / 2 + 5, winSize.height - MARGIN - 4 * SPACE)); + itemClientDisconnect->setPosition(Vec2(VisibleRect::left().x + labelTestClientDisconnect->getContentSize().width / 2 + 5, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemClientDisconnect); // Test disconnecting the endpoint '/testpoint' auto labelTestEndpointDisconnect = Label::createWithTTF("Disconnect Endpoint", "fonts/arial.ttf", 22); auto itemTestEndpointDisconnect = MenuItemLabel::create(labelTestEndpointDisconnect, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEndpointDisconnectClicked, this)); - itemTestEndpointDisconnect->setPosition(Vector2(VisibleRect::right().x - labelTestEndpointDisconnect->getContentSize().width / 2 - 5, winSize.height - MARGIN - 4 * SPACE)); + itemTestEndpointDisconnect->setPosition(Vec2(VisibleRect::right().x - labelTestEndpointDisconnect->getContentSize().width / 2 - 5, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemTestEndpointDisconnect); // Sahred Status Label _sioClientStatus = Label::createWithTTF("Not connected...", "fonts/arial.ttf", 14, Size(320, 100), TextHAlignment::LEFT); - _sioClientStatus->setAnchorPoint(Vector2(0, 0)); - _sioClientStatus->setPosition(Vector2(VisibleRect::left().x, VisibleRect::rightBottom().y)); + _sioClientStatus->setAnchorPoint(Vec2(0, 0)); + _sioClientStatus->setPosition(Vec2(VisibleRect::left().x, VisibleRect::rightBottom().y)); this->addChild(_sioClientStatus); // Back Menu auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(SocketIOTestLayer::toExtensionsMainLayer, this)); - itemBack->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + itemBack->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menuBack = Menu::create(itemBack, NULL); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index fb7757c31a..b33ddc961d 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -28,49 +28,49 @@ WebSocketTestLayer::WebSocketTestLayer() const int SPACE = 35; auto label = Label::createWithTTF("WebSocket Test", "fonts/arial.ttf", 28); - label->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN)); + label->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN)); addChild(label, 0); auto menuRequest = Menu::create(); - menuRequest->setPosition(Vector2::ZERO); + menuRequest->setPosition(Vec2::ZERO); addChild(menuRequest); // Send Text auto labelSendText = Label::createWithTTF("Send Text", "fonts/arial.ttf", 22); auto itemSendText = MenuItemLabel::create(labelSendText, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendTextClicked, this)); - itemSendText->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - SPACE)); + itemSendText->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemSendText); // Send Binary auto labelSendBinary = Label::createWithTTF("Send Binary", "fonts/arial.ttf", 22); auto itemSendBinary = MenuItemLabel::create(labelSendBinary, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendBinaryClicked, this)); - itemSendBinary->setPosition(Vector2(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)); + itemSendBinary->setPosition(Vec2(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemSendBinary); // Send Text Status Label _sendTextStatus = Label::createWithTTF("Send Text WS is waiting...", "fonts/arial.ttf", 14, Size(160, 100), TextHAlignment::CENTER, TextVAlignment::TOP); - _sendTextStatus->setAnchorPoint(Vector2(0, 0)); - _sendTextStatus->setPosition(Vector2(VisibleRect::left().x, VisibleRect::rightBottom().y + 25)); + _sendTextStatus->setAnchorPoint(Vec2(0, 0)); + _sendTextStatus->setPosition(Vec2(VisibleRect::left().x, VisibleRect::rightBottom().y + 25)); this->addChild(_sendTextStatus); // Send Binary Status Label _sendBinaryStatus = Label::createWithTTF("Send Binary WS is waiting...", "fonts/arial.ttf", 14, Size(160, 100), TextHAlignment::CENTER, TextVAlignment::TOP); - _sendBinaryStatus->setAnchorPoint(Vector2(0, 0)); - _sendBinaryStatus->setPosition(Vector2(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25)); + _sendBinaryStatus->setAnchorPoint(Vec2(0, 0)); + _sendBinaryStatus->setPosition(Vec2(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25)); this->addChild(_sendBinaryStatus); // Error Label _errorStatus = Label::createWithTTF("Error WS is waiting...", "fonts/arial.ttf", 14, Size(160, 100), TextHAlignment::CENTER, TextVAlignment::TOP); - _errorStatus->setAnchorPoint(Vector2(0, 0)); - _errorStatus->setPosition(Vector2(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25)); + _errorStatus->setAnchorPoint(Vec2(0, 0)); + _errorStatus->setPosition(Vec2(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25)); this->addChild(_errorStatus); // Back Menu auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(WebSocketTestLayer::toExtensionsMainLayer, this)); - itemBack->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + itemBack->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menuBack = Menu::create(itemBack, NULL); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); _wsiSendText = new network::WebSocket(); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp index d5b2fcc3d4..1a37df2876 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp @@ -82,9 +82,9 @@ NotificationCenterTest::NotificationCenterTest() auto s = Director::getInstance()->getWinSize(); auto pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(NotificationCenterTest::toExtensionsMainLayer, this)); - pBackItem->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + pBackItem->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto pBackMenu = Menu::create(pBackItem, NULL); - pBackMenu->setPosition( Vector2::ZERO ); + pBackMenu->setPosition( Vec2::ZERO ); addChild(pBackMenu); auto label1 = Label::createWithTTF("switch off", "fonts/Marker Felt.ttf", 26); @@ -95,18 +95,18 @@ NotificationCenterTest::NotificationCenterTest() // turn on item->setSelectedIndex(1); auto menu = Menu::create(item, NULL); - menu->setPosition(Vector2(s.width/2+100, s.height/2)); + menu->setPosition(Vec2(s.width/2+100, s.height/2)); addChild(menu); auto menuConnect = Menu::create(); - menuConnect->setPosition(Vector2::ZERO); + menuConnect->setPosition(Vec2::ZERO); addChild(menuConnect); for (int i = 1; i <= 3; i++) { Light* light = Light::lightWithFile("Images/Pea.png"); light->setTag(kTagLight+i); - light->setPosition(Vector2(100, s.height/4*i)); + light->setPosition(Vec2(100, s.height/4*i)); addChild(light); auto label1 = Label::createWithTTF("not connected", "fonts/Marker Felt.ttf", 26); @@ -115,7 +115,7 @@ NotificationCenterTest::NotificationCenterTest() auto item2 = MenuItemLabel::create(label2); auto item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::connectToSwitch, this), item1, item2, NULL); item->setTag(kTagConnect+i); - item->setPosition(Vector2(light->getPosition().x, light->getPosition().y+50)); + item->setPosition(Vec2(light->getPosition().x, light->getPosition().y+50)); menuConnect->addChild(item, 0); if (i == 2) { diff --git a/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp index d324c0fa91..07982e6498 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -144,7 +144,7 @@ void S9BatchNodeBasic::onEnter() blocks->updateWithBatchNode(batchNode, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); log("... updateWithBatchNode"); - blocks->setPosition(Vector2(x, y)); + blocks->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks); @@ -178,7 +178,7 @@ void S9FrameNameSpriteSheet::onEnter() auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); log("... created"); - blocks->setPosition(Vector2(x, y)); + blocks->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks); @@ -212,7 +212,7 @@ void S9FrameNameSpriteSheetRotated::onEnter() auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); log("... created"); - blocks->setPosition(Vector2(x, y)); + blocks->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks); @@ -253,7 +253,7 @@ void S9BatchNodeScaledNoInsets::onEnter() blocks_scaled->updateWithBatchNode(batchNode_scaled, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); log("... updateWithBatchNode"); - blocks_scaled->setPosition(Vector2(x, y)); + blocks_scaled->setPosition(Vec2(x, y)); log("... setPosition"); blocks_scaled->setContentSize(Size(96 * 4, 96*2)); @@ -291,7 +291,7 @@ void S9FrameNameSpriteSheetScaledNoInsets::onEnter() auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); log("... created"); - blocks_scaled->setPosition(Vector2(x, y)); + blocks_scaled->setPosition(Vec2(x, y)); log("... setPosition"); blocks_scaled->setContentSize(Size(96 * 4, 96*2)); @@ -330,7 +330,7 @@ void S9FrameNameSpriteSheetRotatedScaledNoInsets::onEnter() auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); log("... created"); - blocks_scaled->setPosition(Vector2(x, y)); + blocks_scaled->setPosition(Vec2(x, y)); log("... setPosition"); blocks_scaled->setContentSize(Size(96 * 4, 96*2)); @@ -378,7 +378,7 @@ void S9BatchNodeScaleWithCapInsets::onEnter() blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); log("... setContentSize"); - blocks_scaled_with_insets->setPosition(Vector2(x, y)); + blocks_scaled_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks_scaled_with_insets); @@ -413,7 +413,7 @@ void S9FrameNameSpriteSheetInsets::onEnter() auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); log("... created"); - blocks_with_insets->setPosition(Vector2(x, y)); + blocks_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks_with_insets); @@ -450,7 +450,7 @@ void S9FrameNameSpriteSheetInsetsScaled::onEnter() blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); log("... setContentSize"); - blocks_scaled_with_insets->setPosition(Vector2(x, y)); + blocks_scaled_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks_scaled_with_insets); @@ -484,7 +484,7 @@ void S9FrameNameSpriteSheetRotatedInsets::onEnter() auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png", Rect(32, 32, 32, 32)); log("... created"); - blocks_with_insets->setPosition(Vector2(x, y)); + blocks_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks_with_insets); @@ -521,7 +521,7 @@ void S9_TexturePacker::onEnter() auto s = Scale9Sprite::createWithSpriteFrameName("button_normal.png"); log("... created"); - s->setPosition(Vector2(x, y)); + s->setPosition(Vec2(x, y)); log("... setPosition"); s->setContentSize(Size(14 * 16, 10 * 16)); @@ -535,7 +535,7 @@ void S9_TexturePacker::onEnter() auto s2 = Scale9Sprite::createWithSpriteFrameName("button_actived.png"); log("... created"); - s2->setPosition(Vector2(x, y)); + s2->setPosition(Vec2(x, y)); log("... setPosition"); s2->setContentSize(Size(14 * 16, 10 * 16)); @@ -576,7 +576,7 @@ void S9FrameNameSpriteSheetRotatedInsetsScaled::onEnter() blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); log("... setContentSize"); - blocks_scaled_with_insets->setPosition(Vector2(x, y)); + blocks_scaled_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks_scaled_with_insets); @@ -615,7 +615,7 @@ void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter() blocks_scaled_with_insets->setInsetRight(32); blocks_scaled_with_insets->setPreferredSize(Size(32*5.5f, 32*4)); - blocks_scaled_with_insets->setPosition(Vector2(x, y)); + blocks_scaled_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); this->addChild(blocks_scaled_with_insets); @@ -654,7 +654,7 @@ void S9CascadeOpacityAndColor::onEnter() auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); log("... created"); - blocks_scaled_with_insets->setPosition(Vector2(x, y)); + blocks_scaled_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); rgba->addChild(blocks_scaled_with_insets); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp index ed4d5c3069..346395690b 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp @@ -2,17 +2,17 @@ USING_NS_CC; -void CustomTableViewCell::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void CustomTableViewCell::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { TableViewCell::draw(renderer, transform, transformUpdated); // draw bounding box // auto pos = getPosition(); // auto size = Size(178, 200); -// Vector2 vertices[4]={ -// Vector2(pos.x+1, pos.y+1), -// Vector2(pos.x+size.width-1, pos.y+1), -// Vector2(pos.x+size.width-1, pos.y+size.height-1), -// Vector2(pos.x+1, pos.y+size.height-1), +// Vec2 vertices[4]={ +// Vec2(pos.x+1, pos.y+1), +// Vec2(pos.x+size.width-1, pos.y+1), +// Vec2(pos.x+size.width-1, pos.y+size.height-1), +// Vec2(pos.x+1, pos.y+size.height-1), // }; // DrawPrimitives::drawColor4B(0, 0, 255, 255); // DrawPrimitives::drawPoly(vertices, 4, true); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h index ca63419f98..303a3b40bc 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h @@ -7,7 +7,7 @@ class CustomTableViewCell : public cocos2d::extension::TableViewCell { public: - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Matrix &transform, bool transformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; }; #endif /* __CUSTOMTABELVIEWCELL_H__ */ diff --git a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index 71ec024fb7..0bf1dc7681 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -25,14 +25,14 @@ bool TableViewTestLayer::init() TableView* tableView = TableView::create(this, Size(250, 60)); tableView->setDirection(ScrollView::Direction::HORIZONTAL); - tableView->setPosition(Vector2(20,winSize.height/2-30)); + tableView->setPosition(Vec2(20,winSize.height/2-30)); tableView->setDelegate(this); this->addChild(tableView); tableView->reloadData(); tableView = TableView::create(this, Size(60, 250)); tableView->setDirection(ScrollView::Direction::VERTICAL); - tableView->setPosition(Vector2(winSize.width-150,winSize.height/2-120)); + tableView->setPosition(Vec2(winSize.width-150,winSize.height/2-120)); tableView->setDelegate(this); tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN); this->addChild(tableView); @@ -40,9 +40,9 @@ bool TableViewTestLayer::init() // Back Menu MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this)); - itemBack->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + itemBack->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); Menu *menuBack = Menu::create(itemBack, NULL); - menuBack->setPosition(Vector2::ZERO); + menuBack->setPosition(Vec2::ZERO); addChild(menuBack); return true; @@ -76,13 +76,13 @@ TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, ssize_t id cell = new CustomTableViewCell(); cell->autorelease(); auto sprite = Sprite::create("Images/Icon.png"); - sprite->setAnchorPoint(Vector2::ZERO); - sprite->setPosition(Vector2(0, 0)); + sprite->setAnchorPoint(Vec2::ZERO); + sprite->setPosition(Vec2(0, 0)); cell->addChild(sprite); auto label = Label::createWithSystemFont(string->getCString(), "Helvetica", 20.0); - label->setPosition(Vector2::ZERO); - label->setAnchorPoint(Vector2::ZERO); + label->setPosition(Vec2::ZERO); + label->setAnchorPoint(Vec2::ZERO); label->setTag(123); cell->addChild(label); } diff --git a/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp b/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp index a14dd6cdd1..cec7fdc3fb 100644 --- a/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -244,7 +244,7 @@ void TestFilenameLookup::onEnter() this->addChild(sprite); auto s = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); } void TestFilenameLookup::onExit() @@ -277,12 +277,12 @@ void TestIsFileExist::onEnter() isExist = sharedFileUtils->isFileExist("Images/grossini.png"); pTTF = Label::createWithSystemFont(isExist ? "Images/grossini.png exists" : "Images/grossini.png doesn't exist", "", 20); - pTTF->setPosition(Vector2(s.width/2, s.height/3)); + pTTF->setPosition(Vec2(s.width/2, s.height/3)); this->addChild(pTTF); isExist = sharedFileUtils->isFileExist("Images/grossini.xcf"); pTTF = Label::createWithSystemFont(isExist ? "Images/grossini.xcf exists" : "Images/grossini.xcf doesn't exist", "", 20); - pTTF->setPosition(Vector2(s.width/2, s.height/3*2)); + pTTF->setPosition(Vec2(s.width/2, s.height/3*2)); this->addChild(pTTF); } @@ -366,7 +366,7 @@ void TextWritePlist::onEnter() auto label = Label::createWithTTF(fullPath.c_str(), "fonts/Thonburi.ttf", 6); this->addChild(label); auto winSize = Director::getInstance()->getWinSize(); - label->setPosition(Vector2(winSize.width/2, winSize.height/3)); + label->setPosition(Vec2(winSize.width/2, winSize.height/3)); auto loadDict = __Dictionary::createWithContentsOfFile(fullPath.c_str()); auto loadDictInDict = (__Dictionary*)loadDict->objectForKey("dictInDict, Hello World"); diff --git a/tests/cpp-tests/Classes/FontTest/FontTest.cpp b/tests/cpp-tests/Classes/FontTest/FontTest.cpp index 29165fb665..dd6a1662d1 100644 --- a/tests/cpp-tests/Classes/FontTest/FontTest.cpp +++ b/tests/cpp-tests/Classes/FontTest/FontTest.cpp @@ -114,20 +114,20 @@ void FontTest::showFont(const char *pFont) rightColor->ignoreAnchorPointForPosition(false); - top->setAnchorPoint(Vector2(0.5, 1)); - left->setAnchorPoint(Vector2(0,0.5)); - leftColor->setAnchorPoint(Vector2(0,0.5)); - center->setAnchorPoint(Vector2(0,0.5)); - centerColor->setAnchorPoint(Vector2(0,0.5)); - right->setAnchorPoint(Vector2(0,0.5)); - rightColor->setAnchorPoint(Vector2(0,0.5)); + top->setAnchorPoint(Vec2(0.5, 1)); + left->setAnchorPoint(Vec2(0,0.5)); + leftColor->setAnchorPoint(Vec2(0,0.5)); + center->setAnchorPoint(Vec2(0,0.5)); + centerColor->setAnchorPoint(Vec2(0,0.5)); + right->setAnchorPoint(Vec2(0,0.5)); + rightColor->setAnchorPoint(Vec2(0,0.5)); - top->setPosition(Vector2(s.width/2,s.height-20)); - left->setPosition(Vector2(0,s.height/2)); + top->setPosition(Vec2(s.width/2,s.height-20)); + left->setPosition(Vec2(0,s.height/2)); leftColor->setPosition(left->getPosition()); - center->setPosition(Vector2(blockSize.width, s.height/2)); + center->setPosition(Vec2(blockSize.width, s.height/2)); centerColor->setPosition(center->getPosition()); - right->setPosition(Vector2(blockSize.width*2, s.height/2)); + right->setPosition(Vec2(blockSize.width*2, s.height/2)); rightColor->setPosition(right->getPosition()); this->addChild(leftColor, -1, kTagColor1); diff --git a/tests/cpp-tests/Classes/InputTest/MouseTest.cpp b/tests/cpp-tests/Classes/InputTest/MouseTest.cpp index 4c0a900283..12512dafae 100644 --- a/tests/cpp-tests/Classes/InputTest/MouseTest.cpp +++ b/tests/cpp-tests/Classes/InputTest/MouseTest.cpp @@ -5,16 +5,16 @@ MouseTest::MouseTest() auto s = Director::getInstance()->getWinSize(); auto title = Label::createWithTTF("Mouse Test", "fonts/arial.ttf", 28); addChild(title, 0); - title->setPosition( Vector2(s.width/2, s.height-50) ); + title->setPosition( Vec2(s.width/2, s.height-50) ); //Create a label to display the mouse action _labelAction = Label::createWithTTF("Click mouse button and see this change", "fonts/arial.ttf", 22); - _labelAction->setPosition(Vector2(s.width/2, s.height*2/3)); + _labelAction->setPosition(Vec2(s.width/2, s.height*2/3)); addChild(_labelAction, 0); //Create a label to display the mouse position _labelPosition = Label::createWithTTF("Mouse not supported on this device", "fonts/arial.ttf", 22); - _labelPosition->setPosition(Vector2(s.width/2, s.height/3)); + _labelPosition->setPosition(Vec2(s.width/2, s.height/3)); addChild(_labelPosition); diff --git a/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp b/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp index 105132e7ef..5a84b24595 100644 --- a/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp +++ b/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp @@ -17,7 +17,7 @@ IntervalLayer::IntervalLayer() // sun auto sun = ParticleSun::create(); sun->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); - sun->setPosition( Vector2(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32) ); + sun->setPosition( Vec2(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32) ); sun->setTotalParticles(130); sun->setLife(0.6f); @@ -36,11 +36,11 @@ IntervalLayer::IntervalLayer() schedule(schedule_selector(IntervalLayer::step3), 1.0f); schedule(schedule_selector(IntervalLayer::step4), 2.0f); - _label0->setPosition(Vector2(s.width*1/6, s.height/2)); - _label1->setPosition(Vector2(s.width*2/6, s.height/2)); - _label2->setPosition(Vector2(s.width*3/6, s.height/2)); - _label3->setPosition(Vector2(s.width*4/6, s.height/2)); - _label4->setPosition(Vector2(s.width*5/6, s.height/2)); + _label0->setPosition(Vec2(s.width*1/6, s.height/2)); + _label1->setPosition(Vec2(s.width*2/6, s.height/2)); + _label2->setPosition(Vec2(s.width*3/6, s.height/2)); + _label3->setPosition(Vec2(s.width*4/6, s.height/2)); + _label4->setPosition(Vec2(s.width*5/6, s.height/2)); addChild(_label0); addChild(_label1); @@ -50,9 +50,9 @@ IntervalLayer::IntervalLayer() // Sprite auto sprite = Sprite::create(s_pathGrossini); - sprite->setPosition( Vector2(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50) ); + sprite->setPosition( Vec2(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50) ); - auto jump = JumpBy::create(3, Vector2(s.width-80,0), 50, 4); + auto jump = JumpBy::create(3, Vec2(s.width-80,0), 50, 4); addChild(sprite); sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), NULL) )); @@ -64,7 +64,7 @@ IntervalLayer::IntervalLayer() Director::getInstance()->pause(); }); auto menu = Menu::create(item1, NULL); - menu->setPosition( Vector2(s.width/2, s.height-50) ); + menu->setPosition( Vec2(s.width/2, s.height-50) ); addChild( menu ); } diff --git a/tests/cpp-tests/Classes/KeyboardTest/KeyboardTest.cpp b/tests/cpp-tests/Classes/KeyboardTest/KeyboardTest.cpp index c3f9e0223e..10b2eaebf1 100644 --- a/tests/cpp-tests/Classes/KeyboardTest/KeyboardTest.cpp +++ b/tests/cpp-tests/Classes/KeyboardTest/KeyboardTest.cpp @@ -5,7 +5,7 @@ KeyboardTest::KeyboardTest() auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("Keyboard Test", "fonts/arial.ttf", 28); addChild(label, 0); - label->setPosition( Vector2(s.width/2, s.height-50) ); + label->setPosition( Vec2(s.width/2, s.height-50) ); auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = CC_CALLBACK_2(KeyboardTest::onKeyPressed, this); @@ -15,7 +15,7 @@ KeyboardTest::KeyboardTest() // create a label to display the tip string _label = Label::createWithTTF("Please press any key and see console log...", "fonts/arial.ttf", 22); - _label->setPosition(Vector2(s.width / 2, s.height / 2)); + _label->setPosition(Vec2(s.width / 2, s.height / 2)); addChild(_label, 0); _label->retain(); diff --git a/tests/cpp-tests/Classes/KeypadTest/KeypadTest.cpp b/tests/cpp-tests/Classes/KeypadTest/KeypadTest.cpp index 289befe0d6..4bac8b0ba4 100644 --- a/tests/cpp-tests/Classes/KeypadTest/KeypadTest.cpp +++ b/tests/cpp-tests/Classes/KeypadTest/KeypadTest.cpp @@ -5,7 +5,7 @@ KeypadTest::KeypadTest() auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("Keypad Test", "fonts/arial.ttf", 28); addChild(label, 0); - label->setPosition( Vector2(s.width/2, s.height-50) ); + label->setPosition( Vec2(s.width/2, s.height-50) ); auto listener = EventListenerKeyboard::create(); listener->onKeyReleased = CC_CALLBACK_2(KeypadTest::onKeyReleased, this); @@ -14,7 +14,7 @@ KeypadTest::KeypadTest() // create a label to display the tip string _label = Label::createWithTTF("Please press any key...", "fonts/arial.ttf", 22); - _label->setPosition(Vector2(s.width / 2, s.height / 2)); + _label->setPosition(Vec2(s.width / 2, s.height / 2)); addChild(_label, 0); _label->retain(); diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 812fd1c13f..331e262d60 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -180,23 +180,23 @@ Atlas1::Atlas1() V3F_C4B_T2F_Quad quads[] = { { - {Vector3(0,0,0),Color4B(0,0,255,255),Tex2F(0.0f,1.0f),}, // bottom left - {Vector3(s.width,0,0),Color4B(0,0,255,0),Tex2F(1.0f,1.0f),}, // bottom right - {Vector3(0,s.height,0),Color4B(0,0,255,0),Tex2F(0.0f,0.0f),}, // top left - {Vector3(s.width,s.height,0),Color4B(0,0,255,255),Tex2F(1.0f,0.0f),}, // top right + {Vec3(0,0,0),Color4B(0,0,255,255),Tex2F(0.0f,1.0f),}, // bottom left + {Vec3(s.width,0,0),Color4B(0,0,255,0),Tex2F(1.0f,1.0f),}, // bottom right + {Vec3(0,s.height,0),Color4B(0,0,255,0),Tex2F(0.0f,0.0f),}, // top left + {Vec3(s.width,s.height,0),Color4B(0,0,255,255),Tex2F(1.0f,0.0f),}, // top right }, { - {Vector3(40,40,0),Color4B(255,255,255,255),Tex2F(0.0f,0.2f),}, // bottom left - {Vector3(120,80,0),Color4B(255,0,0,255),Tex2F(0.5f,0.2f),}, // bottom right - {Vector3(40,160,0),Color4B(255,255,255,255),Tex2F(0.0f,0.0f),}, // top left - {Vector3(160,160,0),Color4B(0,255,0,255),Tex2F(0.5f,0.0f),}, // top right + {Vec3(40,40,0),Color4B(255,255,255,255),Tex2F(0.0f,0.2f),}, // bottom left + {Vec3(120,80,0),Color4B(255,0,0,255),Tex2F(0.5f,0.2f),}, // bottom right + {Vec3(40,160,0),Color4B(255,255,255,255),Tex2F(0.0f,0.0f),}, // top left + {Vec3(160,160,0),Color4B(0,255,0,255),Tex2F(0.5f,0.0f),}, // top right }, { - {Vector3(s.width/2,40,0),Color4B(255,0,0,255),Tex2F(0.0f,1.0f),}, // bottom left - {Vector3(s.width,40,0),Color4B(0,255,0,255),Tex2F(1.0f,1.0f),}, // bottom right - {Vector3(s.width/2-50,200,0),Color4B(0,0,255,255),Tex2F(0.0f,0.0f),}, // top left - {Vector3(s.width,100,0),Color4B(255,255,0,255),Tex2F(1.0f,0.0f),}, // top right + {Vec3(s.width/2,40,0),Color4B(255,0,0,255),Tex2F(0.0f,1.0f),}, // bottom left + {Vec3(s.width,40,0),Color4B(0,255,0,255),Tex2F(1.0f,1.0f),}, // bottom right + {Vec3(s.width/2-50,200,0),Color4B(0,0,255,255),Tex2F(0.0f,0.0f),}, // top left + {Vec3(s.width,100,0),Color4B(255,255,0,255),Tex2F(1.0f,0.0f),}, // top right }, }; @@ -213,14 +213,14 @@ Atlas1::~Atlas1() _textureAtlas->release(); } -void Atlas1::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Atlas1::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void Atlas1::onDraw(const Matrix &transform, bool transformUpdated) +void Atlas1::onDraw(const Mat4 &transform, bool transformUpdated) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -249,12 +249,12 @@ LabelAtlasTest::LabelAtlasTest() auto label1 = LabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label1, 0, kTagSprite1); - label1->setPosition( Vector2(10,100) ); + label1->setPosition( Vec2(10,100) ); label1->setOpacity( 200 ); auto label2 = LabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label2, 0, kTagSprite2); - label2->setPosition( Vector2(10,200) ); + label2->setPosition( Vec2(10,200) ); label2->setOpacity( 32 ); schedule(schedule_selector(LabelAtlasTest::step)); @@ -296,12 +296,12 @@ LabelAtlasColorTest::LabelAtlasColorTest() { auto label1 = LabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label1, 0, kTagSprite1); - label1->setPosition( Vector2(10,100) ); + label1->setPosition( Vec2(10,100) ); label1->setOpacity( 200 ); auto label2 = LabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label2, 0, kTagSprite2); - label2->setPosition( Vector2(10,200) ); + label2->setPosition( Vec2(10,200) ); label2->setColor( Color3B::RED ); auto fade = FadeOut::create(1.0f); @@ -358,20 +358,20 @@ LabelTTFAlignment::LabelTTFAlignment() auto ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12, Size(256, 32), TextHAlignment::LEFT); - ttf0->setPosition(Vector2(s.width/2,(s.height/6)*2)); - ttf0->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + ttf0->setPosition(Vec2(s.width/2,(s.height/6)*2)); + ttf0->setAnchorPoint(Vec2::ANCHOR_MIDDLE); this->addChild(ttf0); auto ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, Size(245, 32), TextHAlignment::CENTER); - ttf1->setPosition(Vector2(s.width/2,(s.height/6)*3)); - ttf1->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + ttf1->setPosition(Vec2(s.width/2,(s.height/6)*3)); + ttf1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); this->addChild(ttf1); auto ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, Size(245, 32), TextHAlignment::RIGHT); - ttf2->setPosition(Vector2(s.width/2,(s.height/6)*4)); - ttf2->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + ttf2->setPosition(Vec2(s.width/2,(s.height/6)*4)); + ttf2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); this->addChild(ttf2); } @@ -405,7 +405,7 @@ Atlas3::Atlas3() auto label1 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors - label1->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + label1->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); addChild(label1, 0, kTagBitmapAtlas1); auto fade = FadeOut::create(1.0f); auto fade_in = fade->reverse(); @@ -420,7 +420,7 @@ Atlas3::Atlas3() // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected auto label2 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors - label2->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label2->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); label2->setColor( Color3B::RED ); addChild(label2, 0, kTagBitmapAtlas2); auto tint = Sequence::create(TintTo::create(1, 255, 0, 0), @@ -431,7 +431,7 @@ Atlas3::Atlas3() auto label3 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors - label3->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + label3->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); addChild(label3, 0, kTagBitmapAtlas3); label1->setPosition( VisibleRect::leftBottom() ); @@ -490,8 +490,8 @@ Atlas4::Atlas4() auto s = Director::getInstance()->getWinSize(); - label->setPosition( Vector2(s.width/2, s.height/2) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, s.height/2) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); auto BChar = (Sprite*) label->getChildByTag(0); @@ -507,7 +507,7 @@ Atlas4::Atlas4() auto scale_seq = Sequence::create(scale, scale_back,NULL); auto scale_4ever = RepeatForever::create(scale_seq); - auto jump = JumpBy::create(0.5f, Vector2::ZERO, 60, 1); + auto jump = JumpBy::create(0.5f, Vec2::ZERO, 60, 1); auto jump_4ever = RepeatForever::create(jump); auto fade_out = FadeOut::create(1); @@ -524,7 +524,7 @@ Atlas4::Atlas4() // Bottom Label auto label2 = LabelBMFont::create("00.0", "fonts/bitmapFontTest.fnt"); addChild(label2, 0, kTagBitmapAtlas2); - label2->setPosition( Vector2(s.width/2.0f, 80) ); + label2->setPosition( Vec2(s.width/2.0f, 80) ); auto lastChar = (Sprite*) label2->getChildByTag(3); lastChar->runAction( rot_4ever->clone() ); @@ -532,14 +532,14 @@ Atlas4::Atlas4() schedule( schedule_selector(Atlas4::step), 0.1f); } -void Atlas4::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void Atlas4::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void Atlas4::onDraw(const Matrix &transform, bool transformUpdated) +void Atlas4::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -547,8 +547,8 @@ void Atlas4::onDraw(const Matrix &transform, bool transformUpdated) director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); auto s = Director::getInstance()->getWinSize(); - DrawPrimitives::drawLine( Vector2(0, s.height/2), Vector2(s.width, s.height/2) ); - DrawPrimitives::drawLine( Vector2(s.width/2, 0), Vector2(s.width/2, s.height) ); + DrawPrimitives::drawLine( Vec2(0, s.height/2), Vec2(s.width, s.height/2) ); + DrawPrimitives::drawLine( Vec2(s.width/2, 0), Vec2(s.width/2, s.height) ); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } @@ -594,8 +594,8 @@ Atlas5::Atlas5() auto s = Director::getInstance()->getWinSize(); - label->setPosition( Vector2(s.width/2, s.height/2) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, s.height/2) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); } std::string Atlas5::title() const @@ -626,18 +626,18 @@ Atlas6::Atlas6() LabelBMFont* label = NULL; label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/2+50) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ) ; + label->setPosition( Vec2(s.width/2, s.height/2+50) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ) ; label = LabelBMFont::create("fafefifofu", "fonts/bitmapFontTest5.fnt"); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/2) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, s.height/2) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); label = LabelBMFont::create("aeiou", "fonts/bitmapFontTest5.fnt"); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/2-50) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, s.height/2-50) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); } std::string Atlas6::title() const @@ -669,19 +669,19 @@ AtlasBitmapColor::AtlasBitmapColor() label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt"); label->setColor( Color3B::BLUE ); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/4) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, s.height/4) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); label = LabelBMFont::create("Red", "fonts/bitmapFontTest5.fnt"); addChild(label); - label->setPosition( Vector2(s.width/2, 2*s.height/4) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, 2*s.height/4) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); label->setColor( Color3B::RED ); label = LabelBMFont::create("G", "fonts/bitmapFontTest5.fnt"); addChild(label); - label->setPosition( Vector2(s.width/2, 3*s.height/4) ); - label->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + label->setPosition( Vec2(s.width/2, 3*s.height/4) ); + label->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); label->setColor( Color3B::GREEN ); label->setString("Green"); } @@ -720,9 +720,9 @@ AtlasFastBitmap::AtlasFastBitmap() auto s = Director::getInstance()->getWinSize(); - auto p = Vector2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); + auto p = Vec2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); label->setPosition( p ); - label->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + label->setAnchorPoint(Vec2::ANCHOR_MIDDLE); } } @@ -753,7 +753,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // Left auto label1 = LabelBMFont::create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); - label1->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + label1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); addChild(label1, 0, kTagBitmapAtlas1); s = label1->getContentSize(); @@ -762,7 +762,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // Center auto label2 = LabelBMFont::create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); - label2->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + label2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); addChild(label2, 0, kTagBitmapAtlas2); s= label2->getContentSize(); @@ -770,7 +770,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // right auto label3 = LabelBMFont::create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); - label3->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT); + label3->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); addChild(label3, 0, kTagBitmapAtlas3); s = label3->getContentSize(); @@ -803,17 +803,17 @@ LabelsEmpty::LabelsEmpty() // LabelBMFont auto label1 = LabelBMFont::create("", "fonts/bitmapFontTest3.fnt"); addChild(label1, 0, kTagBitmapAtlas1); - label1->setPosition(Vector2(s.width/2, s.height-100)); + label1->setPosition(Vec2(s.width/2, s.height-100)); // LabelTTF auto label2 = LabelTTF::create("", "Arial", 24); addChild(label2, 0, kTagBitmapAtlas2); - label2->setPosition(Vector2(s.width/2, s.height/2)); + label2->setPosition(Vec2(s.width/2, s.height/2)); // LabelAtlas auto label3 = LabelAtlas::create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label3, 0, kTagBitmapAtlas3); - label3->setPosition(Vector2(s.width/2, 0+100)); + label3->setPosition(Vec2(s.width/2, 0+100)); schedule(schedule_selector(LabelsEmpty::updateStrings), 1.0f); @@ -866,7 +866,7 @@ LabelBMFontHD::LabelBMFontHD() // LabelBMFont auto label1 = LabelBMFont::create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelBMFontHD::title() const @@ -890,10 +890,10 @@ LabelAtlasHD::LabelAtlasHD() // LabelBMFont auto label1 = LabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); - label1->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + label1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelAtlasHD::title() const @@ -921,7 +921,7 @@ LabelGlyphDesigner::LabelGlyphDesigner() // LabelBMFont auto label1 = LabelBMFont::create("Testing Glyph Designer", "fonts/futura-48.fnt"); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelGlyphDesigner::title() const @@ -954,8 +954,8 @@ LabelTTFTest::LabelTTFTest() auto s = Director::getInstance()->getWinSize(); auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); - colorLayer->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - colorLayer->setPosition(Vector2((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); + colorLayer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + colorLayer->setPosition(Vec2((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); this->addChild(colorLayer); @@ -966,7 +966,7 @@ LabelTTFTest::LabelTTFTest() MenuItemFont::create("Right", CC_CALLBACK_1(LabelTTFTest::setAlignmentRight, this)), NULL); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vector2(50, s.height / 2 - 20)); + menu->setPosition(Vec2(50, s.height / 2 - 20)); this->addChild(menu); menu = Menu::create( @@ -975,7 +975,7 @@ LabelTTFTest::LabelTTFTest() MenuItemFont::create("Bottom", CC_CALLBACK_1(LabelTTFTest::setAlignmentBottom, this)), NULL); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vector2(s.width - 50, s.height / 2 - 20)); + menu->setPosition(Vec2(s.width - 50, s.height / 2 - 20)); this->addChild(menu); _label = nullptr; @@ -1006,8 +1006,8 @@ void LabelTTFTest::updateAlignment() blockSize, _horizAlign, _vertAlign); _label->retain(); - _label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - _label->setPosition(Vector2((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); + _label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + _label->setPosition(Vec2((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); this->addChild(_label); } @@ -1099,7 +1099,7 @@ LabelTTFMultiline::LabelTTFMultiline() TextHAlignment::CENTER, TextVAlignment::TOP); - center->setPosition(Vector2(s.width / 2, 150)); + center->setPosition(Vec2(s.width / 2, 150)); addChild(center); } @@ -1118,7 +1118,7 @@ LabelTTFChinese::LabelTTFChinese() { auto size = Director::getInstance()->getWinSize(); auto label = LabelTTF::create("中国", "Marker Felt", 30); - label->setPosition(Vector2(size.width / 2, size.height /2)); + label->setPosition(Vec2(size.width / 2, size.height /2)); this->addChild(label); } @@ -1131,7 +1131,7 @@ LabelBMFontChinese::LabelBMFontChinese() { auto size = Director::getInstance()->getWinSize(); auto label = LabelBMFont::create("中国", "fonts/bitmapFontChinese.fnt"); - label->setPosition(Vector2(size.width / 2, size.height /2)); + label->setPosition(Vec2(size.width / 2, size.height /2)); this->addChild(label); } @@ -1208,18 +1208,18 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() right->setTag(RightAlign); // position the label on the center of the screen - _labelShouldRetain->setPosition(Vector2(size.width/2, size.height/2)); + _labelShouldRetain->setPosition(Vec2(size.width/2, size.height/2)); _arrowsBarShouldRetain->setVisible(false); float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width; _arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width); - _arrowsBarShouldRetain->setPosition(Vector2(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); + _arrowsBarShouldRetain->setPosition(Vec2(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); this->snapArrowsToEdge(); - stringMenu->setPosition(Vector2(size.width/2, size.height - menuItemPaddingCenter)); - alignmentMenu->setPosition(Vector2(size.width/2, menuItemPaddingCenter+15)); + stringMenu->setPosition(Vec2(size.width/2, size.height - menuItemPaddingCenter)); + alignmentMenu->setPosition(Vec2(size.width/2, menuItemPaddingCenter+15)); addChild(_labelShouldRetain); addChild(_arrowsBarShouldRetain); @@ -1329,7 +1329,7 @@ void BitmapFontMultiLineAlignment::onTouchesMoved(const std::vector& tou auto winSize = Director::getInstance()->getWinSize(); - this->_arrowsShouldRetain->setPosition(Vector2(MAX(MIN(location.x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), + this->_arrowsShouldRetain->setPosition(Vec2(MAX(MIN(location.x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), this->_arrowsShouldRetain->getPosition().y)); float labelWidth = fabs(this->_arrowsShouldRetain->getPosition().x - this->_labelShouldRetain->getPosition().x) * 2; @@ -1339,7 +1339,7 @@ void BitmapFontMultiLineAlignment::onTouchesMoved(const std::vector& tou void BitmapFontMultiLineAlignment::snapArrowsToEdge() { - this->_arrowsShouldRetain->setPosition(Vector2(this->_labelShouldRetain->getPosition().x + this->_labelShouldRetain->getContentSize().width/2, + this->_arrowsShouldRetain->setPosition(Vec2(this->_labelShouldRetain->getPosition().x + this->_labelShouldRetain->getContentSize().width/2, this->_labelShouldRetain->getPosition().y)); } @@ -1355,7 +1355,7 @@ LabelTTFA8Test::LabelTTFA8Test() auto label1 = LabelTTF::create("Testing A8 Format", "Marker Felt", 48); addChild(label1); label1->setColor(Color3B::RED); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); auto fadeOut = FadeOut::create(2); auto fadeIn = FadeIn::create(2); @@ -1381,11 +1381,11 @@ BMFontOneAtlas::BMFontOneAtlas() auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt"); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/3*2)); + label1->setPosition(Vec2(s.width/2, s.height/3*2)); - auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", 0, TextHAlignment::LEFT, Vector2(0, 128)); + auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", 0, TextHAlignment::LEFT, Vec2(0, 128)); addChild(label2); - label2->setPosition(Vector2(s.width/2, s.height/3*1)); + label2->setPosition(Vec2(s.width/2, s.height/3*1)); } std::string BMFontOneAtlas::title() const @@ -1411,19 +1411,19 @@ BMFontUnicode::BMFontUnicode() auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, TextHAlignment::LEFT); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/5*4)); + label1->setPosition(Vec2(s.width/2, s.height/5*4)); auto label2 = LabelBMFont::create(chinese, "fonts/arial-unicode-26.fnt"); addChild(label2); - label2->setPosition(Vector2(s.width/2, s.height/5*3)); + label2->setPosition(Vec2(s.width/2, s.height/5*3)); auto label3 = LabelBMFont::create(russian, "fonts/arial-26-en-ru.fnt"); addChild(label3); - label3->setPosition(Vector2(s.width/2, s.height/5*2)); + label3->setPosition(Vec2(s.width/2, s.height/5*2)); auto label4 = LabelBMFont::create(japanese, "fonts/arial-unicode-26.fnt"); addChild(label4); - label4->setPosition(Vector2(s.width/2, s.height/5*1)); + label4->setPosition(Vec2(s.width/2, s.height/5*1)); } std::string BMFontUnicode::title() const @@ -1447,7 +1447,7 @@ BMFontInit::BMFontInit() bmFont->setFntFile("fonts/helvetica-32.fnt"); bmFont->setString("It is working!"); this->addChild(bmFont); - bmFont->setPosition(Vector2(s.width/2,s.height/4*2)); + bmFont->setPosition(Vec2(s.width/2,s.height/4*2)); } std::string BMFontInit::title() const @@ -1472,7 +1472,7 @@ TTFFontInit::TTFFontInit() font->setFontSize(48); font->setString("It is working!"); this->addChild(font); - font->setPosition(Vector2(s.width/2,s.height/4*2)); + font->setPosition(Vec2(s.width/2,s.height/4*2)); } std::string TTFFontInit::title() const @@ -1515,7 +1515,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() // add label to the scene this->addChild(fontShadow); - fontShadow->setPosition(Vector2(s.width/2,s.height/4*2.5)); + fontShadow->setPosition(Vec2(s.width/2,s.height/4*2.5)); // create the stroke only label @@ -1534,7 +1534,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() // add label to the scene this->addChild(fontStroke); - fontStroke->setPosition(Vector2(s.width/2,s.height/4*1.8)); + fontStroke->setPosition(Vec2(s.width/2,s.height/4*1.8)); @@ -1564,10 +1564,10 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() // add label to the scene this->addChild(fontStrokeAndShadow); - fontStrokeAndShadow->setPosition(Vector2(s.width/2,s.height/4*1.1)); + fontStrokeAndShadow->setPosition(Vec2(s.width/2,s.height/4*1.1)); auto buttonBG = MenuItemImage::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - buttonBG->setAnchorPoint(Vector2::ANCHOR_MIDDLE_LEFT); + buttonBG->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); buttonBG->setPosition(VisibleRect::left()); // create the label stroke and shadow @@ -1590,11 +1590,11 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() // add label to the scene buttonBG->addChild(fontStrokeAndShadow); - fontStrokeAndShadow->setPosition(Vector2(buttonBG->getContentSize().width/2, buttonBG->getContentSize().height/2)); + fontStrokeAndShadow->setPosition(Vec2(buttonBG->getContentSize().width/2, buttonBG->getContentSize().height/2)); auto menu = Menu::create(buttonBG, nullptr); - menu->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - menu->setPosition(Vector2::ZERO); + menu->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + menu->setPosition(Vec2::ZERO); addChild(menu); } @@ -1623,7 +1623,7 @@ Issue1343::Issue1343() this->addChild(bmFont); bmFont->setScale(0.3f); - bmFont->setPosition(Vector2(s.width/2,s.height/4*2)); + bmFont->setPosition(Vec2(s.width/2,s.height/4*2)); } std::string Issue1343::title() const @@ -1647,7 +1647,7 @@ LabelBMFontBounds::LabelBMFontBounds() label1 = LabelBMFont::create("Testing Glyph Designer", "fonts/boundsTestFont.fnt"); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelBMFontBounds::title() const @@ -1660,14 +1660,14 @@ std::string LabelBMFontBounds::subtitle() const return "You should see string enclosed by a box"; } -void LabelBMFontBounds::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LabelBMFontBounds::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void LabelBMFontBounds::onDraw(const Matrix &transform, bool transformUpdated) +void LabelBMFontBounds::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1680,12 +1680,12 @@ void LabelBMFontBounds::onDraw(const Matrix &transform, bool transformUpdated) origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); - Vector2 vertices[4]= + Vec2 vertices[4]= { - Vector2(origin.width, origin.height), - Vector2(labelSize.width + origin.width, origin.height), - Vector2(labelSize.width + origin.width, labelSize.height + origin.height), - Vector2(origin.width, labelSize.height + origin.height) + Vec2(origin.width, origin.height), + Vec2(labelSize.width + origin.width, origin.height), + Vec2(labelSize.width + origin.width, labelSize.height + origin.height), + Vec2(origin.width, labelSize.height + origin.height) }; DrawPrimitives::drawPoly(vertices, 4, true); @@ -1711,7 +1711,7 @@ void LabelBMFontCrashTest::onEnter() // Create a new label and add it (then crashes) auto label2 = LabelBMFont::create("test 2", "fonts/bitmapFontTest.fnt"); - label2->setPosition(Vector2(winSize.width/2, winSize.height/2)); + label2->setPosition(Vec2(winSize.width/2, winSize.height/2)); this->addChild(label2); } @@ -1735,7 +1735,7 @@ LabelBMFontBinaryFormat::LabelBMFontBinaryFormat() bmFont->setFntFile("fonts/Roboto.bmf.fnt"); bmFont->setString("It is working!"); this->addChild(bmFont); - bmFont->setPosition(Vector2(s.width/2,s.height/4*2)); + bmFont->setPosition(Vec2(s.width/2,s.height/4*2)); } std::string LabelBMFontBinaryFormat::title() const diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.h b/tests/cpp-tests/Classes/LabelTest/LabelTest.h index 6b3bd33291..40b2e74aee 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.h @@ -41,9 +41,9 @@ public: ~Atlas1(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); protected: CustomCommand _customCommand; }; @@ -108,12 +108,12 @@ public: Atlas4(); virtual void step(float dt); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); protected: CustomCommand _customCommand; }; @@ -383,11 +383,11 @@ public: LabelBMFontBounds(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); private: LabelBMFont *label1; CustomCommand _customCommand; diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index a1d681f92a..1d8ee072f9 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -173,15 +173,15 @@ LabelTTFAlignmentNew::LabelTTFAlignmentNew() TTFConfig config("fonts/tahoma.ttf",16); auto ttf0 = Label::createWithTTF(config,"Alignment 0\nnew line",TextHAlignment::LEFT); - ttf0->setPosition(Vector2(s.width/2,(s.height/6)*2 - 30)); + ttf0->setPosition(Vec2(s.width/2,(s.height/6)*2 - 30)); this->addChild(ttf0); auto ttf1 = Label::createWithTTF(config,"Alignment 1\nnew line",TextHAlignment::CENTER); - ttf1->setPosition(Vector2(s.width/2,(s.height/6)*3 - 30)); + ttf1->setPosition(Vec2(s.width/2,(s.height/6)*3 - 30)); this->addChild(ttf1); auto ttf2 = Label::createWithTTF(config,"Alignment 2\nnew line",TextHAlignment::RIGHT); - ttf2->setPosition(Vector2(s.width/2,(s.height/6)*4 - 30)); + ttf2->setPosition(Vec2(s.width/2,(s.height/6)*4 - 30)); this->addChild(ttf2); } @@ -204,7 +204,7 @@ LabelFNTColorAndOpacity::LabelFNTColorAndOpacity() auto label1 = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "Test"); - label1->setAnchorPoint( Vector2(0,0) ); + label1->setAnchorPoint( Vec2(0,0) ); addChild(label1, 0, kTagBitmapAtlas1); auto fade = FadeOut::create(1.0f); auto fade_in = fade->reverse(); @@ -222,7 +222,7 @@ LabelFNTColorAndOpacity::LabelFNTColorAndOpacity() label2->runAction( RepeatForever::create(tint) ); auto label3 = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "Test"); - label3->setAnchorPoint( Vector2(1,1) ); + label3->setAnchorPoint( Vec2(1,1) ); addChild(label3, 0, kTagBitmapAtlas3); label1->setPosition( VisibleRect::leftBottom() ); @@ -268,7 +268,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() auto s = Director::getInstance()->getWinSize(); - label->setPosition( Vector2(s.width/2, s.height/2) ); + label->setPosition( Vec2(s.width/2, s.height/2) ); auto BChar = (Sprite*) label->getLetter(0); auto FChar = (Sprite*) label->getLetter(7); @@ -283,7 +283,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() auto scale_seq = Sequence::create(scale, scale_back,NULL); auto scale_4ever = RepeatForever::create(scale_seq); - auto jump = JumpBy::create(0.5f, Vector2::ZERO, 60, 1); + auto jump = JumpBy::create(0.5f, Vec2::ZERO, 60, 1); auto jump_4ever = RepeatForever::create(jump); auto fade_out = FadeOut::create(1); @@ -300,7 +300,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() // Bottom Label auto label2 = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "00.0"); addChild(label2, 0, kTagBitmapAtlas2); - label2->setPosition( Vector2(s.width/2.0f, 80) ); + label2->setPosition( Vec2(s.width/2.0f, 80) ); auto lastChar = (Sprite*) label2->getLetter(3); lastChar->runAction( rot_4ever->clone() ); @@ -308,7 +308,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() schedule( schedule_selector(LabelFNTSpriteActions::step), 0.1f); } -void LabelFNTSpriteActions::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LabelFNTSpriteActions::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this, transform, transformUpdated); @@ -316,7 +316,7 @@ void LabelFNTSpriteActions::draw(Renderer *renderer, const Matrix &transform, bo } -void LabelFNTSpriteActions::onDraw(const Matrix &transform, bool transformUpdated) +void LabelFNTSpriteActions::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -324,8 +324,8 @@ void LabelFNTSpriteActions::onDraw(const Matrix &transform, bool transformUpdate director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); auto s = Director::getInstance()->getWinSize(); - DrawPrimitives::drawLine( Vector2(0, s.height/2), Vector2(s.width, s.height/2) ); - DrawPrimitives::drawLine( Vector2(s.width/2, 0), Vector2(s.width/2, s.height) ); + DrawPrimitives::drawLine( Vec2(0, s.height/2), Vec2(s.width, s.height/2) ); + DrawPrimitives::drawLine( Vec2(s.width/2, 0), Vec2(s.width/2, s.height) ); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } @@ -356,7 +356,7 @@ LabelFNTPadding::LabelFNTPadding() auto s = Director::getInstance()->getWinSize(); - label->setPosition( Vector2(s.width/2, s.height/2) ); + label->setPosition( Vec2(s.width/2, s.height/2) ); } std::string LabelFNTPadding::title() const @@ -376,15 +376,15 @@ LabelFNTOffset::LabelFNTOffset() Label* label = nullptr; label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "FaFeFiFoFu"); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/2+50) ); + label->setPosition( Vec2(s.width/2, s.height/2+50) ); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "fafefifofu"); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/2) ); + label->setPosition( Vec2(s.width/2, s.height/2) ); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "aeiou"); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/2-50) ); + label->setPosition( Vec2(s.width/2, s.height/2-50) ); } std::string LabelFNTOffset::title() const @@ -405,16 +405,16 @@ LabelFNTColor::LabelFNTColor() label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Blue"); label->setColor( Color3B::BLUE ); addChild(label); - label->setPosition( Vector2(s.width/2, s.height/4) ); + label->setPosition( Vec2(s.width/2, s.height/4) ); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Red"); addChild(label); - label->setPosition( Vector2(s.width/2, 2*s.height/4) ); + label->setPosition( Vec2(s.width/2, 2*s.height/4) ); label->setColor( Color3B::RED ); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Green"); addChild(label); - label->setPosition( Vector2(s.width/2, 3*s.height/4) ); + label->setPosition( Vec2(s.width/2, 3*s.height/4) ); label->setColor( Color3B::GREEN ); label->setString("Green"); } @@ -441,7 +441,7 @@ LabelFNTHundredLabels::LabelFNTHundredLabels() auto s = Director::getInstance()->getWinSize(); - auto p = Vector2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); + auto p = Vec2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); label->setPosition( p ); } } @@ -462,7 +462,7 @@ LabelFNTMultiLine::LabelFNTMultiLine() // Left auto label1 = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", " Multi line\nLeft"); - label1->setAnchorPoint(Vector2(0,0)); + label1->setAnchorPoint(Vec2(0,0)); addChild(label1, 0, kTagBitmapAtlas1); s = label1->getContentSize(); @@ -478,7 +478,7 @@ LabelFNTMultiLine::LabelFNTMultiLine() // right auto label3 = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", "Multi line\nRight\nThree lines Three"); - label3->setAnchorPoint(Vector2(1, 1)); + label3->setAnchorPoint(Vec2(1, 1)); addChild(label3, 0, kTagBitmapAtlas3); s = label3->getContentSize(); @@ -506,17 +506,17 @@ LabelFNTandTTFEmpty::LabelFNTandTTFEmpty() // LabelBMFont auto label1 = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", "", TextHAlignment::CENTER, s.width); addChild(label1, 0, kTagBitmapAtlas1); - label1->setPosition(Vector2(s.width/2, s.height - 100)); + label1->setPosition(Vec2(s.width/2, s.height - 100)); // LabelTTF TTFConfig ttfConfig("fonts/arial.ttf",24); auto label2 = Label::createWithTTF(ttfConfig,"", TextHAlignment::CENTER,s.width); addChild(label2, 0, kTagBitmapAtlas2); - label2->setPosition(Vector2(s.width/2, s.height / 2)); + label2->setPosition(Vec2(s.width/2, s.height / 2)); auto label3 = Label::createWithCharMap("fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label3, 0, kTagBitmapAtlas3); - label3->setPosition(Vector2(s.width/2, 100)); + label3->setPosition(Vec2(s.width/2, 100)); schedule(schedule_selector(LabelFNTandTTFEmpty::updateStrings), 1.0f); @@ -564,7 +564,7 @@ LabelFNTRetina::LabelFNTRetina() // LabelBMFont auto label1 = Label::createWithBMFont("fonts/konqa32.fnt", "TESTING RETINA DISPLAY"); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelFNTRetina::title() const @@ -587,7 +587,7 @@ LabelFNTGlyphDesigner::LabelFNTGlyphDesigner() // LabelBMFont auto label1 = Label::createWithBMFont("fonts/futura-48.fnt", "Testing Glyph Designer"); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelFNTGlyphDesigner::title() const @@ -607,7 +607,7 @@ LabelTTFUnicodeChinese::LabelTTFUnicodeChinese() // like "Error 3 error C2146: syntax error : missing ')' before identifier 'label'"; TTFConfig ttfConfig("fonts/wt021.ttf",28,GlyphCollection::CUSTOM, "美好的一天啊"); auto label = Label::createWithTTF(ttfConfig,"美好的一天啊", TextHAlignment::CENTER, size.width); - label->setPosition(Vector2(size.width / 2, size.height /2)); + label->setPosition(Vec2(size.width / 2, size.height /2)); this->addChild(label); } @@ -625,7 +625,7 @@ LabelFNTUnicodeChinese::LabelFNTUnicodeChinese() { auto size = Director::getInstance()->getWinSize(); auto label = Label::createWithBMFont("fonts/bitmapFontChinese.fnt", "中国"); - label->setPosition(Vector2(size.width / 2, size.height /2)); + label->setPosition(Vec2(size.width / 2, size.height /2)); this->addChild(label); } @@ -708,18 +708,18 @@ LabelFNTMultiLineAlignment::LabelFNTMultiLineAlignment() right->setTag(RightAlign); // position the label on the center of the screen - this->_labelShouldRetain->setPosition(Vector2(size.width/2, size.height/2)); + this->_labelShouldRetain->setPosition(Vec2(size.width/2, size.height/2)); this->_arrowsBarShouldRetain->setVisible(false); float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width; this->_arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width); - this->_arrowsBarShouldRetain->setPosition(Vector2(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); + this->_arrowsBarShouldRetain->setPosition(Vec2(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); this->snapArrowsToEdge(); - stringMenu->setPosition(Vector2(size.width/2, size.height - menuItemPaddingCenter)); - alignmentMenu->setPosition(Vector2(size.width/2, menuItemPaddingCenter+15)); + stringMenu->setPosition(Vec2(size.width/2, size.height - menuItemPaddingCenter)); + alignmentMenu->setPosition(Vec2(size.width/2, menuItemPaddingCenter+15)); this->addChild(this->_labelShouldRetain); this->addChild(this->_arrowsBarShouldRetain); @@ -829,7 +829,7 @@ void LabelFNTMultiLineAlignment::onTouchesMoved(const std::vector& touch auto winSize = Director::getInstance()->getWinSize(); - this->_arrowsShouldRetain->setPosition(Vector2(MAX(MIN(location.x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), + this->_arrowsShouldRetain->setPosition(Vec2(MAX(MIN(location.x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), this->_arrowsShouldRetain->getPosition().y)); float labelWidth = fabs(this->_arrowsShouldRetain->getPosition().x - this->_labelShouldRetain->getPosition().x) * 2; @@ -839,7 +839,7 @@ void LabelFNTMultiLineAlignment::onTouchesMoved(const std::vector& touch void LabelFNTMultiLineAlignment::snapArrowsToEdge() { - this->_arrowsShouldRetain->setPosition(Vector2(this->_labelShouldRetain->getPosition().x + this->_labelShouldRetain->getContentSize().width/2, + this->_arrowsShouldRetain->setPosition(Vec2(this->_labelShouldRetain->getPosition().x + this->_labelShouldRetain->getContentSize().width/2, this->_labelShouldRetain->getPosition().y)); } @@ -856,19 +856,19 @@ LabelFNTUNICODELanguages::LabelFNTUNICODELanguages() auto label1 = Label::createWithBMFont("fonts/arial-unicode-26.fnt", spanish, TextHAlignment::CENTER, 200); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/5*3)); + label1->setPosition(Vec2(s.width/2, s.height/5*3)); auto label2 = Label::createWithBMFont("fonts/arial-unicode-26.fnt", chinese); addChild(label2); - label2->setPosition(Vector2(s.width/2, s.height/5*2.5)); + label2->setPosition(Vec2(s.width/2, s.height/5*2.5)); auto label3 = Label::createWithBMFont("fonts/arial-26-en-ru.fnt", russian); addChild(label3); - label3->setPosition(Vector2(s.width/2, s.height/5*2)); + label3->setPosition(Vec2(s.width/2, s.height/5*2)); auto label4 = Label::createWithBMFont("fonts/arial-unicode-26.fnt", japanese); addChild(label4); - label4->setPosition(Vector2(s.width/2, s.height/5*1.5)); + label4->setPosition(Vec2(s.width/2, s.height/5*1.5)); } std::string LabelFNTUNICODELanguages::title() const @@ -891,7 +891,7 @@ LabelFNTBounds::LabelFNTBounds() // LabelBMFont label1 = Label::createWithBMFont("fonts/boundsTestFont.fnt", "Testing Glyph Designer", TextHAlignment::CENTER,s.width); addChild(label1); - label1->setPosition(Vector2(s.width/2, s.height/2)); + label1->setPosition(Vec2(s.width/2, s.height/2)); } std::string LabelFNTBounds::title() const @@ -904,14 +904,14 @@ std::string LabelFNTBounds::subtitle() const return "You should see string enclosed by a box"; } -void LabelFNTBounds::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LabelFNTBounds::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this, transform, transformUpdated); renderer->addCommand(&_renderCmd); } -void LabelFNTBounds::onDraw(const Matrix &transform, bool transformUpdated) +void LabelFNTBounds::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -924,12 +924,12 @@ void LabelFNTBounds::onDraw(const Matrix &transform, bool transformUpdated) origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); - Vector2 vertices[4]= + Vec2 vertices[4]= { - Vector2(origin.width, origin.height), - Vector2(labelSize.width + origin.width, origin.height), - Vector2(labelSize.width + origin.width, labelSize.height + origin.height), - Vector2(origin.width, labelSize.height + origin.height) + Vec2(origin.width, origin.height), + Vec2(labelSize.width + origin.width, origin.height), + Vec2(labelSize.width + origin.width, labelSize.height + origin.height), + Vec2(origin.width, labelSize.height + origin.height) }; DrawPrimitives::drawPoly(vertices, 4, true); @@ -943,8 +943,8 @@ LabelTTFLongLineWrapping::LabelTTFLongLineWrapping() // Long sentence TTFConfig ttfConfig("fonts/arial.ttf", 14); auto label1 = Label::createWithTTF(ttfConfig, LongSentencesExample, TextHAlignment::CENTER,size.width); - label1->setPosition( Vector2(size.width/2, size.height/2) ); - label1->setAnchorPoint(Vector2(0.5, 1.0)); + label1->setPosition( Vec2(size.width/2, size.height/2) ); + label1->setAnchorPoint(Vec2(0.5, 1.0)); addChild(label1); } @@ -966,7 +966,7 @@ LabelTTFLargeText::LabelTTFLargeText() TTFConfig ttfConfig("fonts/wt021.ttf",18,GlyphCollection::DYNAMIC); std::string text = FileUtils::getInstance()->getStringFromFile("commonly_used_words.txt"); auto label = Label::createWithTTF(ttfConfig,text, TextHAlignment::CENTER, size.width); - label->setPosition( Vector2(size.width/2, size.height/2) ); + label->setPosition( Vec2(size.width/2, size.height/2) ); addChild(label); } @@ -987,19 +987,19 @@ LabelTTFColor::LabelTTFColor() TTFConfig ttfConfig("fonts/arial.ttf", 18); // Green auto label1 = Label::createWithTTF(ttfConfig,"Green", TextHAlignment::CENTER, size.width); - label1->setPosition( Vector2(size.width/2, size.height * 0.3f) ); + label1->setPosition( Vec2(size.width/2, size.height * 0.3f) ); label1->setTextColor( Color4B::GREEN ); addChild(label1); // Red auto label2 = Label::createWithTTF(ttfConfig,"Red", TextHAlignment::CENTER, size.width); - label2->setPosition( Vector2(size.width/2, size.height * 0.4f) ); + label2->setPosition( Vec2(size.width/2, size.height * 0.4f) ); label2->setTextColor( Color4B::RED ); addChild(label2); // Blue auto label3 = Label::createWithTTF(ttfConfig,"Blue", TextHAlignment::CENTER, size.width); - label3->setPosition( Vector2(size.width/2, size.height * 0.5f) ); + label3->setPosition( Vec2(size.width/2, size.height * 0.5f) ); label3->setTextColor( Color4B::BLUE ); addChild(label3); } @@ -1019,7 +1019,7 @@ LabelTTFDynamicAlignment::LabelTTFDynamicAlignment() auto size = Director::getInstance()->getWinSize(); TTFConfig ttfConfig("fonts/arial.ttf", 23); _label = Label::createWithTTF(ttfConfig,LongSentencesExample, TextHAlignment::CENTER, size.width); - _label->setPosition( Vector2(size.width/2, size.height/2) ); + _label->setPosition( Vec2(size.width/2, size.height/2) ); auto menu = Menu::create( MenuItemFont::create("Left", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentLeft, this)), @@ -1028,7 +1028,7 @@ LabelTTFDynamicAlignment::LabelTTFDynamicAlignment() NULL); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vector2(50, size.height / 4 )); + menu->setPosition(Vec2(50, size.height / 4 )); addChild(_label); this->addChild(menu); @@ -1078,34 +1078,34 @@ LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest() auto size = Director::getInstance()->getWinSize(); auto drawNode = DrawNode::create(); - drawNode->setAnchorPoint(Vector2(0, 0)); + drawNode->setAnchorPoint(Vec2(0, 0)); this->addChild(drawNode); drawNode->drawSegment( - Vector2(size.width * 0.1, size.height * 0.8), - Vector2(size.width * 0.1, 0), 1, Color4F(1, 0, 0, 1)); + Vec2(size.width * 0.1, size.height * 0.8), + Vec2(size.width * 0.1, 0), 1, Color4F(1, 0, 0, 1)); drawNode->drawSegment( - Vector2(size.width * 0.85, size.height * 0.8), - Vector2(size.width * 0.85, 0), 1, Color4F(1, 0, 0, 1)); + Vec2(size.width * 0.85, size.height * 0.8), + Vec2(size.width * 0.85, 0), 1, Color4F(1, 0, 0, 1)); TTFConfig ttfConfig("fonts/wt021.ttf", 25, GlyphCollection::DYNAMIC); auto label1 = Label::createWithTTF(ttfConfig, "你好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75); label1->setTextColor(Color4B(128, 255, 255, 255)); - label1->setPosition(Vector2(size.width * 0.1, size.height * 0.6)); - label1->setAnchorPoint(Vector2(0, 0.5)); + label1->setPosition(Vec2(size.width * 0.1, size.height * 0.6)); + label1->setAnchorPoint(Vec2(0, 0.5)); this->addChild(label1); auto label2 = Label::createWithTTF(ttfConfig, "早上好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75); label2->setTextColor(Color4B(255, 128, 255, 255)); - label2->setPosition(Vector2(size.width * 0.1, size.height * 0.4)); - label2->setAnchorPoint(Vector2(0, 0.5)); + label2->setPosition(Vec2(size.width * 0.1, size.height * 0.4)); + label2->setAnchorPoint(Vec2(0, 0.5)); this->addChild(label2); auto label3 = Label::createWithTTF(ttfConfig, "美好的一天啊美好的一天啊美好的一天啊", TextHAlignment::LEFT, size.width * 0.75); label3->setTextColor(Color4B(255, 255, 128, 255)); - label3->setPosition(Vector2(size.width * 0.1, size.height * 0.2)); - label3->setAnchorPoint(Vector2(0, 0.5)); + label3->setPosition(Vec2(size.width * 0.1, size.height * 0.2)); + label3->setAnchorPoint(Vec2(0, 0.5)); this->addChild(label3); } @@ -1140,12 +1140,12 @@ LabelTTFUnicodeNew::LabelTTFUnicodeNew() TTFConfig ttfConfig("fonts/arial.ttf", 23,GlyphCollection::ASCII); // Spanish auto label1 = Label::createWithTTF(ttfConfig,"Buen día, ¿cómo te llamas?", TextHAlignment::CENTER, size.width); - label1->setPosition( Vector2(size.width/2, vSize - (vStep * 4.5)) ); + label1->setPosition( Vec2(size.width/2, vSize - (vStep * 4.5)) ); addChild(label1); // German auto label2 = Label::createWithTTF(ttfConfig,"In welcher Straße haben Sie gelebt?", TextHAlignment::CENTER,size.width); - label2->setPosition( Vector2(size.width/2, vSize - (vStep * 5.5)) ); + label2->setPosition( Vec2(size.width/2, vSize - (vStep * 5.5)) ); addChild(label2); // chinese @@ -1153,7 +1153,7 @@ LabelTTFUnicodeNew::LabelTTFUnicodeNew() ttfConfig.glyphs = GlyphCollection::CUSTOM; ttfConfig.customGlyphs = chinese.c_str(); auto label3 = Label::createWithTTF(ttfConfig,chinese, TextHAlignment::CENTER,size.width); - label3->setPosition( Vector2(size.width/2, vSize - (vStep * 6.5)) ); + label3->setPosition( Vec2(size.width/2, vSize - (vStep * 6.5)) ); addChild(label3); } @@ -1186,7 +1186,7 @@ LabelTTFFontsTestNew::LabelTTFFontsTestNew() ttfConfig.fontFilePath = ttfpaths[i]; auto label = Label::createWithTTF(ttfConfig, ttfpaths[i], TextHAlignment::CENTER,0); if( label ) { - label->setPosition( Vector2(size.width/2, ((size.height * 0.6)/arraysize(ttfpaths) * i) + (size.height/5))); + label->setPosition( Vec2(size.width/2, ((size.height * 0.6)/arraysize(ttfpaths) * i) + (size.height/5))); addChild(label); } else { log("ERROR: Cannot load: %s", ttfpaths[i]); @@ -1209,7 +1209,7 @@ LabelBMFontTestNew::LabelBMFontTestNew() auto size = Director::getInstance()->getWinSize(); auto label1 = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "Hello World, this is testing the new Label using fnt file", TextHAlignment::CENTER, size.width); - label1->setPosition( Vector2(size.width/2, size.height/2) ); + label1->setPosition( Vec2(size.width/2, size.height/2) ); addChild(label1); } @@ -1229,7 +1229,7 @@ LabelTTFDistanceField::LabelTTFDistanceField() TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,true); auto label1 = Label::createWithTTF(ttfConfig,"Distance Field",TextHAlignment::CENTER,size.width); - label1->setPosition( Vector2(size.width/2, size.height * 0.6f) ); + label1->setPosition( Vec2(size.width/2, size.height * 0.6f) ); label1->setTextColor( Color4B::GREEN ); addChild(label1); @@ -1241,7 +1241,7 @@ LabelTTFDistanceField::LabelTTFDistanceField() label1->runAction(RepeatForever::create(action)); auto label2 = Label::createWithTTF(ttfConfig,"Distance Field",TextHAlignment::CENTER,size.width); - label2->setPosition( Vector2(size.width/2, size.height * 0.3f) ); + label2->setPosition( Vec2(size.width/2, size.height * 0.3f) ); label2->setTextColor( Color4B::RED ); addChild(label2); } @@ -1266,28 +1266,28 @@ LabelOutlineAndGlowTest::LabelOutlineAndGlowTest() TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,true); auto label1 = Label::createWithTTF(ttfConfig,"Glow", TextHAlignment::CENTER, size.width); - label1->setPosition( Vector2(size.width/2, size.height*0.7) ); + label1->setPosition( Vec2(size.width/2, size.height*0.7) ); label1->setTextColor( Color4B::GREEN ); label1->enableGlow(Color4B::YELLOW); addChild(label1); ttfConfig.outlineSize = 1; auto label2 = Label::createWithTTF(ttfConfig,"Outline", TextHAlignment::CENTER, size.width); - label2->setPosition( Vector2(size.width/2, size.height*0.6) ); + label2->setPosition( Vec2(size.width/2, size.height*0.6) ); label2->setTextColor( Color4B::RED ); label2->enableOutline(Color4B::BLUE); addChild(label2); ttfConfig.outlineSize = 2; auto label3 = Label::createWithTTF(ttfConfig,"Outline", TextHAlignment::CENTER, size.width); - label3->setPosition( Vector2(size.width/2, size.height*0.48) ); + label3->setPosition( Vec2(size.width/2, size.height*0.48) ); label3->setTextColor( Color4B::RED ); label3->enableOutline(Color4B::BLUE); addChild(label3); ttfConfig.outlineSize = 3; auto label4 = Label::createWithTTF(ttfConfig,"Outline", TextHAlignment::CENTER, size.width); - label4->setPosition( Vector2(size.width/2, size.height*0.36) ); + label4->setPosition( Vec2(size.width/2, size.height*0.36) ); label4->setTextColor( Color4B::RED ); label4->enableOutline(Color4B::BLUE); addChild(label4); @@ -1313,20 +1313,20 @@ LabelShadowTest::LabelShadowTest() TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,true); shadowLabelTTF = Label::createWithTTF(ttfConfig,"TTF:Shadow"); - shadowLabelTTF->setPosition( Vector2(size.width/2, size.height*0.65f) ); + shadowLabelTTF->setPosition( Vec2(size.width/2, size.height*0.65f) ); shadowLabelTTF->setTextColor( Color4B::RED ); shadowLabelTTF->enableShadow(Color4B::BLACK); addChild(shadowLabelTTF); shadowLabelOutline = Label::createWithTTF(ttfConfig,"TTF:Shadow"); - shadowLabelOutline->setPosition( Vector2(size.width/2, size.height*0.5f) ); + shadowLabelOutline->setPosition( Vec2(size.width/2, size.height*0.5f) ); shadowLabelOutline->setTextColor( Color4B::RED ); shadowLabelOutline->enableOutline(Color4B::YELLOW,1); shadowLabelOutline->enableShadow(Color4B::BLACK); addChild(shadowLabelOutline); shadowLabelBMFont = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "BMFont:Shadow"); - shadowLabelBMFont->setPosition( Vector2(size.width/2, size.height*0.35f) ); + shadowLabelBMFont->setPosition( Vec2(size.width/2, size.height*0.35f) ); shadowLabelBMFont->setColor( Color3B::RED ); shadowLabelBMFont->enableShadow(Color4B::GREEN); addChild(shadowLabelBMFont); @@ -1337,7 +1337,7 @@ LabelShadowTest::LabelShadowTest() slider->loadBarTexture("cocosui/sliderTrack.png"); slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider->setPosition(Vector2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f)); + slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f)); slider->setPercent(52); slider->addEventListener(CC_CALLBACK_2(LabelShadowTest::sliderEvent, this)); addChild(slider); @@ -1348,7 +1348,7 @@ LabelShadowTest::LabelShadowTest() slider2->loadBarTexture("cocosui/sliderTrack.png"); slider2->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider2->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider2->setPosition(Vector2(size.width * 0.15f, size.height / 2.0)); + slider2->setPosition(Vec2(size.width * 0.15f, size.height / 2.0)); slider2->setRotation(90); slider2->setPercent(52); slider2->addEventListener(CC_CALLBACK_2(LabelShadowTest::sliderEvent, this)); @@ -1385,14 +1385,14 @@ LabelCharMapTest::LabelCharMapTest() auto label1 = Label::createWithCharMap("fonts/tuffy_bold_italic-charmap.plist"); addChild(label1, 0, kTagSprite1); - label1->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - label1->setPosition( Vector2(10,100) ); + label1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + label1->setPosition( Vec2(10,100) ); label1->setOpacity( 200 ); auto label2 = Label::createWithCharMap("fonts/tuffy_bold_italic-charmap.plist"); addChild(label2, 0, kTagSprite2); - label2->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - label2->setPosition( Vector2(10,200) ); + label2->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + label2->setPosition( Vec2(10,200) ); label2->setOpacity( 32 ); schedule(schedule_selector(LabelCharMapTest::step)); @@ -1431,14 +1431,14 @@ LabelCharMapColorTest::LabelCharMapColorTest() { auto label1 = Label::createWithCharMap( "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label1, 0, kTagSprite1); - label1->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - label1->setPosition( Vector2(10,100) ); + label1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + label1->setPosition( Vec2(10,100) ); label1->setOpacity( 200 ); auto label2 = Label::createWithCharMap("fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label2, 0, kTagSprite2); - label2->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - label2->setPosition( Vector2(10,200) ); + label2->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + label2->setPosition( Vec2(10,200) ); label2->setColor( Color3B::RED ); auto fade = FadeOut::create(1.0f); @@ -1488,7 +1488,7 @@ LabelCrashTest::LabelCrashTest() TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,true); auto label1 = Label::createWithTTF(ttfConfig,"Test崩溃123", TextHAlignment::CENTER, size.width); - label1->setPosition( Vector2(size.width/2, size.height/2) ); + label1->setPosition( Vec2(size.width/2, size.height/2) ); addChild(label1); } @@ -1509,16 +1509,16 @@ LabelTTFOldNew::LabelTTFOldNew() auto label1 = Label::createWithSystemFont("Cocos2d-x Label Test", "arial", 24); addChild(label1, 0, kTagBitmapAtlas1); - label1->setPosition(Vector2(s.width/2, delta * 2)); + label1->setPosition(Vec2(s.width/2, delta * 2)); label1->setColor(Color3B::RED); TTFConfig ttfConfig("fonts/arial.ttf", 24); auto label2 = Label::createWithTTF(ttfConfig, "Cocos2d-x Label Test"); addChild(label2, 0, kTagBitmapAtlas2); - label2->setPosition(Vector2(s.width/2, delta * 2)); + label2->setPosition(Vec2(s.width/2, delta * 2)); } -void LabelTTFOldNew::onDraw(const Matrix &transform, bool transformUpdated) +void LabelTTFOldNew::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1532,12 +1532,12 @@ void LabelTTFOldNew::onDraw(const Matrix &transform, bool transformUpdated) origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); - Vector2 vertices[4]= + Vec2 vertices[4]= { - Vector2(origin.width, origin.height), - Vector2(labelSize.width + origin.width, origin.height), - Vector2(labelSize.width + origin.width, labelSize.height + origin.height), - Vector2(origin.width, labelSize.height + origin.height) + Vec2(origin.width, origin.height), + Vec2(labelSize.width + origin.width, origin.height), + Vec2(labelSize.width + origin.width, labelSize.height + origin.height), + Vec2(origin.width, labelSize.height + origin.height) }; DrawPrimitives::setDrawColor4B(Color4B::RED.r,Color4B::RED.g,Color4B::RED.b,Color4B::RED.a); DrawPrimitives::drawPoly(vertices, 4, true); @@ -1549,12 +1549,12 @@ void LabelTTFOldNew::onDraw(const Matrix &transform, bool transformUpdated) origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); - Vector2 vertices2[4]= + Vec2 vertices2[4]= { - Vector2(origin.width, origin.height), - Vector2(labelSize.width + origin.width, origin.height), - Vector2(labelSize.width + origin.width, labelSize.height + origin.height), - Vector2(origin.width, labelSize.height + origin.height) + Vec2(origin.width, origin.height), + Vec2(labelSize.width + origin.width, origin.height), + Vec2(labelSize.width + origin.width, labelSize.height + origin.height), + Vec2(origin.width, labelSize.height + origin.height) }; DrawPrimitives::setDrawColor4B(Color4B::WHITE.r,Color4B::WHITE.g,Color4B::WHITE.b,Color4B::WHITE.a); DrawPrimitives::drawPoly(vertices2, 4, true); @@ -1562,7 +1562,7 @@ void LabelTTFOldNew::onDraw(const Matrix &transform, bool transformUpdated) director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void LabelTTFOldNew::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void LabelTTFOldNew::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this, transform, transformUpdated); @@ -1585,11 +1585,11 @@ LabelFontNameTest::LabelFontNameTest() auto label1 = Label::create(); label1->setString("Default Font"); - label1->setPosition( Vector2(size.width/2, size.height * 0.7) ); + label1->setPosition( Vec2(size.width/2, size.height * 0.7) ); addChild(label1); auto label3 = Label::createWithSystemFont("Marker Felt","Marker Felt",32); - label3->setPosition( Vector2(size.width/2, size.height * 0.5) ); + label3->setPosition( Vec2(size.width/2, size.height * 0.5) ); addChild(label3); } @@ -1608,9 +1608,9 @@ LabelAlignmentTest::LabelAlignmentTest() auto blockSize = Size(200, 160); auto s = Director::getInstance()->getWinSize(); - auto pos = Vector2((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2); + auto pos = Vec2((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2); auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); - colorLayer->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + colorLayer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); colorLayer->setPosition(pos); this->addChild(colorLayer); @@ -1622,7 +1622,7 @@ LabelAlignmentTest::LabelAlignmentTest() MenuItemFont::create("Right", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentRight, this)), NULL); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vector2(50, s.height / 2 - 20)); + menu->setPosition(Vec2(50, s.height / 2 - 20)); this->addChild(menu); menu = Menu::create( @@ -1631,7 +1631,7 @@ LabelAlignmentTest::LabelAlignmentTest() MenuItemFont::create("Bottom", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentBottom, this)), NULL); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vector2(s.width - 50, s.height / 2 - 20)); + menu->setPosition(Vec2(s.width - 50, s.height / 2 - 20)); this->addChild(menu); _horizAlign = TextHAlignment::LEFT; @@ -1643,7 +1643,7 @@ LabelAlignmentTest::LabelAlignmentTest() _label->setAlignment(_horizAlign,_vertAlign); _label->setTTFConfig(ttfConfig); _label->setString(getCurrentAlignment()); - _label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _label->setPosition(pos); addChild(_label); @@ -1741,8 +1741,8 @@ LabelIssue4428Test::LabelIssue4428Test() auto size = Director::getInstance()->getWinSize(); auto label = Label::createWithBMFont( "fonts/bitmapFontTest3.fnt", "123\n456"); - label->setPosition(Vector2(size.width /2.0f, size.height / 2.0f)); - label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + label->setPosition(Vec2(size.width /2.0f, size.height / 2.0f)); + label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); addChild(label); int len = label->getStringLength(); diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index cdd08e520d..834d6fd5ff 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -58,14 +58,14 @@ public: LabelFNTSpriteActions(); virtual void step(float dt); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); }; class LabelFNTPadding : public AtlasDemoNew @@ -224,13 +224,13 @@ public: LabelFNTBounds(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); Label *label1; }; @@ -430,14 +430,14 @@ public: LabelTTFOldNew(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); }; class LabelTTFLargeText : public AtlasDemoNew diff --git a/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp b/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp index f3a6c6df4b..431daeba67 100644 --- a/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp +++ b/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp @@ -141,9 +141,9 @@ void LayerTestCascadingOpacityA::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, s.height/2)); - sister2->setPosition( Vector2( s.width*2/3, s.height/2)); - label->setPosition( Vector2( s.width/2, s.height/2)); + sister1->setPosition( Vec2( s.width*1/3, s.height/2)); + sister2->setPosition( Vec2( s.width*2/3, s.height/2)); + label->setPosition( Vec2( s.width/2, s.height/2)); layer1->runAction( RepeatForever::create( @@ -182,7 +182,7 @@ void LayerTestCascadingOpacityB::onEnter() auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); - layer1->setPosition( Vector2(0, s.height/2)); + layer1->setPosition( Vec2(0, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -193,9 +193,9 @@ void LayerTestCascadingOpacityB::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, 0)); - sister2->setPosition( Vector2( s.width*2/3, 0)); - label->setPosition( Vector2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0)); + sister2->setPosition( Vec2( s.width*2/3, 0)); + label->setPosition( Vec2( s.width/2, 0)); layer1->runAction( RepeatForever::create( @@ -235,7 +235,7 @@ void LayerTestCascadingOpacityC::onEnter() layer1->setCascadeColorEnabled(false); layer1->setCascadeOpacityEnabled(false); - layer1->setPosition( Vector2(0, s.height/2)); + layer1->setPosition( Vec2(0, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -246,9 +246,9 @@ void LayerTestCascadingOpacityC::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, 0)); - sister2->setPosition( Vector2( s.width*2/3, 0)); - label->setPosition( Vector2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0)); + sister2->setPosition( Vec2( s.width*2/3, 0)); + label->setPosition( Vec2( s.width/2, 0)); layer1->runAction( RepeatForever::create( @@ -294,9 +294,9 @@ void LayerTestCascadingColorA::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, s.height/2)); - sister2->setPosition( Vector2( s.width*2/3, s.height/2)); - label->setPosition( Vector2( s.width/2, s.height/2)); + sister1->setPosition( Vec2( s.width*1/3, s.height/2)); + sister2->setPosition( Vec2( s.width*2/3, s.height/2)); + label->setPosition( Vec2( s.width/2, s.height/2)); layer1->runAction( RepeatForever::create( @@ -336,7 +336,7 @@ void LayerTestCascadingColorB::onEnter() auto s = Director::getInstance()->getWinSize(); auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); - layer1->setPosition( Vector2(0, s.height/2)); + layer1->setPosition( Vec2(0, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -347,9 +347,9 @@ void LayerTestCascadingColorB::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, 0)); - sister2->setPosition( Vector2( s.width*2/3, 0)); - label->setPosition( Vector2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0)); + sister2->setPosition( Vec2( s.width*2/3, 0)); + label->setPosition( Vec2( s.width/2, 0)); layer1->runAction( RepeatForever::create( @@ -388,7 +388,7 @@ void LayerTestCascadingColorC::onEnter() auto s = Director::getInstance()->getWinSize(); auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); - layer1->setPosition( Vector2(0, s.height/2)); + layer1->setPosition( Vec2(0, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -399,9 +399,9 @@ void LayerTestCascadingColorC::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, 0)); - sister2->setPosition( Vector2( s.width*2/3, 0)); - label->setPosition( Vector2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0)); + sister2->setPosition( Vec2( s.width*2/3, 0)); + label->setPosition( Vec2( s.width/2, 0)); layer1->runAction( RepeatForever::create( @@ -449,11 +449,11 @@ void LayerTest1::onEnter() auto layer = LayerColor::create( Color4B(0xFF, 0x00, 0x00, 0x80), 200, 200); layer->ignoreAnchorPointForPosition(false); - layer->setPosition( Vector2(s.width/2, s.height/2) ); + layer->setPosition( Vec2(s.width/2, s.height/2) ); addChild(layer, 1, kTagLayer); } -void LayerTest1::updateSize(Vector2 &touchLocation) +void LayerTest1::updateSize(Vec2 &touchLocation) { auto s = Director::getInstance()->getWinSize(); @@ -497,12 +497,12 @@ void LayerTest2::onEnter() auto s = Director::getInstance()->getWinSize(); auto layer1 = LayerColor::create( Color4B(255, 255, 0, 80), 100, 300); - layer1->setPosition(Vector2(s.width/3, s.height/2)); + layer1->setPosition(Vec2(s.width/3, s.height/2)); layer1->ignoreAnchorPointForPosition(false); addChild(layer1, 1); auto layer2 = LayerColor::create( Color4B(0, 0, 255, 255), 100, 300); - layer2->setPosition(Vector2((s.width/3)*2, s.height/2)); + layer2->setPosition(Vec2((s.width/3)*2, s.height/2)); layer2->ignoreAnchorPointForPosition(false); addChild(layer2, 1); @@ -540,8 +540,8 @@ LayerTestBlend::LayerTestBlend() addChild(sister2); addChild(layer1, 100, kTagLayer); - sister1->setPosition( Vector2( s.width*1/3, s.height/2) ); - sister2->setPosition( Vector2( s.width*2/3, s.height/2) ); + sister1->setPosition( Vec2( s.width*1/3, s.height/2) ); + sister2->setPosition( Vec2( s.width*2/3, s.height/2) ); schedule( schedule_selector(LayerTestBlend::newBlend), 1.0f); } @@ -581,7 +581,7 @@ std::string LayerTestBlend::subtitle() const //------------------------------------------------------------------ LayerGradientTest::LayerGradientTest() { - auto layer1 = LayerGradient::create(Color4B(255,0,0,255), Color4B(0,255,0,255), Vector2(0.9f, 0.9f)); + auto layer1 = LayerGradient::create(Color4B(255,0,0,255), Color4B(0,255,0,255), Vec2(0.9f, 0.9f)); addChild(layer1, 0, kTagLayer); auto listener = EventListenerTouchAllAtOnce::create(); @@ -597,7 +597,7 @@ LayerGradientTest::LayerGradientTest() auto menu = Menu::create(item, NULL); addChild(menu); auto s = Director::getInstance()->getWinSize(); - menu->setPosition(Vector2(s.width / 2, 100)); + menu->setPosition(Vec2(s.width / 2, 100)); } void LayerGradientTest::toggleItem(Ref *sender) @@ -613,7 +613,7 @@ void LayerGradientTest::onTouchesMoved(const std::vector& touches, Event auto touch = touches[0]; auto start = touch->getLocation(); - auto diff = Vector2(s.width/2,s.height/2) - start; + auto diff = Vec2(s.width/2,s.height/2) - start; diff = diff.getNormalized(); auto gradient = static_cast( getChildByTag(1) ); @@ -685,10 +685,10 @@ void LayerIgnoreAnchorPointPos::onEnter() auto l = LayerColor::create(Color4B(255, 0, 0, 255), 150, 150); - l->setAnchorPoint(Vector2(0.5f, 0.5f)); - l->setPosition(Vector2( s.width/2, s.height/2)); + l->setAnchorPoint(Vec2(0.5f, 0.5f)); + l->setPosition(Vec2( s.width/2, s.height/2)); - auto move = MoveBy::create(2, Vector2(100,2)); + auto move = MoveBy::create(2, Vec2(100,2)); auto back = (MoveBy *)move->reverse(); auto seq = Sequence::create(move, back, NULL); l->runAction(RepeatForever::create(seq)); @@ -697,14 +697,14 @@ void LayerIgnoreAnchorPointPos::onEnter() auto child = Sprite::create("Images/grossini.png"); l->addChild(child); auto lsize = l->getContentSize(); - child->setPosition(Vector2(lsize.width/2, lsize.height/2)); + child->setPosition(Vec2(lsize.width/2, lsize.height/2)); auto item = MenuItemFont::create("Toggle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointPos::onToggle, this)); auto menu = Menu::create(item, NULL); this->addChild(menu); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); } void LayerIgnoreAnchorPointPos::onToggle(Ref* pObject) @@ -721,7 +721,7 @@ std::string LayerIgnoreAnchorPointPos::title() const std::string LayerIgnoreAnchorPointPos::subtitle() const { - return "Ignoring Anchor Vector2 for position"; + return "Ignoring Anchor Vec2 for position"; } // LayerIgnoreAnchorPointRot @@ -733,8 +733,8 @@ void LayerIgnoreAnchorPointRot::onEnter() auto l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200); - l->setAnchorPoint(Vector2(0.5f, 0.5f)); - l->setPosition(Vector2( s.width/2, s.height/2)); + l->setAnchorPoint(Vec2(0.5f, 0.5f)); + l->setPosition(Vec2( s.width/2, s.height/2)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); @@ -745,14 +745,14 @@ void LayerIgnoreAnchorPointRot::onEnter() auto child = Sprite::create("Images/grossini.png"); l->addChild(child); auto lsize = l->getContentSize(); - child->setPosition(Vector2(lsize.width/2, lsize.height/2)); + child->setPosition(Vec2(lsize.width/2, lsize.height/2)); auto item = MenuItemFont::create("Toogle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointRot::onToggle, this)); auto menu = Menu::create(item, NULL); this->addChild(menu); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); } void LayerIgnoreAnchorPointRot::onToggle(Ref* pObject) @@ -769,7 +769,7 @@ std::string LayerIgnoreAnchorPointRot::title() const std::string LayerIgnoreAnchorPointRot::subtitle() const { - return "Ignoring Anchor Vector2 for rotations"; + return "Ignoring Anchor Vec2 for rotations"; } // LayerIgnoreAnchorPointScale @@ -781,8 +781,8 @@ void LayerIgnoreAnchorPointScale::onEnter() auto l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200); - l->setAnchorPoint(Vector2(0.5f, 1.0f)); - l->setPosition(Vector2( s.width/2, s.height/2)); + l->setAnchorPoint(Vec2(0.5f, 1.0f)); + l->setPosition(Vec2( s.width/2, s.height/2)); auto scale = ScaleBy::create(2, 2); @@ -796,14 +796,14 @@ void LayerIgnoreAnchorPointScale::onEnter() auto child = Sprite::create("Images/grossini.png"); l->addChild(child); auto lsize = l->getContentSize(); - child->setPosition(Vector2(lsize.width/2, lsize.height/2)); + child->setPosition(Vec2(lsize.width/2, lsize.height/2)); auto item = MenuItemFont::create("Toogle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointScale::onToggle, this)); auto menu = Menu::create(item, NULL); this->addChild(menu); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); } void LayerIgnoreAnchorPointScale::onToggle(Ref* pObject) @@ -820,7 +820,7 @@ std::string LayerIgnoreAnchorPointScale::title() const std::string LayerIgnoreAnchorPointScale::subtitle() const { - return "Ignoring Anchor Vector2 for scale"; + return "Ignoring Anchor Vec2 for scale"; } void LayerTestScene::runThisTest() @@ -836,17 +836,17 @@ LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest() { auto layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255)); layer1->setContentSize(Size(80, 80)); - layer1->setPosition(Vector2(50,50)); + layer1->setPosition(Vec2(50,50)); addChild(layer1); auto layer2 = LayerGradient::create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127)); layer2->setContentSize(Size(80, 80)); - layer2->setPosition(Vector2(100,90)); + layer2->setPosition(Vec2(100,90)); addChild(layer2); auto layer3 = LayerGradient::create(); layer3->setContentSize(Size(80, 80)); - layer3->setPosition(Vector2(150,140)); + layer3->setPosition(Vec2(150,140)); layer3->setStartColor(Color3B(255, 0, 0)); layer3->setEndColor(Color3B(255, 0, 255)); layer3->setStartOpacity(255); @@ -879,7 +879,7 @@ void LayerBug3162A::onEnter() { _layer[i] = LayerColor::create(color[i]); _layer[i]->setContentSize(size); - _layer[i]->setPosition(Vector2(size.width/2, size.height/2) - Vector2(20, 20)); + _layer[i]->setPosition(Vec2(size.width/2, size.height/2) - Vec2(20, 20)); _layer[i]->setOpacity(150); _layer[i]->setCascadeOpacityEnabled(true); if (i > 0) @@ -922,7 +922,7 @@ void LayerBug3162B::onEnter() { _layer[i] = LayerColor::create(color[i]); _layer[i]->setContentSize(size); - _layer[i]->setPosition(Vector2(size.width/2, size.height/2) - Vector2(20, 20)); + _layer[i]->setPosition(Vec2(size.width/2, size.height/2) - Vec2(20, 20)); //_layer[i]->setOpacity(150); if (i > 0) { diff --git a/tests/cpp-tests/Classes/LayerTest/LayerTest.h b/tests/cpp-tests/Classes/LayerTest/LayerTest.h index 0bfbf729e1..62cd4cdca7 100644 --- a/tests/cpp-tests/Classes/LayerTest/LayerTest.h +++ b/tests/cpp-tests/Classes/LayerTest/LayerTest.h @@ -80,7 +80,7 @@ public: virtual void onEnter() override; virtual std::string subtitle() const override; - void updateSize(Vector2 &touchLocation); + void updateSize(Vec2 &touchLocation); void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); diff --git a/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp b/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp index c5b75e6366..bb00913264 100644 --- a/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp +++ b/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp @@ -119,9 +119,9 @@ MenuLayerMainMenu::MenuLayerMainMenu() if( i % 2 == 0) offset = -offset; - child->setPosition( Vector2( dstPoint.x + offset, dstPoint.y) ); + child->setPosition( Vec2( dstPoint.x + offset, dstPoint.y) ); child->runAction( - EaseElasticOut::create(MoveBy::create(2, Vector2(dstPoint.x - offset,0)), 0.35f) + EaseElasticOut::create(MoveBy::create(2, Vec2(dstPoint.x - offset,0)), 0.35f) ); i++; } @@ -130,7 +130,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() _disabledItem->setEnabled( false ); addChild(menu); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); menu->setScale(0); menu->runAction(ScaleTo::create(1,1)); } @@ -224,7 +224,7 @@ MenuLayer2::MenuLayer2() auto menu = Menu::create(item1, item2, item3, NULL); auto s = Director::getInstance()->getWinSize(); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); menu->setTag( kTagMenu ); @@ -252,7 +252,7 @@ void MenuLayer2::alignMenusH() // TIP: if no padding, padding = 5 menu->alignItemsHorizontally(); auto p = menu->getPosition(); - menu->setPosition(p + Vector2(0,30)); + menu->setPosition(p + Vec2(0,30)); } else @@ -260,7 +260,7 @@ void MenuLayer2::alignMenusH() // TIP: but padding is configurable menu->alignItemsHorizontallyWithPadding(40); auto p = menu->getPosition(); - menu->setPosition(p - Vector2(0,30)); + menu->setPosition(p - Vec2(0,30)); } } } @@ -276,14 +276,14 @@ void MenuLayer2::alignMenusV() // TIP: if no padding, padding = 5 menu->alignItemsVertically(); auto p = menu->getPosition(); - menu->setPosition(p + Vector2(100,0)); + menu->setPosition(p + Vec2(100,0)); } else { // TIP: but padding is configurable menu->alignItemsVerticallyWithPadding(40); auto p = menu->getPosition(); - menu->setPosition(p - Vector2(100,0)); + menu->setPosition(p - Vec2(100,0)); } } } @@ -345,15 +345,15 @@ MenuLayer3::MenuLayer3() _disabledItem->setEnabled( false ); auto menu = Menu::create( item1, item2, item3, NULL); - menu->setPosition( Vector2(0,0) ); + menu->setPosition( Vec2(0,0) ); auto s = Director::getInstance()->getWinSize(); - item1->setPosition( Vector2(s.width/2 - 150, s.height/2) ); - item2->setPosition( Vector2(s.width/2 - 200, s.height/2) ); - item3->setPosition( Vector2(s.width/2, s.height/2 - 100) ); + item1->setPosition( Vec2(s.width/2 - 150, s.height/2) ); + item2->setPosition( Vec2(s.width/2 - 200, s.height/2) ); + item3->setPosition( Vec2(s.width/2, s.height/2 - 100) ); - auto jump = JumpBy::create(3, Vector2(400,0), 50, 4); + auto jump = JumpBy::create(3, Vec2(400,0), 50, 4); item2->runAction( RepeatForever::create(Sequence::create( jump, jump->reverse(), NULL))); auto spin1 = RotateBy::create(3, 360); @@ -366,7 +366,7 @@ MenuLayer3::MenuLayer3() addChild( menu ); - menu->setPosition(Vector2(0,0)); + menu->setPosition(Vec2(0,0)); } MenuLayer3::~MenuLayer3() @@ -450,7 +450,7 @@ MenuLayer4::MenuLayer4() addChild( menu ); auto s = Director::getInstance()->getWinSize(); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); } MenuLayer4::~MenuLayer4() @@ -479,7 +479,7 @@ BugsTest::BugsTest() menu->alignItemsVertically(); auto s = Director::getInstance()->getWinSize(); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); } void BugsTest::issue1410MenuCallback(Ref *sender) @@ -510,7 +510,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove() auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("click item and move, should not crash", "fonts/arial.ttf", 20); - label->setPosition(Vector2(s.width/2, s.height - 30)); + label->setPosition(Vec2(s.width/2, s.height - 30)); addChild(label); item = MenuItemFont::create("item 1"); @@ -522,7 +522,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove() addChild(menu); menu->alignItemsVertically(); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); // Register Touch Event _touchListener = EventListenerTouchOneByOne::create(); diff --git a/tests/cpp-tests/Classes/MenuTest/MenuTest.h b/tests/cpp-tests/Classes/MenuTest/MenuTest.h index 89820ed3a6..e676b9fe98 100644 --- a/tests/cpp-tests/Classes/MenuTest/MenuTest.h +++ b/tests/cpp-tests/Classes/MenuTest/MenuTest.h @@ -61,7 +61,7 @@ public: class MenuLayer2 : public Layer { protected: - Vector2 _centeredMenu; + Vec2 _centeredMenu; bool _alignedH; void alignMenusH(); diff --git a/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp b/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp index 66db64aea0..233603da5d 100644 --- a/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -62,12 +62,12 @@ void MotionStreakTest1::onEnter() // the root object just rotates around _root = Sprite::create(s_pathR1); addChild(_root, 1); - _root->setPosition(Vector2(s.width/2, s.height/2)); + _root->setPosition(Vec2(s.width/2, s.height/2)); // the target object is offset from root, and the streak is moved to follow it _target = Sprite::create(s_pathR1); _root->addChild(_target); - _target->setPosition(Vector2(s.width/4, 0)); + _target->setPosition(Vec2(s.width/4, 0)); // create the streak object and add it to the scene streak = MotionStreak::create(2, 3, 32, Color3B::GREEN, s_streak); @@ -78,7 +78,7 @@ void MotionStreakTest1::onEnter() auto a1 = RotateBy::create(2, 360); auto action1 = RepeatForever::create(a1); - auto motion = MoveBy::create(2, Vector2(100,0) ); + auto motion = MoveBy::create(2, Vec2(100,0) ); _root->runAction( RepeatForever::create(Sequence::create(motion, motion->reverse(), NULL) ) ); _root->runAction( action1 ); @@ -97,7 +97,7 @@ void MotionStreakTest1::onEnter() void MotionStreakTest1::onUpdate(float delta) { - streak->setPosition( _target->convertToWorldSpace(Vector2::ZERO) ); + streak->setPosition( _target->convertToWorldSpace(Vec2::ZERO) ); } std::string MotionStreakTest1::title() const @@ -125,7 +125,7 @@ void MotionStreakTest2::onEnter() streak = MotionStreak::create(3, 3, 64, Color3B::WHITE, s_streak ); addChild(streak); - streak->setPosition( Vector2(s.width/2, s.height/2) ); + streak->setPosition( Vec2(s.width/2, s.height/2) ); } void MotionStreakTest2::onTouchesMoved(const std::vector& touches, Event* event) @@ -157,7 +157,7 @@ void Issue1358::onEnter() addChild(streak); - _center = Vector2(size.width/2, size.height/2); + _center = Vec2(size.width/2, size.height/2); _radius = size.width/3; _angle = 0.0f; @@ -167,7 +167,7 @@ void Issue1358::onEnter() void Issue1358::update(float dt) { _angle += 1.0f; - streak->setPosition(Vector2(_center.x + cosf(_angle/180 * M_PI)*_radius, + streak->setPosition(Vec2(_center.x + cosf(_angle/180 * M_PI)*_radius, _center.y + sinf(_angle/ 180 * M_PI)*_radius)); } @@ -219,7 +219,7 @@ void MotionStreakTest::onEnter() auto menuMode = Menu::create(itemMode, NULL); addChild(menuMode); - menuMode->setPosition(Vector2(s.width/2, s.height/4)); + menuMode->setPosition(Vec2(s.width/2, s.height/4)); } void MotionStreakTest::modeCallback(Ref *pSender) diff --git a/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.h b/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.h index ee4f9fcc39..cd3864a7db 100644 --- a/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.h +++ b/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.h @@ -61,7 +61,7 @@ public: virtual void onEnter() override; virtual void update(float dt); private: - Vector2 _center; + Vec2 _center; float _radius; float _angle; }; diff --git a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp index 848293b58e..2dd971a644 100644 --- a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -17,18 +17,18 @@ public: setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { DrawPrimitives::setDrawColor4B(_touchColor.r, _touchColor.g, _touchColor.b, 255); glLineWidth(10); - DrawPrimitives::drawLine( Vector2(0, _touchPoint.y), Vector2(getContentSize().width, _touchPoint.y) ); - DrawPrimitives::drawLine( Vector2(_touchPoint.x, 0), Vector2(_touchPoint.x, getContentSize().height) ); + DrawPrimitives::drawLine( Vec2(0, _touchPoint.y), Vec2(getContentSize().width, _touchPoint.y) ); + DrawPrimitives::drawLine( Vec2(_touchPoint.x, 0), Vec2(_touchPoint.x, getContentSize().height) ); glLineWidth(1); DrawPrimitives::setPointSize(30); DrawPrimitives::drawPoint(_touchPoint); } - void setTouchPos(const Vector2& pt) + void setTouchPos(const Vec2& pt) { _touchPoint = pt; } @@ -42,13 +42,13 @@ public: { auto pRet = new TouchPoint(); pRet->setContentSize(pParent->getContentSize()); - pRet->setAnchorPoint(Vector2(0.0f, 0.0f)); + pRet->setAnchorPoint(Vec2(0.0f, 0.0f)); pRet->autorelease(); return pRet; } private: - Vector2 _touchPoint; + Vec2 _touchPoint; Color3B _touchColor; }; @@ -63,7 +63,7 @@ bool MutiTouchTestLayer::init() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto title = Label::createWithSystemFont("Please touch the screen!", "", 24); - title->setPosition(VisibleRect::top()+Vector2(0, -40)); + title->setPosition(VisibleRect::top()+Vec2(0, -40)); addChild(title); return true; diff --git a/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp b/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp index 4b12b7447f..0355b21751 100644 --- a/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp +++ b/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp @@ -127,21 +127,21 @@ void TouchableSpriteTest::onEnter() { EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto containerForSprite1 = Node::create(); auto sprite1 = Sprite::create("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2) + Vector2(-80, 80)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 80)); containerForSprite1->addChild(sprite1); addChild(containerForSprite1, 10); auto sprite2 = Sprite::create("Images/MagentaSquare.png"); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite2, 20); auto sprite3 = Sprite::create("Images/YellowSquare.png"); - sprite3->setPosition(Vector2(0, 0)); + sprite3->setPosition(Vec2(0, 0)); sprite2->addChild(sprite3, 1); // Make sprite1 touchable @@ -151,7 +151,7 @@ void TouchableSpriteTest::onEnter() listener1->onTouchBegan = [](Touch* touch, Event* event){ auto target = static_cast(event->getCurrentTarget()); - Vector2 locationInNode = target->convertToNodeSpace(touch->getLocation()); + Vec2 locationInNode = target->convertToNodeSpace(touch->getLocation()); Size s = target->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); @@ -199,20 +199,20 @@ void TouchableSpriteTest::onEnter() }); nextItem->setFontSizeObj(16); - nextItem->setPosition(VisibleRect::right() + Vector2(-100, -30)); + nextItem->setPosition(VisibleRect::right() + Vec2(-100, -30)); auto menu2 = Menu::create(nextItem, NULL); - menu2->setPosition(Vector2(0, 0)); - menu2->setAnchorPoint(Vector2(0, 0)); + menu2->setPosition(Vec2(0, 0)); + menu2->setAnchorPoint(Vec2(0, 0)); this->addChild(menu2); }); removeAllTouchItem->setFontSizeObj(16); - removeAllTouchItem->setPosition(VisibleRect::right() + Vector2(-100, 0)); + removeAllTouchItem->setPosition(VisibleRect::right() + Vec2(-100, 0)); auto menu = Menu::create(removeAllTouchItem, nullptr); - menu->setPosition(Vector2(0, 0)); - menu->setAnchorPoint(Vector2(0, 0)); + menu->setPosition(Vec2(0, 0)); + menu->setAnchorPoint(Vec2(0, 0)); addChild(menu); } @@ -263,7 +263,7 @@ public: listener->onTouchBegan = [=](Touch* touch, Event* event){ - Vector2 locationInNode = this->convertToNodeSpace(touch->getLocation()); + Vec2 locationInNode = this->convertToNodeSpace(touch->getLocation()); Size s = this->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); @@ -317,22 +317,22 @@ void FixedPriorityTest::onEnter() { EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto sprite1 = TouchableSprite::create(30); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2) + Vector2(-80, 40)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); addChild(sprite1, 10); auto sprite2 = TouchableSprite::create(20); sprite2->setTexture("Images/MagentaSquare.png"); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite2, 20); auto sprite3 = TouchableSprite::create(10); sprite3->setTexture("Images/YellowSquare.png"); - sprite3->setPosition(Vector2(0, 0)); + sprite3->setPosition(Vec2(0, 0)); sprite2->addChild(sprite3, 1); } @@ -352,11 +352,11 @@ void RemoveListenerWhenDispatching::onEnter() { EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto sprite1 = Sprite::create("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite1, 10); // Make sprite1 touchable @@ -367,7 +367,7 @@ void RemoveListenerWhenDispatching::onEnter() std::shared_ptr firstClick(new bool(true)); listener1->onTouchBegan = [=](Touch* touch, Event* event){ - Vector2 locationInNode = sprite1->convertToNodeSpace(touch->getLocation()); + Vec2 locationInNode = sprite1->convertToNodeSpace(touch->getLocation()); Size s = sprite1->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); @@ -386,7 +386,7 @@ void RemoveListenerWhenDispatching::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1, sprite1); auto statusLabel = Label::createWithSystemFont("The sprite could be touched!", "", 20); - statusLabel->setPosition(origin + Vector2(size.width/2, size.height-90)); + statusLabel->setPosition(origin + Vec2(size.width/2, size.height-90)); addChild(statusLabel); std::shared_ptr enable(new bool(true)); // Enable/Disable item @@ -407,10 +407,10 @@ void RemoveListenerWhenDispatching::onEnter() } }, MenuItemFont::create("Enabled"), MenuItemFont::create("Disabled"), NULL); - toggleItem->setPosition(origin + Vector2(size.width/2, 80)); + toggleItem->setPosition(origin + Vec2(size.width/2, 80)); auto menu = Menu::create(toggleItem, nullptr); - menu->setPosition(Vector2(0, 0)); - menu->setAnchorPoint(Vector2(0, 0)); + menu->setPosition(Vec2(0, 0)); + menu->setAnchorPoint(Vec2(0, 0)); addChild(menu, -1); } @@ -429,13 +429,13 @@ void CustomEventTest::onEnter() { EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); MenuItemFont::setFontSize(20); auto statusLabel = Label::createWithSystemFont("No custom event 1 received!", "", 20); - statusLabel->setPosition(origin + Vector2(size.width/2, size.height-90)); + statusLabel->setPosition(origin + Vec2(size.width/2, size.height-90)); addChild(statusLabel); _listener = EventListenerCustom::create("game_custom_event1", [=](EventCustom* event){ @@ -458,10 +458,10 @@ void CustomEventTest::onEnter() _eventDispatcher->dispatchEvent(&event); CC_SAFE_DELETE_ARRAY(buf); }); - sendItem->setPosition(origin + Vector2(size.width/2, size.height/2)); + sendItem->setPosition(origin + Vec2(size.width/2, size.height/2)); auto statusLabel2 = Label::createWithSystemFont("No custom event 2 received!", "", 20); - statusLabel2->setPosition(origin + Vector2(size.width/2, size.height-120)); + statusLabel2->setPosition(origin + Vec2(size.width/2, size.height-120)); addChild(statusLabel2); _listener2 = EventListenerCustom::create("game_custom_event2", [=](EventCustom* event){ @@ -484,11 +484,11 @@ void CustomEventTest::onEnter() _eventDispatcher->dispatchEvent(&event); CC_SAFE_DELETE_ARRAY(buf); }); - sendItem2->setPosition(origin + Vector2(size.width/2, size.height/2 - 40)); + sendItem2->setPosition(origin + Vec2(size.width/2, size.height/2 - 40)); auto menu = Menu::create(sendItem, sendItem2, nullptr); - menu->setPosition(Vector2(0, 0)); - menu->setAnchorPoint(Vector2(0, 0)); + menu->setPosition(Vec2(0, 0)); + menu->setAnchorPoint(Vec2(0, 0)); addChild(menu, -1); } @@ -514,11 +514,11 @@ void LabelKeyboardEventTest::onEnter() { EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto statusLabel = Label::createWithSystemFont("No keyboard event received!", "", 20); - statusLabel->setPosition(origin + Vector2(size.width/2, size.height/2)); + statusLabel->setPosition(origin + Vec2(size.width/2, size.height/2)); addChild(statusLabel); auto listener = EventListenerKeyboard::create(); @@ -560,13 +560,13 @@ _pos = _max; \ EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); Device::setAccelerometerEnabled(true); auto sprite = Sprite::create(s_Ball); - sprite->setPosition(origin + Vector2(size.width/2, size.height/2)); + sprite->setPosition(origin + Vec2(size.width/2, size.height/2)); addChild(sprite); auto listener = EventListenerAcceleration::create([=](Acceleration* acc, Event* event){ @@ -610,11 +610,11 @@ void RemoveAndRetainNodeTest::onEnter() EventDispatcherTestDemo::onEnter(); - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); _sprite = Sprite::create("Images/CyanSquare.png"); - _sprite->setPosition(origin+Vector2(size.width/2, size.height/2)); + _sprite->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(_sprite, 10); // Make sprite1 touchable @@ -624,7 +624,7 @@ void RemoveAndRetainNodeTest::onEnter() listener1->onTouchBegan = [](Touch* touch, Event* event){ auto target = static_cast(event->getCurrentTarget()); - Vector2 locationInNode = target->convertToNodeSpace(touch->getLocation()); + Vec2 locationInNode = target->convertToNodeSpace(touch->getLocation()); Size s = target->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); @@ -701,17 +701,17 @@ void RemoveListenerAfterAddingTest::onEnter() _eventDispatcher->removeEventListener(listener); }); - item1->setPosition(VisibleRect::center() + Vector2(0, 80)); + item1->setPosition(VisibleRect::center() + Vec2(0, 80)); auto addNextButton = [this](){ auto next = MenuItemFont::create("Please Click Me To Reset!", [this](Ref* sender){ this->restartCallback(nullptr); }); - next->setPosition(VisibleRect::center() + Vector2(0, -40)); + next->setPosition(VisibleRect::center() + Vec2(0, -40)); auto menu = Menu::create(next, nullptr); menu->setPosition(VisibleRect::leftBottom()); - menu->setAnchorPoint(Vector2::ZERO); + menu->setAnchorPoint(Vec2::ZERO); this->addChild(menu); }; @@ -728,7 +728,7 @@ void RemoveListenerAfterAddingTest::onEnter() addNextButton(); }); - item2->setPosition(VisibleRect::center() + Vector2(0, 40)); + item2->setPosition(VisibleRect::center() + Vec2(0, 40)); auto item3 = MenuItemFont::create("Click Me 3", [=](Ref* sender){ auto listener = EventListenerTouchOneByOne::create(); @@ -747,7 +747,7 @@ void RemoveListenerAfterAddingTest::onEnter() auto menu = Menu::create(item1, item2, item3, nullptr); menu->setPosition(VisibleRect::leftBottom()); - menu->setAnchorPoint(Vector2::ZERO); + menu->setAnchorPoint(Vec2::ZERO); addChild(menu); } @@ -789,23 +789,23 @@ void DirectorEventTest::onEnter() TTFConfig ttfConfig("fonts/arial.ttf", 20); _label1 = Label::createWithTTF(ttfConfig, "Update: 0"); - _label1->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _label1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _label1->setPosition(30,s.height/2 + 60); this->addChild(_label1); _label2 = Label::createWithTTF(ttfConfig, "Visit: 0"); - _label2->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _label2->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _label2->setPosition(30,s.height/2 + 20); this->addChild(_label2); _label3 = Label::createWithTTF(ttfConfig, "Draw: 0"); - _label3->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _label3->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _label3->setPosition(30,30); _label3->setPosition(30,s.height/2 - 20); this->addChild(_label3); _label4 = Label::createWithTTF(ttfConfig, "Projection: 0"); - _label4->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + _label4->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _label4->setPosition(30,30); _label4->setPosition(30,s.height/2 - 60); this->addChild(_label4); @@ -899,7 +899,7 @@ GlobalZTouchTest::GlobalZTouchTest() listener->onTouchBegan = [](Touch* touch, Event* event){ auto target = static_cast(event->getCurrentTarget()); - Vector2 locationInNode = target->convertToNodeSpace(touch->getLocation()); + Vec2 locationInNode = target->convertToNodeSpace(touch->getLocation()); Size s = target->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); @@ -1082,9 +1082,9 @@ StopPropagationTest::StopPropagationTest() } } -bool StopPropagationTest::isPointInNode(Vector2 pt, Node* node) +bool StopPropagationTest::isPointInNode(Vec2 pt, Node* node) { - Vector2 locationInNode = node->convertToNodeSpace(pt); + Vec2 locationInNode = node->convertToNodeSpace(pt); Size s = node->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); @@ -1095,7 +1095,7 @@ bool StopPropagationTest::isPointInNode(Vector2 pt, Node* node) return false; } -bool StopPropagationTest::isPointInTopHalfAreaOfScreen(Vector2 pt) +bool StopPropagationTest::isPointInTopHalfAreaOfScreen(Vec2 pt) { Size winSize = Director::getInstance()->getWinSize(); @@ -1119,22 +1119,22 @@ std::string StopPropagationTest::subtitle() const // PauseResumeTargetTest PauseResumeTargetTest::PauseResumeTargetTest() { - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto sprite1 = TouchableSprite::create(); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2) + Vector2(-80, 40)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); addChild(sprite1, -10); auto sprite2 = TouchableSprite::create(); sprite2->setTexture("Images/MagentaSquare.png"); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite2, -20); auto sprite3 = TouchableSprite::create(100); // Sprite3 uses fixed priority listener sprite3->setTexture("Images/YellowSquare.png"); - sprite3->setPosition(Vector2(0, 0)); + sprite3->setPosition(Vec2(0, 0)); sprite2->addChild(sprite3, -1); auto popup = MenuItemFont::create("Popup", [=](Ref* sender){ @@ -1154,18 +1154,18 @@ PauseResumeTargetTest::PauseResumeTargetTest() closeItem->setPosition(VisibleRect::center()); auto closeMenu = Menu::create(closeItem, NULL); - closeMenu->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - closeMenu->setPosition(Vector2::ZERO); + closeMenu->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + closeMenu->setPosition(Vec2::ZERO); colorLayer->addChild(closeMenu); }); - popup->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); + popup->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); popup->setPosition(VisibleRect::right()); auto menu = Menu::create(popup, nullptr); - menu->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - menu->setPosition(Vector2::ZERO); + menu->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + menu->setPosition(Vec2::ZERO); addChild(menu); } @@ -1191,8 +1191,8 @@ Issue4129::Issue4129() _customlistener = _eventDispatcher->addCustomEventListener(EVENT_COME_TO_BACKGROUND, [this](EventCustom* event){ auto label = Label::createWithSystemFont("Yeah, this issue was fixed.", "", 20); - label->setAnchorPoint(Vector2(0, 0.5f)); - label->setPosition(Vector2(VisibleRect::left())); + label->setAnchorPoint(Vec2(0, 0.5f)); + label->setPosition(Vec2(VisibleRect::left())); this->addChild(label); // After test, remove it. @@ -1214,11 +1214,11 @@ Issue4129::Issue4129() }); nextItem->setFontSizeObj(16); - nextItem->setPosition(VisibleRect::right() + Vector2(-100, -30)); + nextItem->setPosition(VisibleRect::right() + Vec2(-100, -30)); auto menu2 = Menu::create(nextItem, NULL); - menu2->setPosition(Vector2(0, 0)); - menu2->setAnchorPoint(Vector2(0, 0)); + menu2->setPosition(Vec2(0, 0)); + menu2->setAnchorPoint(Vec2(0, 0)); this->addChild(menu2); // Simulate to dispatch 'come to background' event @@ -1226,11 +1226,11 @@ Issue4129::Issue4129() }); removeAllTouchItem->setFontSizeObj(16); - removeAllTouchItem->setPosition(VisibleRect::right() + Vector2(-100, 0)); + removeAllTouchItem->setPosition(VisibleRect::right() + Vec2(-100, 0)); auto menu = Menu::create(removeAllTouchItem, nullptr); - menu->setPosition(Vector2(0, 0)); - menu->setAnchorPoint(Vector2(0, 0)); + menu->setPosition(Vec2(0, 0)); + menu->setAnchorPoint(Vec2(0, 0)); addChild(menu); } @@ -1255,23 +1255,23 @@ std::string Issue4129::subtitle() const // Issue4160 Issue4160::Issue4160() { - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto sprite1 = TouchableSprite::create(-30); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2) + Vector2(-80, 40)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); addChild(sprite1, -10); auto sprite2 = TouchableSprite::create(-20); sprite2->setTexture("Images/MagentaSquare.png"); sprite2->removeListenerOnTouchEnded(true); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite2, -20); auto sprite3 = TouchableSprite::create(-10); sprite3->setTexture("Images/YellowSquare.png"); - sprite3->setPosition(Vector2(0, 0)); + sprite3->setPosition(Vec2(0, 0)); sprite2->addChild(sprite3, -1); } @@ -1361,7 +1361,7 @@ DanglingNodePointersTest::DanglingNodePointersTest() { #if CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS == 1 && COCOS2D_DEBUG > 0 - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto callback2 = [](DanglingNodePointersTestSprite * sprite2) @@ -1380,18 +1380,18 @@ DanglingNodePointersTest::DanglingNodePointersTest() // Recreate sprite 1 again sprite2 = DanglingNodePointersTestSprite::create(callback2); sprite2->setTexture("Images/MagentaSquare.png"); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); sprite1->addChild(sprite2, -20); }; auto sprite1 = DanglingNodePointersTestSprite::create(callback1); // Sprite 1 will receive touch before sprite 2 sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite1, -10); auto sprite2 = DanglingNodePointersTestSprite::create(callback2); // Sprite 2 will be removed when sprite 1 is touched, should never receive an event. sprite2->setTexture("Images/MagentaSquare.png"); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); sprite1->addChild(sprite2, -20); #endif @@ -1420,7 +1420,7 @@ std::string DanglingNodePointersTest::subtitle() const RegisterAndUnregisterWhileEventHanldingTest::RegisterAndUnregisterWhileEventHanldingTest() { - Vector2 origin = Director::getInstance()->getVisibleOrigin(); + Vec2 origin = Director::getInstance()->getVisibleOrigin(); Size size = Director::getInstance()->getVisibleSize(); auto callback1 = [=](DanglingNodePointersTestSprite * sprite) @@ -1435,7 +1435,7 @@ RegisterAndUnregisterWhileEventHanldingTest::RegisterAndUnregisterWhileEventHanl auto sprite2 = DanglingNodePointersTestSprite::create(callback2); sprite2->setTexture("Images/CyanSquare.png"); - sprite2->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite2->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite2, 0); removeChild(sprite2); @@ -1444,7 +1444,7 @@ RegisterAndUnregisterWhileEventHanldingTest::RegisterAndUnregisterWhileEventHanl auto sprite1 = DanglingNodePointersTestSprite::create(callback1); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vector2(size.width/2, size.height/2)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2)); addChild(sprite1, -10); } diff --git a/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h b/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h index 58a78898ab..8118f2619e 100644 --- a/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h +++ b/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h @@ -161,8 +161,8 @@ public: virtual std::string subtitle() const override; protected: - bool isPointInNode(Vector2 pt, Node* node); - bool isPointInTopHalfAreaOfScreen(Vector2 pt); + bool isPointInNode(Vec2 pt, Node* node); + bool isPointInTopHalfAreaOfScreen(Vec2 pt); }; class PauseResumeTargetTest : public EventDispatcherTestDemo diff --git a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp index 6149b386f6..eda32322af 100644 --- a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp +++ b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp @@ -230,7 +230,7 @@ protected: public: static SpriteInGroupCommand* create(const std::string& filename); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; }; SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename) @@ -241,7 +241,7 @@ SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename) return sprite; } -void SpriteInGroupCommand::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void SpriteInGroupCommand::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { CCASSERT(renderer, "Render is null"); _spriteWrapperCommand.init(_globalZOrder); @@ -309,7 +309,7 @@ void NewSpriteBatchTest::onTouchesEnded(const std::vector &touches, Eve } } -void NewSpriteBatchTest::addNewSpriteWithCoords(Vector2 p) +void NewSpriteBatchTest::addNewSpriteWithCoords(Vec2 p) { auto BatchNode = static_cast( getChildByTag(kTagSpriteBatchNode) ); @@ -321,7 +321,7 @@ void NewSpriteBatchTest::addNewSpriteWithCoords(Vector2 p) auto sprite = Sprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121)); BatchNode->addChild(sprite); - sprite->setPosition( Vector2( p.x, p.y) ); + sprite->setPosition( Vec2( p.x, p.y) ); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -350,19 +350,19 @@ NewClippingNodeTest::NewClippingNodeTest() auto clipper = ClippingNode::create(); clipper->setTag( kTagClipperNode ); clipper->setContentSize( Size(200, 200) ); - clipper->setAnchorPoint( Vector2(0.5, 0.5) ); - clipper->setPosition( Vector2(s.width / 2, s.height / 2) ); + clipper->setAnchorPoint( Vec2(0.5, 0.5) ); + clipper->setPosition( Vec2(s.width / 2, s.height / 2) ); clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); this->addChild(clipper); //TODO Fix draw node as clip node // auto stencil = NewDrawNode::create(); -// Vector2 rectangle[4]; -// rectangle[0] = Vector2(0, 0); -// rectangle[1] = Vector2(clipper->getContentSize().width, 0); -// rectangle[2] = Vector2(clipper->getContentSize().width, clipper->getContentSize().height); -// rectangle[3] = Vector2(0, clipper->getContentSize().height); +// Vec2 rectangle[4]; +// rectangle[0] = Vec2(0, 0); +// rectangle[1] = Vec2(clipper->getContentSize().width, 0); +// rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height); +// rectangle[3] = Vec2(0, clipper->getContentSize().height); // // Color4F white(1, 1, 1, 1); // stencil->drawPolygon(rectangle, 4, white, 1, white); @@ -376,8 +376,8 @@ NewClippingNodeTest::NewClippingNodeTest() auto content = Sprite::create("Images/background2.png"); content->setTag( kTagContentNode ); - content->setAnchorPoint( Vector2(0.5, 0.5) ); - content->setPosition( Vector2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); + content->setAnchorPoint( Vec2(0.5, 0.5) ); + content->setPosition( Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); clipper->addChild(content); _scrolling = false; @@ -408,7 +408,7 @@ void NewClippingNodeTest::onTouchesBegan(const std::vector &touches, Ev { Touch *touch = touches[0]; auto clipper = this->getChildByTag(kTagClipperNode); - Vector2 point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); + Vec2 point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); auto rect = Rect(0, 0, clipper->getContentSize().width, clipper->getContentSize().height); _scrolling = rect.containsPoint(point); _lastPoint = point; @@ -420,7 +420,7 @@ void NewClippingNodeTest::onTouchesMoved(const std::vector &touches, Ev Touch *touch = touches[0]; auto clipper = this->getChildByTag(kTagClipperNode); auto point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); - Vector2 diff = point - _lastPoint; + Vec2 diff = point - _lastPoint; auto content = clipper->getChildByTag(kTagContentNode); content->setPosition(content->getPosition() + diff); _lastPoint = point; @@ -444,11 +444,11 @@ NewDrawNodeTest::NewDrawNodeTest() addChild(parent); auto rectNode = DrawNode::create(); - Vector2 rectangle[4]; - rectangle[0] = Vector2(-50, -50); - rectangle[1] = Vector2(50, -50); - rectangle[2] = Vector2(50, 50); - rectangle[3] = Vector2(-50, 50); + Vec2 rectangle[4]; + rectangle[0] = Vec2(-50, -50); + rectangle[1] = Vec2(50, -50); + rectangle[2] = Vec2(50, 50); + rectangle[3] = Vec2(-50, 50); Color4F white(1, 1, 1, 1); rectNode->drawPolygon(rectangle, 4, white, 1, white); @@ -475,13 +475,13 @@ NewCullingTest::NewCullingTest() Size size = Director::getInstance()->getWinSize(); auto sprite = Sprite::create("Images/btn-about-normal-vertical.png"); sprite->setRotation(5); - sprite->setPosition(Vector2(size.width/2,size.height/3)); + sprite->setPosition(Vec2(size.width/2,size.height/3)); sprite->setScale(2); addChild(sprite); auto sprite2 = Sprite::create("Images/btn-about-normal-vertical.png"); sprite2->setRotation(-85); - sprite2->setPosition(Vector2(size.width/2,size.height * 2/3)); + sprite2->setPosition(Vec2(size.width/2,size.height * 2/3)); sprite2->setScale(2); addChild(sprite2); @@ -540,7 +540,7 @@ VBOFullTest::VBOFullTest() for (int i=0; isetPosition(Vector2(0,0)); + sprite->setPosition(Vec2(0,0)); parent->addChild(sprite); } } diff --git a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.h b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.h index 5d657b4a70..428440feaf 100644 --- a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.h +++ b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.h @@ -78,7 +78,7 @@ public: virtual std::string subtitle() const override; void onTouchesEnded(const std::vector& touches, Event* event); - void addNewSpriteWithCoords(Vector2 p); + void addNewSpriteWithCoords(Vec2 p); protected: NewSpriteBatchTest(); @@ -102,7 +102,7 @@ protected: virtual ~NewClippingNodeTest(); bool _scrolling; - Vector2 _lastPoint; + Vec2 _lastPoint; }; class NewDrawNodeTest : public MultiSceneTest @@ -131,7 +131,7 @@ protected: virtual ~NewCullingTest(); bool onTouchBegan(Touch* touch, Event *event); void onTouchMoved(Touch* touch, Event *event); - Vector2 _lastPos; + Vec2 _lastPos; }; class VBOFullTest : public MultiSceneTest diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 0f082167c7..868f9a6c57 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -165,8 +165,8 @@ void Test2::onEnter() auto sp3 = Sprite::create(s_pathSister1); auto sp4 = Sprite::create(s_pathSister2); - sp1->setPosition(Vector2(100, s.height /2 )); - sp2->setPosition(Vector2(380, s.height /2 )); + sp1->setPosition(Vec2(100, s.height /2 )); + sp2->setPosition(Vec2(380, s.height /2 )); addChild(sp1); addChild(sp2); @@ -187,7 +187,7 @@ void Test2::onEnter() NULL) ); - sp2->setAnchorPoint(Vector2(0,0)); + sp2->setAnchorPoint(Vec2(0,0)); sp1->runAction(action1); sp2->runAction(action2); @@ -212,8 +212,8 @@ Test4::Test4() auto sp1 = Sprite::create(s_pathSister1); auto sp2 = Sprite::create(s_pathSister2); - sp1->setPosition( Vector2(100,160) ); - sp2->setPosition( Vector2(380,160) ); + sp1->setPosition( Vec2(100,160) ); + sp2->setPosition( Vec2(380,160) ); addChild(sp1, 0, 2); addChild(sp2, 0, 3); @@ -251,8 +251,8 @@ Test5::Test5() auto sp1 = Sprite::create(s_pathSister1); auto sp2 = Sprite::create(s_pathSister2); - sp1->setPosition(Vector2(100,160)); - sp2->setPosition(Vector2(380,160)); + sp1->setPosition(Vec2(100,160)); + sp2->setPosition(Vec2(380,160)); auto rot = RotateBy::create(2, 360); auto rot_back = rot->reverse(); @@ -306,8 +306,8 @@ Test6::Test6() auto sp2 = Sprite::create(s_pathSister2); auto sp21 = Sprite::create(s_pathSister2); - sp1->setPosition(Vector2(100,160)); - sp2->setPosition(Vector2(380,160)); + sp1->setPosition(Vec2(100,160)); + sp2->setPosition(Vec2(380,160)); auto rot = RotateBy::create(2, 360); auto rot_back = rot->reverse(); @@ -367,7 +367,7 @@ StressTest1::StressTest1() auto sp1 = Sprite::create(s_pathSister1); addChild(sp1, 0, kTagSprite1); - sp1->setPosition( Vector2(s.width/2, s.height/2) ); + sp1->setPosition( Vec2(s.width/2, s.height/2) ); schedule( schedule_selector(StressTest1::shouldNotCrash), 1.0f); } @@ -385,7 +385,7 @@ void StressTest1::shouldNotCrash(float dt) // if it doesn't, it works Ok. // auto explosion = [Sprite create:@"grossinis_sister2.png"); - explosion->setPosition( Vector2(s.width/2, s.height/2) ); + explosion->setPosition( Vec2(s.width/2, s.height/2) ); runAction( Sequence::create( RotateBy::create(2, 360), @@ -420,9 +420,9 @@ StressTest2::StressTest2() auto sublayer = Layer::create(); auto sp1 = Sprite::create(s_pathSister1); - sp1->setPosition( Vector2(80, s.height/2) ); + sp1->setPosition( Vec2(80, s.height/2) ); - auto move = MoveBy::create(3, Vector2(350,0)); + auto move = MoveBy::create(3, Vec2(350,0)); auto move_ease_inout3 = EaseInOut::create(move->clone(), 2.0f); auto move_ease_inout_back3 = move_ease_inout3->reverse(); auto seq3 = Sequence::create( move_ease_inout3, move_ease_inout_back3, NULL); @@ -431,7 +431,7 @@ StressTest2::StressTest2() auto fire = ParticleFire::create(); fire->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); - fire->setPosition( Vector2(80, s.height/2-50) ); + fire->setPosition( Vec2(80, s.height/2-50) ); auto copy_seq3 = seq3->clone(); @@ -500,20 +500,20 @@ NodeToWorld::NodeToWorld() auto back = Sprite::create(s_back3); addChild( back, -10); - back->setAnchorPoint( Vector2(0,0) ); + back->setAnchorPoint( Vec2(0,0) ); auto backSize = back->getContentSize(); auto item = MenuItemImage::create(s_PlayNormal, s_PlaySelect); auto menu = Menu::create(item, NULL); menu->alignItemsVertically(); - menu->setPosition( Vector2(backSize.width/2, backSize.height/2)); + menu->setPosition( Vec2(backSize.width/2, backSize.height/2)); back->addChild(menu); auto rot = RotateBy::create(5, 360); auto fe = RepeatForever::create( rot); item->runAction( fe ); - auto move = MoveBy::create(3, Vector2(200,0)); + auto move = MoveBy::create(3, Vec2(200,0)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); auto fe2 = RepeatForever::create(seq); @@ -540,26 +540,26 @@ NodeToWorld3D::NodeToWorld3D() Size s = Director::getInstance()->getWinSize(); auto parent = Node::create(); parent->setContentSize(s); - parent->setAnchorPoint(Vector2(0.5, 0.5)); + parent->setAnchorPoint(Vec2(0.5, 0.5)); parent->setPosition(s.width/2, s.height/2); this->addChild(parent); auto back = Sprite::create(s_back3); parent->addChild( back, -10); - back->setAnchorPoint( Vector2(0,0) ); + back->setAnchorPoint( Vec2(0,0) ); auto backSize = back->getContentSize(); auto item = MenuItemImage::create(s_PlayNormal, s_PlaySelect); auto menu = Menu::create(item, NULL); menu->alignItemsVertically(); - menu->setPosition( Vector2(backSize.width/2, backSize.height/2)); + menu->setPosition( Vec2(backSize.width/2, backSize.height/2)); back->addChild(menu); auto rot = RotateBy::create(5, 360); auto fe = RepeatForever::create( rot); item->runAction( fe ); - auto move = MoveBy::create(3, Vector2(200,0)); + auto move = MoveBy::create(3, Vec2(200,0)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); auto fe2 = RepeatForever::create(seq); @@ -601,7 +601,7 @@ CameraOrbitTest::CameraOrbitTest() auto p = Sprite::create(s_back3); addChild( p, 0); - p->setPosition( Vector2(s.width/2, s.height/2) ); + p->setPosition( Vec2(s.width/2, s.height/2) ); p->setOpacity( 128 ); Sprite* sprite; @@ -613,7 +613,7 @@ CameraOrbitTest::CameraOrbitTest() sprite = Sprite::create(s_pathGrossini); sprite->setScale(0.5f); p->addChild(sprite, 0); - sprite->setPosition( Vector2(s.width/4*1, s.height/2) ); + sprite->setPosition( Vec2(s.width/4*1, s.height/2) ); orbit = OrbitCamera::create(2, 1, 0, 0, 360, 0, 0); sprite->runAction( RepeatForever::create( orbit ) ); @@ -621,7 +621,7 @@ CameraOrbitTest::CameraOrbitTest() sprite = Sprite::create(s_pathGrossini); sprite->setScale( 1.0f ); p->addChild(sprite, 0); - sprite->setPosition( Vector2(s.width/4*2, s.height/2) ); + sprite->setPosition( Vec2(s.width/4*2, s.height/2) ); orbit = OrbitCamera::create(2, 1, 0, 0, 360, 45, 0); sprite->runAction( RepeatForever::create( orbit ) ); @@ -630,7 +630,7 @@ CameraOrbitTest::CameraOrbitTest() sprite = Sprite::create(s_pathGrossini); sprite->setScale( 2.0f ); p->addChild(sprite, 0); - sprite->setPosition( Vector2(s.width/4*3, s.height/2) ); + sprite->setPosition( Vec2(s.width/4*3, s.height/2) ); ss = sprite->getContentSize(); orbit = OrbitCamera::create(2, 1, 0, 0, 360, 90, -45), sprite->runAction( RepeatForever::create(orbit) ); @@ -677,7 +677,7 @@ CameraZoomTest::CameraZoomTest() // LEFT sprite = Sprite::create(s_pathGrossini); addChild( sprite, 0); - sprite->setPosition( Vector2(s.width/4*1, s.height/2) ); + sprite->setPosition( Vec2(s.width/4*1, s.height/2) ); // cam = sprite->getCamera(); // cam->setEye(0, 0, 415/2); // cam->setCenter(0, 0, 0); @@ -685,12 +685,12 @@ CameraZoomTest::CameraZoomTest() // CENTER sprite = Sprite::create(s_pathGrossini); addChild( sprite, 0, 40); - sprite->setPosition(Vector2(s.width/4*2, s.height/2)); + sprite->setPosition(Vec2(s.width/4*2, s.height/2)); // RIGHT sprite = Sprite::create(s_pathGrossini); addChild( sprite, 0, 20); - sprite->setPosition(Vector2(s.width/4*3, s.height/2)); + sprite->setPosition(Vec2(s.width/4*3, s.height/2)); _z = 0; scheduleUpdate(); @@ -745,19 +745,19 @@ CameraCenterTest::CameraCenterTest() // LEFT-TOP sprite = Sprite::create("Images/white-512x512.png"); addChild( sprite, 0); - sprite->setPosition(Vector2(s.width/5*1, s.height/5*1)); + sprite->setPosition(Vec2(s.width/5*1, s.height/5*1)); sprite->setColor(Color3B::RED); sprite->setTextureRect(Rect(0, 0, 120, 50)); orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); sprite->runAction(RepeatForever::create( orbit )); -// [sprite setAnchorPoint: Vector2(0,1)); +// [sprite setAnchorPoint: Vec2(0,1)); // LEFT-BOTTOM sprite = Sprite::create("Images/white-512x512.png"); addChild( sprite, 0, 40); - sprite->setPosition(Vector2(s.width/5*1, s.height/5*4)); + sprite->setPosition(Vec2(s.width/5*1, s.height/5*4)); sprite->setColor(Color3B::BLUE); sprite->setTextureRect(Rect(0, 0, 120, 50)); orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); @@ -767,7 +767,7 @@ CameraCenterTest::CameraCenterTest() // RIGHT-TOP sprite = Sprite::create("Images/white-512x512.png"); addChild( sprite, 0); - sprite->setPosition(Vector2(s.width/5*4, s.height/5*1)); + sprite->setPosition(Vec2(s.width/5*4, s.height/5*1)); sprite->setColor(Color3B::YELLOW); sprite->setTextureRect(Rect(0, 0, 120, 50)); orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); @@ -777,7 +777,7 @@ CameraCenterTest::CameraCenterTest() // RIGHT-BOTTOM sprite = Sprite::create("Images/white-512x512.png"); addChild( sprite, 0, 40); - sprite->setPosition(Vector2(s.width/5*4, s.height/5*4)); + sprite->setPosition(Vec2(s.width/5*4, s.height/5*4)); sprite->setColor(Color3B::GREEN); sprite->setTextureRect(Rect(0, 0, 120, 50)); orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); @@ -786,7 +786,7 @@ CameraCenterTest::CameraCenterTest() // CENTER sprite = Sprite::create("Images/white-512x512.png"); addChild( sprite, 0, 40); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); sprite->setColor(Color3B::WHITE); sprite->setTextureRect(Rect(0, 0, 120, 50)); orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); @@ -821,7 +821,7 @@ ConvertToNode::ConvertToNode() for(int i = 0; i < 3; i++) { auto sprite = Sprite::create("Images/grossini.png"); - sprite->setPosition(Vector2( s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2( s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -831,13 +831,13 @@ ConvertToNode::ConvertToNode() switch(i) { case 0: - sprite->setAnchorPoint(Vector2::ZERO); + sprite->setAnchorPoint(Vec2::ZERO); break; case 1: - sprite->setAnchorPoint(Vector2(0.5f, 0.5f)); + sprite->setAnchorPoint(Vec2(0.5f, 0.5f)); break; case 2: - sprite->setAnchorPoint(Vector2(1,1)); + sprite->setAnchorPoint(Vec2(1,1)); break; } @@ -857,7 +857,7 @@ void ConvertToNode::onTouchesEnded(const std::vector& touches, Event *ev for( int i = 0; i < 3; i++) { auto node = getChildByTag(100+i); - Vector2 p1, p2; + Vec2 p1, p2; p1 = node->convertToNodeSpaceAR(location); p2 = node->convertToNodeSpace(location); @@ -887,7 +887,7 @@ NodeOpaqueTest::NodeOpaqueTest() { background = Sprite::create("Images/background1.png"); background->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); - background->setAnchorPoint(Vector2::ZERO); + background->setAnchorPoint(Vec2::ZERO); addChild(background); } } @@ -912,7 +912,7 @@ NodeNonOpaqueTest::NodeNonOpaqueTest() { background = Sprite::create("Images/background1.jpg"); background->setBlendFunc(BlendFunc::DISABLE); - background->setAnchorPoint(Vector2::ZERO); + background->setAnchorPoint(Vec2::ZERO); addChild(background); } } @@ -993,22 +993,22 @@ public: sprite->setGLProgramState(shaderState); return sprite; } - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; - void onDraw(const Matrix &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + void onDraw(const Mat4 &transform, bool transformUpdated); protected: CustomCommand _customCommand; }; -void MySprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void MySprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void MySprite::onDraw(const Matrix &transform, bool transformUpdated) +void MySprite::onDraw(const Mat4 &transform, bool transformUpdated) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -1065,12 +1065,12 @@ CameraTest1::CameraTest1() _sprite1 = MySprite::create(s_back3); addChild( _sprite1 ); - _sprite1->setPosition( Vector2(1*s.width/4, s.height/2) ); + _sprite1->setPosition( Vec2(1*s.width/4, s.height/2) ); _sprite1->setScale(0.5); _sprite2 = Sprite::create(s_back3); addChild( _sprite2 ); - _sprite2->setPosition( Vector2(3*s.width/4, s.height/2) ); + _sprite2->setPosition( Vec2(3*s.width/4, s.height/2) ); _sprite2->setScale(0.5); auto camera = OrbitCamera::create(10, 0, 1, 0, 360, 0, 0); @@ -1113,20 +1113,20 @@ CameraTest2::CameraTest2() _sprite1 = MySprite::create(s_back3); addChild( _sprite1 ); - _sprite1->setPosition( Vector2(1*s.width/4, s.height/2) ); + _sprite1->setPosition( Vec2(1*s.width/4, s.height/2) ); _sprite1->setScale(0.5); _sprite2 = Sprite::create(s_back3); addChild( _sprite2 ); - _sprite2->setPosition( Vector2(3*s.width/4, s.height/2) ); + _sprite2->setPosition( Vec2(3*s.width/4, s.height/2) ); _sprite2->setScale(0.5); - Vector3 eye(150, 0, 200), center(0, 0, 0), up(0, 1, 0); + Vec3 eye(150, 0, 200), center(0, 0, 0), up(0, 1, 0); - Matrix lookupMatrix; - Matrix::createLookAt(eye, center, up, &lookupMatrix); + Mat4 lookupMatrix; + Mat4::createLookAt(eye, center, up, &lookupMatrix); - Matrix lookupMatrix2 = lookupMatrix; + Mat4 lookupMatrix2 = lookupMatrix; _sprite1->setAdditionalTransform(&lookupMatrix2); _sprite2->setAdditionalTransform(&lookupMatrix2); diff --git a/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.cpp b/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.cpp index 088edc92a1..2e650c23d2 100644 --- a/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.cpp +++ b/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.cpp @@ -24,7 +24,7 @@ Parallax1::Parallax1() // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) - cocosImage->setAnchorPoint( Vector2(0,0) ); + cocosImage->setAnchorPoint( Vec2(0,0) ); // Middle layer: a Tile map atlas @@ -32,7 +32,7 @@ Parallax1::Parallax1() tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) - tilemap->setAnchorPoint( Vector2(0, 0) ); + tilemap->setAnchorPoint( Vec2(0, 0) ); // Anti Aliased images tilemap->getTexture()->setAntiAliasTexParameters(); @@ -43,7 +43,7 @@ Parallax1::Parallax1() // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) - background->setAnchorPoint( Vector2(0,0) ); + background->setAnchorPoint( Vec2(0,0) ); // create a void node, a parent node @@ -52,21 +52,21 @@ Parallax1::Parallax1() // NOW add the 3 layers to the 'void' node // background image is moved at a ratio of 0.4x, 0.5y - voidNode->addChild(background, -1, Vector2(0.4f,0.5f), Vector2::ZERO); + voidNode->addChild(background, -1, Vec2(0.4f,0.5f), Vec2::ZERO); // tiles are moved at a ratio of 2.2x, 1.0y - voidNode->addChild(tilemap, 1, Vector2(2.2f,1.0f), Vector2(0,-200) ); + voidNode->addChild(tilemap, 1, Vec2(2.2f,1.0f), Vec2(0,-200) ); // top image is moved at a ratio of 3.0x, 2.5y - voidNode->addChild(cocosImage, 2, Vector2(3.0f,2.5f), Vector2(200,800) ); + voidNode->addChild(cocosImage, 2, Vec2(3.0f,2.5f), Vec2(200,800) ); // now create some actions that will move the 'void' node // and the children of the 'void' node will move at different // speed, thus, simulation the 3D environment - auto goUp = MoveBy::create(4, Vector2(0,-500) ); + auto goUp = MoveBy::create(4, Vec2(0,-500) ); auto goDown = goUp->reverse(); - auto go = MoveBy::create(8, Vector2(-1000,0) ); + auto go = MoveBy::create(8, Vec2(-1000,0) ); auto goBack = go->reverse(); auto seq = Sequence::create(goUp, go, goDown, goBack, NULL); voidNode->runAction( (RepeatForever::create(seq) )); @@ -96,7 +96,7 @@ Parallax2::Parallax2() // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) - cocosImage->setAnchorPoint( Vector2(0,0) ); + cocosImage->setAnchorPoint( Vec2(0,0) ); // Middle layer: a Tile map atlas @@ -104,7 +104,7 @@ Parallax2::Parallax2() tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) - tilemap->setAnchorPoint( Vector2(0, 0) ); + tilemap->setAnchorPoint( Vec2(0, 0) ); // Anti Aliased images tilemap->getTexture()->setAntiAliasTexParameters(); @@ -115,7 +115,7 @@ Parallax2::Parallax2() // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) - background->setAnchorPoint( Vector2(0,0) ); + background->setAnchorPoint( Vec2(0,0) ); // create a void node, a parent node @@ -124,13 +124,13 @@ Parallax2::Parallax2() // NOW add the 3 layers to the 'void' node // background image is moved at a ratio of 0.4x, 0.5y - voidNode->addChild(background, -1, Vector2(0.4f,0.5f), Vector2::ZERO); + voidNode->addChild(background, -1, Vec2(0.4f,0.5f), Vec2::ZERO); // tiles are moved at a ratio of 1.0, 1.0y - voidNode->addChild(tilemap, 1, Vector2(1.0f,1.0f), Vector2(0,-200) ); + voidNode->addChild(tilemap, 1, Vec2(1.0f,1.0f), Vec2(0,-200) ); // top image is moved at a ratio of 3.0x, 2.5y - voidNode->addChild( cocosImage, 2, Vector2(3.0f,2.5f), Vector2(200,1000) ); + voidNode->addChild( cocosImage, 2, Vec2(3.0f,2.5f), Vec2(200,1000) ); addChild(voidNode, 0, kTagNode); } @@ -161,7 +161,7 @@ Issue2572::Issue2572() { _addChildStep = 1.0f; _wholeMoveTime = 3.0f; - _wholeMoveSize = Vector2(-300, 0); + _wholeMoveSize = Vec2(-300, 0); // create a parallax node, a parent node _paraNode = ParallaxNode::create(); @@ -186,8 +186,8 @@ void Issue2572::update(float dt) auto child = Sprite::create("Images/Icon.png"); Size viewSize = Director::getInstance()->getVisibleSize(); - Vector2 offset = Vector2(viewSize.width / 2, viewSize.height/2); - _paraNode->addChild(child, 1, Vector2( 1, 0 ), offset ); + Vec2 offset = Vec2(viewSize.width / 2, viewSize.height/2); + _paraNode->addChild(child, 1, Vec2( 1, 0 ), offset ); _childList.pushBack(child); } diff --git a/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.h b/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.h index 15f343cc5a..e7fcd82934 100644 --- a/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.h +++ b/tests/cpp-tests/Classes/ParallaxTest/ParallaxTest.h @@ -60,7 +60,7 @@ protected: float _addChildStep; float _wholeMoveTime; - Vector2 _wholeMoveSize; + Vec2 _wholeMoveSize; virtual void update(float dt) override; diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp index 570c7fa72b..d96cecd29b 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp @@ -48,7 +48,7 @@ void DemoFire::onEnter() _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) );//.pvr"); auto p = _emitter->getPosition(); - _emitter->setPosition( Vector2(p.x, 100) ); + _emitter->setPosition( Vec2(p.x, 100) ); setEmitterPosition(); } @@ -145,7 +145,7 @@ void DemoBigFlower::onEnter() _emitter->setDuration(-1); // gravity - _emitter->setGravity(Vector2::ZERO); + _emitter->setGravity(Vec2::ZERO); // angle _emitter->setAngle(90); @@ -164,8 +164,8 @@ void DemoBigFlower::onEnter() _emitter->setTangentialAccelVar(0); // emitter position - _emitter->setPosition( Vector2(160,240) ); - _emitter->setPosVar(Vector2::ZERO); + _emitter->setPosition( Vec2(160,240) ); + _emitter->setPosVar(Vec2::ZERO); // life of particles _emitter->setLife(4); @@ -229,7 +229,7 @@ void DemoRotFlower::onEnter() _emitter->setDuration(-1); // gravity - _emitter->setGravity(Vector2::ZERO); + _emitter->setGravity(Vec2::ZERO); // angle _emitter->setAngle(90); @@ -248,8 +248,8 @@ void DemoRotFlower::onEnter() _emitter->setTangentialAccelVar(0); // emitter position - _emitter->setPosition( Vector2(160,240) ); - _emitter->setPosVar(Vector2::ZERO); + _emitter->setPosition( Vec2(160,240) ); + _emitter->setPosVar(Vec2::ZERO); // life of particles _emitter->setLife(3); @@ -379,7 +379,7 @@ void DemoSmoke::onEnter() _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); auto p = _emitter->getPosition(); - _emitter->setPosition( Vector2( p.x, 100) ); + _emitter->setPosition( Vec2( p.x, 100) ); setEmitterPosition(); } @@ -403,12 +403,12 @@ void DemoSnow::onEnter() _background->addChild(_emitter, 10); auto p = _emitter->getPosition(); - _emitter->setPosition( Vector2( p.x, p.y-110) ); + _emitter->setPosition( Vec2( p.x, p.y-110) ); _emitter->setLife(3); _emitter->setLifeVar(1); // gravity - _emitter->setGravity(Vector2(0,-10)); + _emitter->setGravity(Vec2(0,-10)); // speed of particles _emitter->setSpeed(130); @@ -451,7 +451,7 @@ void DemoRain::onEnter() _background->addChild(_emitter, 10); auto p = _emitter->getPosition(); - _emitter->setPosition( Vector2( p.x, p.y-100) ); + _emitter->setPosition( Vec2( p.x, p.y-100) ); _emitter->setLife(4); _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); @@ -487,7 +487,7 @@ void DemoModernArt::onEnter() _emitter->setDuration(-1); // gravity - _emitter->setGravity(Vector2(0,0)); + _emitter->setGravity(Vec2(0,0)); // angle _emitter->setAngle(0); @@ -506,8 +506,8 @@ void DemoModernArt::onEnter() _emitter->setSpeedVar(10); // emitter position - _emitter->setPosition( Vector2( s.width/2, s.height/2) ); - _emitter->setPosVar(Vector2::ZERO); + _emitter->setPosition( Vec2( s.width/2, s.height/2) ); + _emitter->setPosVar(Vec2::ZERO); // life of particles _emitter->setLife(2.0f); @@ -596,21 +596,21 @@ void ParallaxParticle::onEnter() auto p1 = Sprite::create(s_back3); auto p2 = Sprite::create(s_back3); - p->addChild( p1, 1, Vector2(0.5f,1), Vector2(0,250) ); - p->addChild(p2, 2, Vector2(1.5f,1), Vector2(0,50) ); + p->addChild( p1, 1, Vec2(0.5f,1), Vec2(0,250) ); + p->addChild(p2, 2, Vec2(1.5f,1), Vec2(0,50) ); _emitter = ParticleFlower::create(); _emitter->retain(); _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); p1->addChild(_emitter, 10); - _emitter->setPosition( Vector2(250,200) ); + _emitter->setPosition( Vec2(250,200) ); auto par = ParticleSun::create(); p2->addChild(par, 10); par->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - auto move = MoveBy::create(4, Vector2(300,0)); + auto move = MoveBy::create(4, Vec2(300,0)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); p->runAction(RepeatForever::create(seq)); @@ -662,8 +662,8 @@ void RadiusMode1::onEnter() // emitter position auto size = Director::getInstance()->getWinSize(); - _emitter->setPosition(Vector2(size.width/2, size.height/2)); - _emitter->setPosVar(Vector2::ZERO); + _emitter->setPosition(Vec2(size.width/2, size.height/2)); + _emitter->setPosVar(Vec2::ZERO); // life of particles _emitter->setLife(5); @@ -746,8 +746,8 @@ void RadiusMode2::onEnter() // emitter position auto size = Director::getInstance()->getWinSize(); - _emitter->setPosition(Vector2(size.width/2, size.height/2)); - _emitter->setPosVar(Vector2::ZERO); + _emitter->setPosition(Vec2(size.width/2, size.height/2)); + _emitter->setPosVar(Vec2::ZERO); // life of particles _emitter->setLife(4); @@ -830,8 +830,8 @@ void Issue704::onEnter() // emitter position auto size = Director::getInstance()->getWinSize(); - _emitter->setPosition(Vector2(size.width/2, size.height/2)); - _emitter->setPosVar(Vector2::ZERO); + _emitter->setPosition(Vec2(size.width/2, size.height/2)); + _emitter->setPosVar(Vec2::ZERO); // life of particles _emitter->setLife(5); @@ -1083,22 +1083,22 @@ void ParticleDemo::onEnter(void) auto menu = Menu::create(item4, NULL); - menu->setPosition( Vector2::ZERO ); - item4->setPosition( Vector2( VisibleRect::left().x, VisibleRect::bottom().y+ 100) ); - item4->setAnchorPoint( Vector2(0,0) ); + menu->setPosition( Vec2::ZERO ); + item4->setPosition( Vec2( VisibleRect::left().x, VisibleRect::bottom().y+ 100) ); + item4->setAnchorPoint( Vec2(0,0) ); addChild( menu, 100 ); auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); - labelAtlas->setPosition(Vector2(s.width-66,50)); + labelAtlas->setPosition(Vec2(s.width-66,50)); // moving background _background = Sprite::create(s_back3); addChild(_background, 5); - _background->setPosition( Vector2(s.width/2, s.height-180) ); + _background->setPosition( Vec2(s.width/2, s.height-180) ); - auto move = MoveBy::create(4, Vector2(300,0) ); + auto move = MoveBy::create(4, Vec2(300,0) ); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); _background->runAction( RepeatForever::create(seq) ); @@ -1133,10 +1133,10 @@ void ParticleDemo::onTouchesEnded(const std::vector& touches, Event *ev auto location = touch->getLocation(); - auto pos = Vector2::ZERO; + auto pos = Vec2::ZERO; if (_background) { - pos = _background->convertToWorldSpace(Vector2::ZERO); + pos = _background->convertToWorldSpace(Vec2::ZERO); } if (_emitter != NULL) @@ -1198,7 +1198,7 @@ void ParticleDemo::setEmitterPosition() auto s = Director::getInstance()->getWinSize(); if (_emitter != NULL) { - _emitter->setPosition( Vector2(s.width / 2, s.height / 2) ); + _emitter->setPosition( Vec2(s.width / 2, s.height / 2) ); } } @@ -1269,9 +1269,9 @@ void ParticleBatchMultipleEmitters::onEnter() auto s = Director::getInstance()->getWinSize(); - emitter1->setPosition(Vector2( s.width/1.25f, s.height/1.25f)); - emitter2->setPosition(Vector2( s.width/2, s.height/2)); - emitter3->setPosition(Vector2( s.width/4, s.height/4)); + emitter1->setPosition(Vec2( s.width/1.25f, s.height/1.25f)); + emitter2->setPosition(Vec2( s.width/2, s.height/2)); + emitter3->setPosition(Vec2( s.width/4, s.height/4)); auto batch = ParticleBatchNode::createWithTexture(emitter1->getTexture()); @@ -1326,9 +1326,9 @@ void ParticleReorder::onEnter() int neg = (i==0 ? 1 : -1 ); - emitter1->setPosition(Vector2( s.width/2-30, s.height/2+60*neg)); - emitter2->setPosition(Vector2( s.width/2, s.height/2+60*neg)); - emitter3->setPosition(Vector2( s.width/2+30, s.height/2+60*neg)); + emitter1->setPosition(Vec2( s.width/2-30, s.height/2+60*neg)); + emitter2->setPosition(Vec2( s.width/2, s.height/2+60*neg)); + emitter3->setPosition(Vec2( s.width/2+30, s.height/2+60*neg)); parent->addChild(emitter1, 0, 1); parent->addChild(emitter2, 0, 2); @@ -1406,7 +1406,7 @@ bool RainbowEffect::initWithTotalParticles(int numberOfParticles) setEmitterMode(ParticleSystem::Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vector2(0,0)); + setGravity(Vec2(0,0)); // Gravity mode: radial acceleration setRadialAccel(0); @@ -1423,8 +1423,8 @@ bool RainbowEffect::initWithTotalParticles(int numberOfParticles) // emitter position auto winSize = Director::getInstance()->getWinSize(); - setPosition(Vector2(winSize.width/2, winSize.height/2)); - setPosVar(Vector2::ZERO); + setPosition(Vec2(winSize.width/2, winSize.height/2)); + setPosVar(Vec2::ZERO); // life of particles setLife(0.5f); @@ -1480,7 +1480,7 @@ void Issue1201::onEnter() auto s = Director::getInstance()->getWinSize(); - particle->setPosition(Vector2(s.width/2, s.height/2)); + particle->setPosition(Vec2(s.width/2, s.height/2)); _emitter = particle; } @@ -1508,7 +1508,7 @@ void MultipleParticleSystems::onEnter() for (int i = 0; i<5; i++) { auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); - particleSystem->setPosition(Vector2(i*50 ,i*50)); + particleSystem->setPosition(Vec2(i*50 ,i*50)); particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); addChild(particleSystem); @@ -1566,7 +1566,7 @@ void MultipleParticleSystemsBatched::onEnter() auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); - particleSystem->setPosition(Vector2(i*50 ,i*50)); + particleSystem->setPosition(Vec2(i*50 ,i*50)); batchNode->setTexture(particleSystem->getTexture()); batchNode->addChild(particleSystem); @@ -1628,7 +1628,7 @@ void AddAndDeleteParticleSystems::onEnter() particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setTotalParticles(200); - particleSystem->setPosition(Vector2(i*15 +100,i*15+100)); + particleSystem->setPosition(Vec2(i*15 +100,i*15+100)); unsigned int randZ = rand() % 100; _batchNode->addChild(particleSystem, randZ, -1); @@ -1655,7 +1655,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setTotalParticles(200); - particleSystem->setPosition(Vector2(rand() % 300 ,rand() % 400)); + particleSystem->setPosition(Vec2(rand() % 300 ,rand() % 400)); CCLOG("add a new system"); unsigned int randZ = rand() % 100; @@ -1737,7 +1737,7 @@ void ReorderParticleSystems::onEnter() particleSystem->setAngleVar(0); // emitter position - particleSystem->setPosVar(Vector2::ZERO); + particleSystem->setPosVar(Vec2::ZERO); // life of particles particleSystem->setLife(4); @@ -1774,7 +1774,7 @@ void ReorderParticleSystems::onEnter() // additive - particleSystem->setPosition(Vector2(i*10+120 ,200)); + particleSystem->setPosition(Vec2(i*10+120 ,200)); _batchNode->addChild(particleSystem); @@ -1989,7 +1989,7 @@ void ParticleAutoBatching::onEnter() for(int i=0; i<10; i++) { auto particle = ParticleSystemQuad::create("Particles/SmallSun.plist"); particle->setTotalParticles(100); - particle->setPosition(Vector2(i*s.width/11, s.height/2)); + particle->setPosition(Vec2(i*s.width/11, s.height/2)); this->addChild(particle ,10); } } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp index 5568b796b0..b7ba926f88 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -96,7 +96,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -104,7 +104,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } lastRenderedCount = 0; @@ -139,12 +139,12 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height/2+15)); + menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height/2-15)); + infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new AllocBasicLayer(true, MAX_LAYER, g_curCase); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp index 7c10f87806..82655b256c 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp @@ -89,7 +89,7 @@ void PerformanceCallbackScene::onEnter() // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -97,7 +97,7 @@ void PerformanceCallbackScene::onEnter() { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } getScheduler()->schedule(schedule_selector(PerformanceCallbackScene::onUpdate), this, 0.0f, false); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp index c41e1a05a4..b56c156732 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp @@ -98,7 +98,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1, TAG_TITLE); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -106,7 +106,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1, TAG_SUBTITLE); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } lastRenderedCount = 0; @@ -144,12 +144,12 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height/2+15)); + menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height/2-15)); + infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new ContainerBasicLayer(true, MAX_LAYER, g_curCase); @@ -181,7 +181,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) this->updateProfilerName(); }, toggleItems); - toggle->setAnchorPoint(Vector2::ANCHOR_MIDDLE_LEFT); + toggle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); toggle->setPosition(VisibleRect::left()); _toggle = toggle; @@ -200,8 +200,8 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) this->_increase->setEnabled(false); this->_decrease->setEnabled(false); }); - start->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - start->setPosition(VisibleRect::right() + Vector2(0, 40)); + start->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + start->setPosition(VisibleRect::right() + Vec2(0, 40)); _startItem = start; auto stop = MenuItemFont::create("stop", [this](Ref* sender){ @@ -219,12 +219,12 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) }); stop->setEnabled(false); - stop->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - stop->setPosition(VisibleRect::right() + Vector2(0, -40)); + stop->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + stop->setPosition(VisibleRect::right() + Vec2(0, -40)); _stopItem = stop; auto menu2 = Menu::create(toggle, start, stop, NULL); - menu2->setPosition(Vector2::ZERO); + menu2->setPosition(Vec2::ZERO); addChild(menu2); MenuItemFont::setFontSize(oldFontSize); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp index 5274712764..3eb36c686f 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp @@ -96,7 +96,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1, TAG_TITLE); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -104,7 +104,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1, TAG_SUBTITLE); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } _lastRenderedCount = 0; @@ -142,12 +142,12 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height/2+15)); + menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 listeners", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height/2-15)); + infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new EventDispatcherBasicLayer(true, MAX_LAYER, g_curCase); @@ -196,7 +196,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode reset(); }, toggleItems); - toggle->setAnchorPoint(Vector2::ANCHOR_MIDDLE_LEFT); + toggle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); toggle->setPosition(VisibleRect::left()); _toggle = toggle; @@ -215,8 +215,8 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode this->_increase->setEnabled(false); this->_decrease->setEnabled(false); }); - start->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - start->setPosition(VisibleRect::right() + Vector2(0, 40)); + start->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + start->setPosition(VisibleRect::right() + Vec2(0, 40)); _startItem = start; auto stop = MenuItemFont::create("stop", [=](Ref* sender){ @@ -236,12 +236,12 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode }); stop->setEnabled(false); - stop->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - stop->setPosition(VisibleRect::right() + Vector2(0, -40)); + stop->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + stop->setPosition(VisibleRect::right() + Vec2(0, -40)); _stopItem = stop; auto menu2 = Menu::create(toggle, start, stop, NULL); - menu2->setPosition(Vector2::ZERO); + menu2->setPosition(Vec2::ZERO); addChild(menu2); MenuItemFont::setFontSize(oldFontSize); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp index bd85ecbe25..a384b31d2f 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp @@ -99,12 +99,12 @@ void LabelMainScene::initWithSubTest(int nodes) auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height-65)); + menu->setPosition(Vec2(s.width/2, s.height-65)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height-90)); + infoLabel->setPosition(Vec2(s.width/2, s.height-90)); addChild(infoLabel, 1, kTagInfoLayer); // add menu @@ -117,7 +117,7 @@ void LabelMainScene::initWithSubTest(int nodes) */ auto menuAutoTest = Menu::create(); - menuAutoTest->setPosition( Vector2::ZERO ); + menuAutoTest->setPosition( Vec2::ZERO ); MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(24); @@ -131,14 +131,14 @@ void LabelMainScene::initWithSubTest(int nodes) autoTestItem = MenuItemFont::create("Auto Test Off",CC_CALLBACK_1(LabelMainScene::onAutoTest, this)); } autoTestItem->setTag(1); - autoTestItem->setPosition(Vector2( s.width - 90, s.height / 2)); + autoTestItem->setPosition(Vec2( s.width - 90, s.height / 2)); autoTestItem->setColor(Color3B::RED); menuAutoTest->addChild(autoTestItem); addChild( menuAutoTest, 3, kTagAutoTestMenu ); _title = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(_title, 1); - _title->setPosition(Vector2(s.width/2, s.height-50)); + _title->setPosition(Vec2(s.width/2, s.height-50)); while(_quantityNodes < nodes) onIncrease(this); @@ -195,7 +195,7 @@ void LabelMainScene::onIncrease(Ref* sender) for( int i=0;i< kNodesIncrease;i++) { auto label = Label::createWithSystemFont("LabelTTF", "Marker Felt", 30); - label->setPosition(Vector2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); + label->setPosition(Vec2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); _labelContainer->addChild(label, 1, _quantityNodes); _quantityNodes++; @@ -205,7 +205,7 @@ void LabelMainScene::onIncrease(Ref* sender) for( int i=0;i< kNodesIncrease;i++) { auto label = Label::createWithBMFont("fonts/bitmapFontTest3.fnt","LabelBMFont"); - label->setPosition(Vector2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); + label->setPosition(Vec2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); _labelContainer->addChild(label, 1, _quantityNodes); _quantityNodes++; @@ -217,7 +217,7 @@ void LabelMainScene::onIncrease(Ref* sender) for( int i=0;i< kNodesIncrease;i++) { auto label = Label::createWithTTF(ttfConfig, "Label", TextHAlignment::LEFT); - label->setPosition(Vector2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); + label->setPosition(Vec2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); _labelContainer->addChild(label, 1, _quantityNodes); _quantityNodes++; @@ -228,7 +228,7 @@ void LabelMainScene::onIncrease(Ref* sender) for( int i=0;i< kNodesIncrease;i++) { auto label = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", LongSentencesExample); - label->setPosition(Vector2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); + label->setPosition(Vec2((size.width/2 + rand() % 50), ((int)size.height/2 + rand() % 50))); _labelContainer->addChild(label, 1, _quantityNodes); _quantityNodes++; @@ -240,7 +240,7 @@ void LabelMainScene::onIncrease(Ref* sender) for( int i=0;i< kNodesIncrease;i++) { auto label = Label::createWithTTF(ttfConfig, LongSentencesExample, TextHAlignment::CENTER, size.width); - label->setPosition(Vector2((rand() % 50), rand()%((int)size.height/3))); + label->setPosition(Vec2((rand() % 50), rand()%((int)size.height/3))); _labelContainer->addChild(label, 1, _quantityNodes); _quantityNodes++; diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 5785518285..f7835b201c 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -125,7 +125,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -133,7 +133,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } lastRenderedCount = 0; @@ -168,12 +168,12 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height/2+15)); + menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height/2-15)); + infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new NodeChildrenMenuLayer(true, MAX_LAYER, g_curCase); @@ -240,7 +240,7 @@ void IterateSpriteSheet::updateQuantityOfNodes() auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setVisible(false); - sprite->setPosition(Vector2(-1000,-1000)); + sprite->setPosition(Vec2(-1000,-1000)); } } @@ -450,7 +450,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes() { auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); batchNode->addChild(sprite); - sprite->setPosition(Vector2( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); + sprite->setPosition(Vec2( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); sprite->setVisible(false); } } @@ -926,7 +926,7 @@ void VisitSceneGraph::updateQuantityOfNodes() auto node = Node::create(); this->addChild(node); node->setVisible(true); - node->setPosition(Vector2(-1000,-1000)); + node->setPosition(Vec2(-1000,-1000)); node->setTag(1000 + currentQuantityOfNodes + i ); } } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp index 7ec1ebfd0f..b001e31f5d 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -100,18 +100,18 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height/2+15)); + menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height - 90)); + infoLabel->setPosition(Vec2(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); - labelAtlas->setPosition(Vector2(s.width-66,50)); + labelAtlas->setPosition(Vec2(s.width-66,50)); // Next Prev Test auto menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); @@ -139,12 +139,12 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) } } pSubMenu->alignItemsHorizontally(); - pSubMenu->setPosition(Vector2(s.width/2, 80)); + pSubMenu->setPosition(Vec2(s.width/2, 80)); addChild(pSubMenu, 2); auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); updateQuantityLabel(); createParticleSystem(); @@ -173,10 +173,10 @@ void ParticleMainScene::createParticleSystem() /* * Tests: - * 1: Vector2 Particle System using 32-bit textures (PNG) - * 2: Vector2 Particle System using 16-bit textures (PNG) - * 3: Vector2 Particle System using 8-bit textures (PNG) - * 4: Vector2 Particle System using 4-bit textures (PVRTC) + * 1: Vec2 Particle System using 32-bit textures (PNG) + * 2: Vec2 Particle System using 16-bit textures (PNG) + * 3: Vec2 Particle System using 8-bit textures (PNG) + * 4: Vec2 Particle System using 4-bit textures (PVRTC) * 5: Quad Particle System using 32-bit textures (PNG) * 6: Quad Particle System using 16-bit textures (PNG) @@ -289,7 +289,7 @@ void ParticlePerformTest1::doTest() particleSystem->setDuration(-1); // gravity - particleSystem->setGravity(Vector2(0,-90)); + particleSystem->setGravity(Vec2(0,-90)); // angle particleSystem->setAngle(90); @@ -304,8 +304,8 @@ void ParticlePerformTest1::doTest() particleSystem->setSpeedVar(50); // emitter position - particleSystem->setPosition(Vector2(s.width/2, 100)); - particleSystem->setPosVar(Vector2(s.width/2,0)); + particleSystem->setPosition(Vec2(s.width/2, 100)); + particleSystem->setPosVar(Vec2(s.width/2,0)); // life of particles particleSystem->setLife(2.0f); @@ -359,7 +359,7 @@ void ParticlePerformTest2::doTest() particleSystem->setDuration(-1); // gravity - particleSystem->setGravity(Vector2(0,-90)); + particleSystem->setGravity(Vec2(0,-90)); // angle particleSystem->setAngle(90); @@ -374,8 +374,8 @@ void ParticlePerformTest2::doTest() particleSystem->setSpeedVar(50); // emitter position - particleSystem->setPosition(Vector2(s.width/2, 100)); - particleSystem->setPosVar(Vector2(s.width/2,0)); + particleSystem->setPosition(Vec2(s.width/2, 100)); + particleSystem->setPosVar(Vec2(s.width/2,0)); // life of particles particleSystem->setLife(2.0f); @@ -429,7 +429,7 @@ void ParticlePerformTest3::doTest() particleSystem->setDuration(-1); // gravity - particleSystem->setGravity(Vector2(0,-90)); + particleSystem->setGravity(Vec2(0,-90)); // angle particleSystem->setAngle(90); @@ -444,8 +444,8 @@ void ParticlePerformTest3::doTest() particleSystem->setSpeedVar(50); // emitter position - particleSystem->setPosition(Vector2(s.width/2, 100)); - particleSystem->setPosVar(Vector2(s.width/2,0)); + particleSystem->setPosition(Vec2(s.width/2, 100)); + particleSystem->setPosVar(Vec2(s.width/2,0)); // life of particles particleSystem->setLife(2.0f); @@ -499,7 +499,7 @@ void ParticlePerformTest4::doTest() particleSystem->setDuration(-1); // gravity - particleSystem->setGravity(Vector2(0,-90)); + particleSystem->setGravity(Vec2(0,-90)); // angle particleSystem->setAngle(90); @@ -514,8 +514,8 @@ void ParticlePerformTest4::doTest() particleSystem->setSpeedVar(50); // emitter position - particleSystem->setPosition(Vector2(s.width/2, 100)); - particleSystem->setPosVar(Vector2(s.width/2,0)); + particleSystem->setPosition(Vec2(s.width/2, 100)); + particleSystem->setPosVar(Vec2(s.width/2,0)); // life of particles particleSystem->setLife(2.0f); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp index 177a7da236..206e45d265 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp @@ -39,8 +39,8 @@ void RenderTestLayer::onEnter() addChild(map,-1); - //map->setAnchorPoint( Vector2(0, 0) ); - //map->setPosition( Vector2(-20,-200) ); + //map->setAnchorPoint( Vec2(0, 0) ); + //map->setPosition( Vec2(-20,-200) ); } void RenderTestLayer::showCurrentTest() diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp index e9753583a8..0fdeac4065 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp @@ -40,7 +40,7 @@ void ScenarioMenuLayer::onEnter() // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -48,7 +48,7 @@ void ScenarioMenuLayer::onEnter() { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } performTests(); @@ -90,12 +90,12 @@ void ScenarioTest::performTests() // add tile map _map1 = TMXTiledMap::create("TileMaps/iso-test.tmx"); - _map1->setAnchorPoint( Vector2(0.5, 0.5) ); + _map1->setAnchorPoint( Vec2(0.5, 0.5) ); _map1->setPosition(origin); this->addChild(_map1); _map2 = TMXTiledMap::create("TileMaps/iso-test2.tmx"); - _map2->setAnchorPoint( Vector2(0.5, 0.5) ); + _map2->setAnchorPoint( Vec2(0.5, 0.5) ); _map2->setPosition(origin); this->addChild(_map2); @@ -106,8 +106,8 @@ void ScenarioTest::performTests() MenuItemFont::create( "Add/Remove Particle"), MenuItemFont::create( "Add/Remove Particle System"), NULL); - _itemToggle->setAnchorPoint(Vector2(0.0f, 0.5f)); - _itemToggle->setPosition(Vector2(origin.x, origin.y + s.height / 2)); + _itemToggle->setAnchorPoint(Vec2(0.0f, 0.5f)); + _itemToggle->setPosition(Vec2(origin.x, origin.y + s.height / 2)); // add decrease & increase menu item MenuItemFont::setFontSize(65); @@ -127,7 +127,7 @@ void ScenarioTest::performTests() break; } }); - decrease->setPosition(Vector2(origin.x + s.width / 2 - 80, origin.y + 80)); + decrease->setPosition(Vec2(origin.x + s.width / 2 - 80, origin.y + 80)); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { int idx = _itemToggle->getSelectedIndex(); @@ -146,30 +146,30 @@ void ScenarioTest::performTests() } }); increase->setColor(Color3B(0,200,20)); - increase->setPosition(Vector2(origin.x + s.width / 2 + 80, origin.y + 80)); + increase->setPosition(Vec2(origin.x + s.width / 2 + 80, origin.y + 80)); auto menu = Menu::create(_itemToggle, decrease, increase, NULL); - menu->setPosition(Vector2(0.0f, 0.0f)); + menu->setPosition(Vec2(0.0f, 0.0f)); addChild(menu, 10); // add tip labels _spriteLabel = Label::createWithTTF("Sprites : 0", "fonts/arial.ttf", 15); - _spriteLabel->setAnchorPoint(Vector2(0.0f, 0.5f)); + _spriteLabel->setAnchorPoint(Vec2(0.0f, 0.5f)); addChild(_spriteLabel, 10); - _spriteLabel->setPosition(Vector2(origin.x, origin.y + s.height/2 + 70)); + _spriteLabel->setPosition(Vec2(origin.x, origin.y + s.height/2 + 70)); char str[32] = { 0 }; sprintf(str, "Particles : %d", _particleNumber); _particleLabel = Label::createWithTTF(str, "fonts/arial.ttf", 15); - _particleLabel->setAnchorPoint(Vector2(0.0f, 0.5f)); + _particleLabel->setAnchorPoint(Vec2(0.0f, 0.5f)); addChild(_particleLabel, 10); - _particleLabel->setPosition(Vector2(origin.x, origin.y + s.height/2 + 45)); + _particleLabel->setPosition(Vec2(origin.x, origin.y + s.height/2 + 45)); _parsysLabel = Label::createWithTTF("Particle System : 0", "fonts/arial.ttf", 15); - _parsysLabel->setAnchorPoint(Vector2(0.0f, 0.5f)); + _parsysLabel->setAnchorPoint(Vec2(0.0f, 0.5f)); addChild(_parsysLabel, 10); - _parsysLabel->setPosition(Vector2(origin.x, origin.y + s.height/2 + 20)); + _parsysLabel->setPosition(Vec2(origin.x, origin.y + s.height/2 + 20)); // add sprites addNewSprites(_initSpriteNum); @@ -236,7 +236,7 @@ void ScenarioTest::addNewSprites(int num) float randomx = CCRANDOM_0_1(); float randomy = CCRANDOM_0_1(); - sprite->setPosition(origin + Vector2(randomx * s.width, randomy * s.height)); + sprite->setPosition(origin + Vec2(randomx * s.width, randomy * s.height)); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -310,7 +310,7 @@ void ScenarioTest::addParticleSystem(int num) float randomx = CCRANDOM_0_1(); float randomy = CCRANDOM_0_1(); - par->setPosition(origin + Vector2(s.width * randomx, s.height * randomy)); + par->setPosition(origin + Vec2(s.width * randomx, s.height * randomy)); par->setTotalParticles(_particleNumber); addChild(par, 9); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp index 453edff62e..8625056b41 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -388,12 +388,12 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); - menu->setPosition(Vector2(s.width/2, s.height-65)); + menu->setPosition(Vec2(s.width/2, s.height-65)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); - infoLabel->setPosition(Vector2(s.width/2, s.height-90)); + infoLabel->setPosition(Vec2(s.width/2, s.height-90)); addChild(infoLabel, 1, kTagInfoLayer); // add menu @@ -406,7 +406,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) */ auto menuAutoTest = Menu::create(); - menuAutoTest->setPosition( Vector2::ZERO ); + menuAutoTest->setPosition( Vec2::ZERO ); MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(24); @@ -420,7 +420,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) autoTestItem = MenuItemFont::create("Auto Test Off",CC_CALLBACK_1(SpriteMainScene::onAutoTest, this)); } autoTestItem->setTag(1); - autoTestItem->setPosition(Vector2( s.width - 90, s.height / 2)); + autoTestItem->setPosition(Vec2( s.width - 90, s.height / 2)); menuAutoTest->addChild(autoTestItem); addChild( menuAutoTest, 3, kTagAutoTestMenu ); @@ -446,13 +446,13 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) } subMenu->alignItemsHorizontally(); - subMenu->setPosition(Vector2(s.width/2, 80)); + subMenu->setPosition(Vec2(s.width/2, 80)); addChild(subMenu, 2); // add title label auto label = Label::createWithTTF(title(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // subtitle @@ -461,7 +461,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) { auto l = Label::createWithTTF(strSubtitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 9999); - l->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - 60) ); + l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) ); } while(quantityNodes < nNodes) @@ -755,7 +755,7 @@ void SpriteMainScene::onAutoTest(Ref* sender) void performanceActions(Sprite* sprite) { auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Vec2((rand() % (int)size.width), (rand() % (int)size.height))); float period = 0.5f + (rand() % 1000) / 500.0f; auto rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1()); @@ -773,9 +773,9 @@ void performanceActions20(Sprite* sprite) { auto size = Director::getInstance()->getWinSize(); if( CCRANDOM_0_1() < 0.2f ) - sprite->setPosition(Vector2((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Vec2((rand() % (int)size.width), (rand() % (int)size.height))); else - sprite->setPosition(Vector2( -1000, -1000)); + sprite->setPosition(Vec2( -1000, -1000)); float period = 0.5f + (rand() % 1000) / 500.0f; auto rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1()); @@ -792,7 +792,7 @@ void performanceActions20(Sprite* sprite) void performanceRotationScale(Sprite* sprite) { auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Vec2((rand() % (int)size.width), (rand() % (int)size.height))); sprite->setRotation(CCRANDOM_0_1() * 360); sprite->setScale(CCRANDOM_0_1() * 2); } @@ -800,7 +800,7 @@ void performanceRotationScale(Sprite* sprite) void performancePosition(Sprite* sprite) { auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Vec2((rand() % (int)size.width), (rand() % (int)size.height))); } void performanceout20(Sprite* sprite) @@ -808,20 +808,20 @@ void performanceout20(Sprite* sprite) auto size = Director::getInstance()->getWinSize(); if( CCRANDOM_0_1() < 0.2f ) - sprite->setPosition(Vector2((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Vec2((rand() % (int)size.width), (rand() % (int)size.height))); else - sprite->setPosition(Vector2( -1000, -1000)); + sprite->setPosition(Vec2( -1000, -1000)); } void performanceOut100(Sprite* sprite) { - sprite->setPosition(Vector2( -1000, -1000)); + sprite->setPosition(Vec2( -1000, -1000)); } void performanceScale(Sprite* sprite) { auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Vec2((rand() % (int)size.width), (rand() % (int)size.height))); sprite->setScale(CCRANDOM_0_1() * 100 / 50); } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp index 691707cac7..914bd46a87 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp @@ -40,7 +40,7 @@ struct { static const int g_testMax = sizeof(g_testsName)/sizeof(g_testsName[0]); -Vector2 PerformanceMainLayer::_CurrentPos = Vector2::ZERO; +Vec2 PerformanceMainLayer::_CurrentPos = Vec2::ZERO; //////////////////////////////////////////////////////// // @@ -60,7 +60,7 @@ void PerformanceMainLayer::onEnter() for (int i = 0; i < g_testMax; ++i) { auto pItem = MenuItemFont::create(g_testsName[i].name, g_testsName[i].callback); - pItem->setPosition(Vector2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); + pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -91,17 +91,17 @@ void PerformanceMainLayer::onTouchMoved(Touch* touches, Event *event) float nMoveY = touchLocation.y - _beginPos.y; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } @@ -116,17 +116,17 @@ void PerformanceMainLayer::onMouseScroll(Event *event) float nMoveY = mouseEvent->getScrollY() * 6; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } @@ -154,18 +154,18 @@ void PerformBasicLayer::onEnter() MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(24); auto pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(PerformBasicLayer::toMainLayer, this)); - pMainItem->setPosition(Vector2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + pMainItem->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); auto menu = Menu::create(pMainItem, NULL); - menu->setPosition( Vector2::ZERO ); + menu->setPosition( Vec2::ZERO ); if (_controlMenuVisible) { auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(PerformBasicLayer::backCallback, this)); auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(PerformBasicLayer::restartCallback, this)); auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(PerformBasicLayer::nextCallback, this)); - item1->setPosition(Vector2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vector2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); menu->addChild(item1, kItemTagBasic); menu->addChild(item2, kItemTagBasic); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h index be79a0a2d6..45fb299acf 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h @@ -13,10 +13,10 @@ public: void onMouseScroll(Event *event); protected: - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; - static Vector2 _CurrentPos; + static Vec2 _CurrentPos; }; class PerformBasicLayer : public Layer diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp index 6132bf508c..fe02765945 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp @@ -50,7 +50,7 @@ void TextureMenuLayer::onEnter() // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); @@ -58,7 +58,7 @@ void TextureMenuLayer::onEnter() { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1); - l->setPosition(Vector2(s.width/2, s.height-80)); + l->setPosition(Vec2(s.width/2, s.height-80)); } performTests(); diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp index ca4d53e945..cb3f16091b 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp @@ -75,12 +75,12 @@ void TouchesMainScene::onEnter() // add title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); scheduleUpdate(); _plabel = Label::createWithBMFont("fonts/arial16.fnt","00.0"); - _plabel->setPosition(Vector2(s.width/2, s.height/2)); + _plabel->setPosition(Vec2(s.width/2, s.height/2)); addChild(_plabel); elapsedTime = 0; @@ -225,7 +225,7 @@ void TouchesPerformTest3::onEnter() // add title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); #define TOUCH_PROFILER_NAME "TouchProfileName" #define TOUCHABLE_NODE_NUM 1000 @@ -282,7 +282,7 @@ void TouchesPerformTest3::onEnter() } }); - menuItem->setPosition(Vector2(0, -20)); + menuItem->setPosition(Vec2(0, -20)); auto menu = Menu::create(menuItem, NULL); addChild(menu); } diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index 8240019fed..8dd67b948a 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -90,7 +90,7 @@ void PhysicsDemoDisabled::onEnter() "fonts/arial.ttf", 18); auto size = Director::getInstance()->getWinSize(); - label->setPosition(Vector2(size.width/2, size.height/2)); + label->setPosition(Vec2(size.width/2, size.height/2)); addChild(label); } @@ -156,10 +156,10 @@ void PhysicsDemo::onEnter() auto menu = Menu::create(item, NULL); this->addChild(menu); - menu->setPosition(Vector2(VisibleRect::right().x-50, VisibleRect::top().y-10)); + menu->setPosition(Vec2(VisibleRect::right().x-50, VisibleRect::top().y-10)); } -Sprite* PhysicsDemo::addGrossiniAtPosition(Vector2 p, float scale/* = 1.0*/) +Sprite* PhysicsDemo::addGrossiniAtPosition(Vec2 p, float scale/* = 1.0*/) { CCLOG("Add sprite %0.2f x %02.f",p.x,p.y); @@ -243,7 +243,7 @@ void PhysicsDemoClickAdd::onAcceleration(Acceleration* acc, Event* event) prevX = accelX; prevY = accelY; - auto v = Vector2( accelX, accelY); + auto v = Vec2( accelX, accelY); v = v * 200; if(_scene != nullptr) @@ -305,7 +305,7 @@ namespace } } -Sprite* PhysicsDemo::makeBall(Vector2 point, float radius, PhysicsMaterial material) +Sprite* PhysicsDemo::makeBall(Vec2 point, float radius, PhysicsMaterial material) { Sprite* ball = nullptr; if (_ball != nullptr) @@ -320,12 +320,12 @@ Sprite* PhysicsDemo::makeBall(Vector2 point, float radius, PhysicsMaterial mater auto body = PhysicsBody::createCircle(radius, material); ball->setPhysicsBody(body); - ball->setPosition(Vector2(point.x, point.y)); + ball->setPosition(Vec2(point.x, point.y)); return ball; } -Sprite* PhysicsDemo::makeBox(Vector2 point, Size size, int color, PhysicsMaterial material) +Sprite* PhysicsDemo::makeBox(Vec2 point, Size size, int color, PhysicsMaterial material) { bool yellow = false; if (color == 0) @@ -343,12 +343,12 @@ Sprite* PhysicsDemo::makeBox(Vector2 point, Size size, int color, PhysicsMateria auto body = PhysicsBody::createBox(size, material); box->setPhysicsBody(body); - box->setPosition(Vector2(point.x, point.y)); + box->setPosition(Vec2(point.x, point.y)); return box; } -Sprite* PhysicsDemo::makeTriangle(Vector2 point, Size size, int color, PhysicsMaterial material) +Sprite* PhysicsDemo::makeTriangle(Vec2 point, Size size, int color, PhysicsMaterial material) { bool yellow = false; if (color == 0) @@ -370,11 +370,11 @@ Sprite* PhysicsDemo::makeTriangle(Vector2 point, Size size, int color, PhysicsMa triangle->setScaleY(size.height/43.5f); } - Vector2 vers[] = { Vector2(0, size.height/2), Vector2(size.width/2, -size.height/2), Vector2(-size.width/2, -size.height/2)}; + Vec2 vers[] = { Vec2(0, size.height/2), Vec2(size.width/2, -size.height/2), Vec2(-size.width/2, -size.height/2)}; auto body = PhysicsBody::createPolygon(vers, 3, material); triangle->setPhysicsBody(body); - triangle->setPosition(Vector2(point.x, point.y)); + triangle->setPosition(Vec2(point.x, point.y)); return triangle; } @@ -438,7 +438,7 @@ void PhysicsDemoLogoSmash::onEnter() { PhysicsDemo::onEnter(); - _scene->getPhysicsWorld()->setGravity(Vector2(0, 0)); + _scene->getPhysicsWorld()->setGravity(Vec2(0, 0)); _scene->getPhysicsWorld()->setUpdateRate(5.0f); _ball = SpriteBatchNode::create("Images/ball.png", sizeof(logo_image)/sizeof(logo_image[0])); @@ -452,7 +452,7 @@ void PhysicsDemoLogoSmash::onEnter() float x_jitter = 0.05*frand(); float y_jitter = 0.05*frand(); - Node* ball = makeBall(Vector2(2*(x - logo_width/2 + x_jitter) + VisibleRect::getVisibleRect().size.width/2, + Node* ball = makeBall(Vec2(2*(x - logo_width/2 + x_jitter) + VisibleRect::getVisibleRect().size.width/2, 2*(logo_height-y + y_jitter) + VisibleRect::getVisibleRect().size.height/2 - logo_height/2), 0.95f, PhysicsMaterial(0.01f, 0.0f, 0.0f)); @@ -466,10 +466,10 @@ void PhysicsDemoLogoSmash::onEnter() } - auto bullet = makeBall(Vector2(400, 0), 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); - bullet->getPhysicsBody()->setVelocity(Vector2(200, 0)); + auto bullet = makeBall(Vec2(400, 0), 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); + bullet->getPhysicsBody()->setVelocity(Vec2(200, 0)); - bullet->setPosition(Vector2(-500, VisibleRect::getVisibleRect().size.height/2)); + bullet->setPosition(Vec2(-500, VisibleRect::getVisibleRect().size.height/2)); _ball->addChild(bullet); } @@ -499,7 +499,7 @@ void PhysicsDemoPyramidStack::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto node = Node::create(); - node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vector2(0, 50), VisibleRect::rightBottom() + Vector2(0, 50))); + node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); this->addChild(node); auto ball = Sprite::create("Images/ball.png"); @@ -507,7 +507,7 @@ void PhysicsDemoPyramidStack::onEnter() ball->setTag(100); ball->setPhysicsBody(PhysicsBody::createCircle(10)); ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - ball->setPosition(VisibleRect::bottom() + Vector2(0, 60)); + ball->setPosition(VisibleRect::bottom() + Vec2(0, 60)); this->addChild(ball); scheduleOnce(schedule_selector(PhysicsDemoPyramidStack::updateOnce), 3.0); @@ -516,7 +516,7 @@ void PhysicsDemoPyramidStack::onEnter() { for(int j=0; j<=i; j++) { - auto sp = addGrossiniAtPosition(VisibleRect::bottom() + Vector2((i/2 - j) * 11, (14 - i) * 23 + 100), 0.2f); + auto sp = addGrossiniAtPosition(VisibleRect::bottom() + Vec2((i/2 - j) * 11, (14 - i) * 23 + 100), 0.2f); sp->getPhysicsBody()->setTag(DRAG_BODYS_TAG); } } @@ -543,8 +543,8 @@ void PhysicsDemoRayCast::onEnter() _scene->getPhysicsWorld()->setGravity(Point::ZERO); auto node = DrawNode::create(); - node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vector2(0, 50), VisibleRect::rightBottom() + Vector2(0, 50))); - node->drawSegment(VisibleRect::leftBottom() + Vector2(0, 50), VisibleRect::rightBottom() + Vector2(0, 50), 1, STATIC_COLOR); + node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); + node->drawSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50), 1, STATIC_COLOR); this->addChild(node); MenuItemFont::setFontSize(18); @@ -552,7 +552,7 @@ void PhysicsDemoRayCast::onEnter() auto menu = Menu::create(item, NULL); this->addChild(menu); - menu->setPosition(Vector2(VisibleRect::left().x+100, VisibleRect::top().y-10)); + menu->setPosition(Vec2(VisibleRect::left().x+100, VisibleRect::top().y-10)); scheduleUpdate(); } @@ -580,16 +580,16 @@ void PhysicsDemoRayCast::changeModeCallback(Ref* sender) bool PhysicsDemoRayCast::anyRay(PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data) { - *((Vector2*)data) = info.contact; + *((Vec2*)data) = info.contact; return false; } void PhysicsDemoRayCast::update(float delta) { float L = 150.0f; - Vector2 point1 = VisibleRect::center(); - Vector2 d(L * cosf(_angle), L * sinf(_angle)); - Vector2 point2 = point1 + d; + Vec2 point1 = VisibleRect::center(); + Vec2 d(L * cosf(_angle), L * sinf(_angle)); + Vec2 point2 = point1 + d; removeChild(_node); _node = DrawNode::create(); @@ -597,7 +597,7 @@ void PhysicsDemoRayCast::update(float delta) { case 0: { - Vector2 point3 = point2; + Vec2 point3 = point2; auto func = CC_CALLBACK_3(PhysicsDemoRayCast::anyRay, this); _scene->getPhysicsWorld()->rayCast(func, point1, point2, &point3); @@ -613,7 +613,7 @@ void PhysicsDemoRayCast::update(float delta) } case 1: { - Vector2 point3 = point2; + Vec2 point3 = point2; float friction = 1.0f; PhysicsRayCastCallbackFunc func = [&point3, &friction](PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data)->bool { @@ -640,7 +640,7 @@ void PhysicsDemoRayCast::update(float delta) case 2: { #define MAX_MULTI_RAYCAST_NUM 5 - Vector2 points[MAX_MULTI_RAYCAST_NUM]; + Vec2 points[MAX_MULTI_RAYCAST_NUM]; int num = 0; PhysicsRayCastCallbackFunc func = [&points, &num](PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data)->bool @@ -729,16 +729,16 @@ void PhysicsDemoJoints::onEnter() { for (int j = 0; j < 4; ++j) { - Vector2 offset(VisibleRect::leftBottom().x + 5 + j * width + width/2, VisibleRect::leftBottom().y + 50 + i * height + height/2); + Vec2 offset(VisibleRect::leftBottom().x + 5 + j * width + width/2, VisibleRect::leftBottom().y + 50 + i * height + height/2); box->addShape(PhysicsShapeEdgeBox::create(Size(width, height), PHYSICSSHAPE_MATERIAL_DEFAULT, 1, offset)); switch (i*4 + j) { case 0: { - auto sp1 = makeBall(offset - Vector2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30, 0), 10); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBall(offset + Vector2(30, 0), 10); + auto sp2 = makeBall(offset + Vec2(30, 0), 10); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); PhysicsJointPin* joint = PhysicsJointPin::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset); @@ -751,9 +751,9 @@ void PhysicsDemoJoints::onEnter() case 1: { - auto sp1 = makeBall(offset - Vector2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30, 0), 10); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); PhysicsJointFixed* joint = PhysicsJointFixed::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset); @@ -766,9 +766,9 @@ void PhysicsDemoJoints::onEnter() case 2: { - auto sp1 = makeBall(offset - Vector2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30, 0), 10); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); PhysicsJointDistance* joint = PhysicsJointDistance::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO); @@ -780,9 +780,9 @@ void PhysicsDemoJoints::onEnter() } case 3: { - auto sp1 = makeBall(offset - Vector2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30, 0), 10); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 30.0f, 60.0f); @@ -794,9 +794,9 @@ void PhysicsDemoJoints::onEnter() } case 4: { - auto sp1 = makeBall(offset - Vector2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30, 0), 10); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); PhysicsJointSpring* joint = PhysicsJointSpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 500.0f, 0.3f); @@ -808,12 +808,12 @@ void PhysicsDemoJoints::onEnter() } case 5: { - auto sp1 = makeBall(offset - Vector2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30, 0), 10); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Vector2(30, 15), Vector2(30, -15), Vector2(-30, 0)); + PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Vec2(30, 15), Vec2(30, -15), Vec2(-30, 0)); _scene->getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -822,9 +822,9 @@ void PhysicsDemoJoints::onEnter() } case 6: { - auto sp1 = makeBox(offset - Vector2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); @@ -838,9 +838,9 @@ void PhysicsDemoJoints::onEnter() } case 7: { - auto sp1 = makeBox(offset - Vector2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); @@ -854,9 +854,9 @@ void PhysicsDemoJoints::onEnter() } case 8: { - auto sp1 = makeBox(offset - Vector2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); @@ -870,9 +870,9 @@ void PhysicsDemoJoints::onEnter() } case 9: { - auto sp1 = makeBox(offset - Vector2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); @@ -886,9 +886,9 @@ void PhysicsDemoJoints::onEnter() } case 10: { - auto sp1 = makeBox(offset - Vector2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vector2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); @@ -928,15 +928,15 @@ void PhysicsDemoActions::onEnter() this->addChild(node); Sprite* sp1 = addGrossiniAtPosition(VisibleRect::center()); - Sprite* sp2 = addGrossiniAtPosition(VisibleRect::left() + Vector2(50, 0)); - Sprite* sp3 = addGrossiniAtPosition(VisibleRect::right() - Vector2(20, 0)); - Sprite* sp4 = addGrossiniAtPosition(VisibleRect::leftTop() + Vector2(50, -50)); + Sprite* sp2 = addGrossiniAtPosition(VisibleRect::left() + Vec2(50, 0)); + Sprite* sp3 = addGrossiniAtPosition(VisibleRect::right() - Vec2(20, 0)); + Sprite* sp4 = addGrossiniAtPosition(VisibleRect::leftTop() + Vec2(50, -50)); sp4->getPhysicsBody()->setGravityEnable(false); - auto actionTo = JumpTo::create(2, Vector2(100,100), 50, 4); - auto actionBy = JumpBy::create(2, Vector2(300,0), 50, 4); - auto actionUp = JumpBy::create(2, Vector2(0,50), 80, 4); + auto actionTo = JumpTo::create(2, Vec2(100,100), 50, 4); + auto actionBy = JumpBy::create(2, Vec2(300,0), 50, 4); + auto actionUp = JumpBy::create(2, Vec2(0,50), 80, 4); auto actionByBack = actionBy->reverse(); sp1->runAction(RepeatForever::create(actionUp)); @@ -969,20 +969,20 @@ void PhysicsDemoPump::onEnter() body->setDynamic(false); PhysicsMaterial staticMaterial(PHYSICS_INFINITY, 0, 0.5f); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(50, 0), VisibleRect::leftTop() + Vector2(50, -130), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(190, 0), VisibleRect::leftTop() + Vector2(100, -50), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(100, -50), VisibleRect::leftTop() + Vector2(100, -90), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(50, -130), VisibleRect::leftTop() + Vector2(100, -145), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(100, -145), VisibleRect::leftBottom() + Vector2(100, 80), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(150, -80), VisibleRect::leftBottom() + Vector2(150, 80), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vector2(150, -80), VisibleRect::rightTop() + Vector2(-100, -150), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(50, 0), VisibleRect::leftTop() + Vec2(50, -130), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(190, 0), VisibleRect::leftTop() + Vec2(100, -50), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(100, -50), VisibleRect::leftTop() + Vec2(100, -90), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(50, -130), VisibleRect::leftTop() + Vec2(100, -145), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(100, -145), VisibleRect::leftBottom() + Vec2(100, 80), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(150, -80), VisibleRect::leftBottom() + Vec2(150, 80), staticMaterial, 2.0f)); + body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(150, -80), VisibleRect::rightTop() + Vec2(-100, -150), staticMaterial, 2.0f)); body->setCategoryBitmask(0x01); // balls for (int i = 0; i < 6; ++i) { - auto ball = makeBall(VisibleRect::leftTop() + Vector2(75 + CCRANDOM_0_1() * 90, 0), 22, PhysicsMaterial(0.05f, 0.0f, 0.1f)); + auto ball = makeBall(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0), 22, PhysicsMaterial(0.05f, 0.0f, 0.1f)); ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(ball); } @@ -990,12 +990,12 @@ void PhysicsDemoPump::onEnter() node->setPhysicsBody(body); this->addChild(node); - Vector2 vec[4] = + Vec2 vec[4] = { - VisibleRect::leftTop() + Vector2(102, -148), - VisibleRect::leftTop() + Vector2(148, -161), - VisibleRect::leftBottom() + Vector2(148, 20), - VisibleRect::leftBottom() + Vector2(102, 20) + VisibleRect::leftTop() + Vec2(102, -148), + VisibleRect::leftTop() + Vec2(148, -161), + VisibleRect::leftBottom() + Vec2(148, 20), + VisibleRect::leftBottom() + Vec2(102, 20) }; auto _world = _scene->getPhysicsWorld(); @@ -1004,7 +1004,7 @@ void PhysicsDemoPump::onEnter() auto sgear = Node::create(); auto sgearB = PhysicsBody::createCircle(44); sgear->setPhysicsBody(sgearB); - sgear->setPosition(VisibleRect::leftBottom() + Vector2(125, 0)); + sgear->setPosition(VisibleRect::leftBottom() + Vec2(125, 0)); this->addChild(sgear); sgearB->setCategoryBitmask(0x04); sgearB->setCollisionBitmask(0x04); @@ -1016,7 +1016,7 @@ void PhysicsDemoPump::onEnter() auto bgear = Node::create(); auto bgearB = PhysicsBody::createCircle(100); bgear->setPhysicsBody(bgearB); - bgear->setPosition(VisibleRect::leftBottom() + Vector2(275, 0)); + bgear->setPosition(VisibleRect::leftBottom() + Vec2(275, 0)); this->addChild(bgear); bgearB->setCategoryBitmask(0x04); _world->addJoint(PhysicsJointPin::construct(body, bgearB, bgearB->getPosition())); @@ -1031,11 +1031,11 @@ void PhysicsDemoPump::onEnter() this->addChild(pump); pumpB->setCategoryBitmask(0x02); pumpB->setGravityEnable(false); - _world->addJoint(PhysicsJointDistance::construct(pumpB, sgearB, Vector2(0, 0), Vector2(0, -44))); + _world->addJoint(PhysicsJointDistance::construct(pumpB, sgearB, Vec2(0, 0), Vec2(0, -44))); // plugger - Vector2 seg[] = {VisibleRect::leftTop() + Vector2(75, -120), VisibleRect::leftBottom() + Vector2(75, -100)}; - Vector2 segCenter = (seg[1] + seg[0])/2; + Vec2 seg[] = {VisibleRect::leftTop() + Vec2(75, -120), VisibleRect::leftBottom() + Vec2(75, -100)}; + Vec2 segCenter = (seg[1] + seg[0])/2; seg[1] -= segCenter; seg[0] -= segCenter; auto plugger = Node::create(); @@ -1048,8 +1048,8 @@ void PhysicsDemoPump::onEnter() this->addChild(plugger); pluggerB->setCategoryBitmask(0x02); sgearB->setCollisionBitmask(0x04 | 0x01); - _world->addJoint(PhysicsJointPin::construct(body, pluggerB, VisibleRect::leftBottom() + Vector2(75, -90))); - _world->addJoint(PhysicsJointDistance::construct(pluggerB, sgearB, pluggerB->world2Local(VisibleRect::leftBottom() + Vector2(75, 0)), Vector2(44, 0))); + _world->addJoint(PhysicsJointPin::construct(body, pluggerB, VisibleRect::leftBottom() + Vec2(75, -90))); + _world->addJoint(PhysicsJointDistance::construct(pluggerB, sgearB, pluggerB->world2Local(VisibleRect::leftBottom() + Vec2(75, 0)), Vec2(44, 0))); } void PhysicsDemoPump::update(float delta) @@ -1058,8 +1058,8 @@ void PhysicsDemoPump::update(float delta) { if (body->getTag() == DRAG_BODYS_TAG && body->getPosition().y < 0.0f) { - body->getNode()->setPosition(VisibleRect::leftTop() + Vector2(75 + CCRANDOM_0_1() * 90, 0)); - body->setVelocity(Vector2(0, 0)); + body->getNode()->setPosition(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0)); + body->setVelocity(Vec2(0, 0)); } } @@ -1124,7 +1124,7 @@ void PhysicsDemoOneWayPlatform::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto ground = Node::create(); - ground->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vector2(0, 50), VisibleRect::rightBottom() + Vector2(0, 50))); + ground->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); this->addChild(ground); auto platform = makeBox(VisibleRect::center(), Size(200, 50)); @@ -1132,8 +1132,8 @@ void PhysicsDemoOneWayPlatform::onEnter() platform->getPhysicsBody()->setContactTestBitmask(0xFFFFFFFF); this->addChild(platform); - auto ball = makeBall(VisibleRect::center() - Vector2(0, 50), 20); - ball->getPhysicsBody()->setVelocity(Vector2(0, 150)); + auto ball = makeBall(VisibleRect::center() - Vec2(0, 50), 20); + ball->getPhysicsBody()->setVelocity(Vec2(0, 150)); ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); ball->getPhysicsBody()->setMass(1.0f); ball->getPhysicsBody()->setContactTestBitmask(0xFFFFFFFF); @@ -1167,11 +1167,11 @@ void PhysicsDemoSlice::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto ground = Node::create(); - ground->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vector2(0, 50), VisibleRect::rightBottom() + Vector2(0, 50))); + ground->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); this->addChild(ground); auto box = Node::create(); - Vector2 points[4] = {Vector2(-100, -100), Vector2(-100, 100), Vector2(100, 100), Vector2(100, -100)}; + Vec2 points[4] = {Vec2(-100, -100), Vec2(-100, 100), Vec2(100, 100), Vec2(100, -100)}; box->setPhysicsBody(PhysicsBody::createPolygon(points, 4)); box->setPosition(VisibleRect::center()); box->getPhysicsBody()->setTag(_sliceTag); @@ -1187,7 +1187,7 @@ bool PhysicsDemoSlice::slice(PhysicsWorld &world, const PhysicsRayCastInfo& info if (!info.shape->containsPoint(info.start) && !info.shape->containsPoint(info.end)) { - Vector2 normal = info.end - info.start; + Vec2 normal = info.end - info.start; normal = normal.getPerp().getNormalized(); float dist = info.start.dot(normal); @@ -1200,16 +1200,16 @@ bool PhysicsDemoSlice::slice(PhysicsWorld &world, const PhysicsRayCastInfo& info return true; } -void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vector2 normal, float distance) +void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vec2 normal, float distance) { PhysicsBody* body = shape->getBody(); int count = shape->getPointsCount(); int pointsCount = 0; - Vector2* points = new Vector2[count + 1]; + Vec2* points = new Vec2[count + 1]; for (int i=0, j=count-1; ilocal2World(shape->getPoint(j)); + Vec2 a = body->local2World(shape->getPoint(j)); float aDist = a.dot(normal) - distance; if (aDist < 0.0f) @@ -1218,7 +1218,7 @@ void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vector2 normal, floa ++pointsCount; } - Vector2 b = body->local2World(shape->getPoint(i)); + Vec2 b = body->local2World(shape->getPoint(i)); float bDist = b.dot(normal) - distance; if (aDist*bDist < 0.0f) @@ -1229,7 +1229,7 @@ void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vector2 normal, floa } } - Vector2 center = PhysicsShape::getPolyonCenter(points, pointsCount); + Vec2 center = PhysicsShape::getPolyonCenter(points, pointsCount); Node* node = Node::create(); PhysicsBody* polyon = PhysicsBody::createPolygon(points, pointsCount, PHYSICSBODY_MATERIAL_DEFAULT, -center); node->setPosition(center); @@ -1266,11 +1266,11 @@ void PhysicsDemoBug3988::onEnter() _scene->getPhysicsWorld()->setGravity(Vect::ZERO); auto ball = Sprite::create("Images/YellowSquare.png"); - ball->setPosition(VisibleRect::center() - Vector2(100, 0)); + ball->setPosition(VisibleRect::center() - Vec2(100, 0)); ball->setRotation(30.0f); this->addChild(ball); - auto physicsBall = makeBox(VisibleRect::center() + Vector2(100, 0), Size(100, 100)); + auto physicsBall = makeBox(VisibleRect::center() + Vec2(100, 0), Size(100, 100)); physicsBall->setRotation(30.0f); this->addChild(physicsBall); } @@ -1307,12 +1307,12 @@ void PhysicsContactTest::onEnter() auto menu1 = Menu::create(decrease1, increase1, NULL); menu1->alignItemsHorizontally(); - menu1->setPosition(Vector2(s.width/2, s.height-50)); + menu1->setPosition(Vec2(s.width/2, s.height-50)); addChild(menu1, 1); auto label = Label::createWithTTF("yellow box", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2 - 150, s.height-50)); + label->setPosition(Vec2(s.width/2 - 150, s.height-50)); auto decrease2 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); decrease2->setColor(Color3B(0,200,20)); @@ -1323,12 +1323,12 @@ void PhysicsContactTest::onEnter() auto menu2 = Menu::create(decrease2, increase2, NULL); menu2->alignItemsHorizontally(); - menu2->setPosition(Vector2(s.width/2, s.height-90)); + menu2->setPosition(Vec2(s.width/2, s.height-90)); addChild(menu2, 1); label = Label::createWithTTF("blue box", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2 - 150, s.height-90)); + label->setPosition(Vec2(s.width/2 - 150, s.height-90)); auto decrease3 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); decrease3->setColor(Color3B(0,200,20)); @@ -1339,12 +1339,12 @@ void PhysicsContactTest::onEnter() auto menu3 = Menu::create(decrease3, increase3, NULL); menu3->alignItemsHorizontally(); - menu3->setPosition(Vector2(s.width/2, s.height-130)); + menu3->setPosition(Vec2(s.width/2, s.height-130)); addChild(menu3, 1); label = Label::createWithTTF("yellow triangle", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2 - 150, s.height-130)); + label->setPosition(Vec2(s.width/2 - 150, s.height-130)); auto decrease4 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); decrease4->setColor(Color3B(0,200,20)); @@ -1355,12 +1355,12 @@ void PhysicsContactTest::onEnter() auto menu4 = Menu::create(decrease4, increase4, NULL); menu4->alignItemsHorizontally(); - menu4->setPosition(Vector2(s.width/2, s.height-170)); + menu4->setPosition(Vec2(s.width/2, s.height-170)); addChild(menu4, 1); label = Label::createWithTTF("blue triangle", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vector2(s.width/2 - 150, s.height-170)); + label->setPosition(Vec2(s.width/2 - 150, s.height-170)); resetTest(); } @@ -1427,22 +1427,22 @@ void PhysicsContactTest::resetTest() sprintf(buffer, "%d", _yellowBoxNum); auto label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width/2, s.height-50)); sprintf(buffer, "%d", _blueBoxNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-90)); + label->setPosition(Vec2(s.width/2, s.height-90)); sprintf(buffer, "%d", _yellowTriangleNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-130)); + label->setPosition(Vec2(s.width/2, s.height-130)); sprintf(buffer, "%d", _blueTriangleNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vector2(s.width/2, s.height-170)); + label->setPosition(Vec2(s.width/2, s.height-170)); auto wall = Node::create(); wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f))); @@ -1458,10 +1458,10 @@ void PhysicsContactTest::resetTest() { Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); Size winSize = VisibleRect::getVisibleRect().size; - Vector2 position = Vector2(winSize.width, winSize.height) - Vector2(size.width, size.height); + Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vector2(size.width/2, size.height/2); + position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); Vect velocity((CCRANDOM_0_1() - 0.5)*200, (CCRANDOM_0_1() - 0.5)*200); auto box = makeBox(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f)); box->getPhysicsBody()->setVelocity(velocity); @@ -1476,10 +1476,10 @@ void PhysicsContactTest::resetTest() { Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); Size winSize = VisibleRect::getVisibleRect().size; - Vector2 position = Vector2(winSize.width, winSize.height) - Vector2(size.width, size.height); + Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vector2(size.width/2, size.height/2); + position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); Vect velocity((CCRANDOM_0_1() - 0.5)*200, (CCRANDOM_0_1() - 0.5)*200); auto box = makeBox(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f)); box->getPhysicsBody()->setVelocity(velocity); @@ -1494,10 +1494,10 @@ void PhysicsContactTest::resetTest() { Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); Size winSize = VisibleRect::getVisibleRect().size; - Vector2 position = Vector2(winSize.width, winSize.height) - Vector2(size.width, size.height); + Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vector2(size.width/2, size.height/2); + position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); Vect velocity((CCRANDOM_0_1() - 0.5)*300, (CCRANDOM_0_1() - 0.5)*300); auto triangle = makeTriangle(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f)); triangle->getPhysicsBody()->setVelocity(velocity); @@ -1512,10 +1512,10 @@ void PhysicsContactTest::resetTest() { Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); Size winSize = VisibleRect::getVisibleRect().size; - Vector2 position = Vector2(winSize.width, winSize.height) - Vector2(size.width, size.height); + Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vector2(size.width/2, size.height/2); + position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); Vect velocity((CCRANDOM_0_1() - 0.5)*300, (CCRANDOM_0_1() - 0.5)*300); auto triangle = makeTriangle(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f)); triangle->getPhysicsBody()->setVelocity(velocity); @@ -1566,7 +1566,7 @@ void PhysicsPositionRotationTest::onEnter() // anchor test auto anchorNode = Sprite::create("Images/YellowSquare.png"); - anchorNode->setAnchorPoint(Vector2(0.1f, 0.9f)); + anchorNode->setAnchorPoint(Vec2(0.1f, 0.9f)); anchorNode->setPosition(100, 100); anchorNode->setScale(0.25); anchorNode->setPhysicsBody(PhysicsBody::createBox(anchorNode->getContentSize()*anchorNode->getScale())); @@ -1592,7 +1592,7 @@ void PhysicsPositionRotationTest::onEnter() auto offsetPosNode = Sprite::create("Images/YellowSquare.png"); offsetPosNode->setPosition(100, 200); offsetPosNode->setPhysicsBody(PhysicsBody::createBox(offsetPosNode->getContentSize()/2)); - offsetPosNode->getPhysicsBody()->setPositionOffset(-Vector2(offsetPosNode->getContentSize()/2)); + offsetPosNode->getPhysicsBody()->setPositionOffset(-Vec2(offsetPosNode->getContentSize()/2)); offsetPosNode->getPhysicsBody()->setRotationOffset(45); offsetPosNode->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(offsetPosNode); @@ -1623,17 +1623,17 @@ void PhysicsSetGravityEnableTest::onEnter() addChild(wall); // common box - auto commonBox = makeBox(Vector2(100, 100), Size(50, 50), 1); + auto commonBox = makeBox(Vec2(100, 100), Size(50, 50), 1); commonBox->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(commonBox); - auto box = makeBox(Vector2(200, 100), Size(50, 50), 2); + auto box = makeBox(Vec2(200, 100), Size(50, 50), 2); box->getPhysicsBody()->setMass(20); box->getPhysicsBody()->setTag(DRAG_BODYS_TAG); box->getPhysicsBody()->setGravityEnable(false); addChild(box); - auto ball = makeBall(Vector2(200, 200), 50); + auto ball = makeBall(Vec2(200, 200), 50); ball->setTag(2); ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); ball->getPhysicsBody()->setGravityEnable(false); diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h index 78e26297e6..9e8fc8f01b 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h @@ -49,10 +49,10 @@ public: void backCallback(Ref* sender); void toggleDebugCallback(Ref* sender); - Sprite* addGrossiniAtPosition(Vector2 p, float scale = 1.0); - Sprite* makeBall(Vector2 point, float radius, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); - Sprite* makeBox(Vector2 point, Size size, int color = 0, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); - Sprite* makeTriangle(Vector2 point, Size size, int color = 0, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); + Sprite* addGrossiniAtPosition(Vec2 p, float scale = 1.0); + Sprite* makeBall(Vec2 point, float radius, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); + Sprite* makeBox(Vec2 point, Size size, int color = 0, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); + Sprite* makeTriangle(Vec2 point, Size size, int color = 0, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); bool onTouchBegan(Touch* touch, Event* event); void onTouchMoved(Touch* touch, Event* event); @@ -177,7 +177,7 @@ public: virtual std::string subtitle() const override; bool slice(PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data); - void clipPoly(PhysicsShapePolygon* shape, Vector2 normal, float distance); + void clipPoly(PhysicsShapePolygon* shape, Vec2 normal, float distance); void onTouchEnded(Touch *touch, Event *event); diff --git a/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp b/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp index d4213b54ff..14e9b8dc6a 100644 --- a/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp +++ b/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp @@ -27,7 +27,7 @@ void ReleasePoolTestScene::runThisTest() // title auto label = Label::createWithTTF("AutoreasePool Test", "fonts/arial.ttf", 32); addChild(label, 9999); - label->setPosition(Vector2(VisibleRect::center().x, VisibleRect::top().y - 30)); + label->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 30)); // reference count should be added when added into auto release pool diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp index 8170f8921c..b86d503ba8 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -94,7 +94,7 @@ RenderTextureSave::RenderTextureSave() // create a render texture, this is what we are going to draw into _target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); _target->retain(); - _target->setPosition(Vector2(s.width / 2, s.height / 2)); + _target->setPosition(Vec2(s.width / 2, s.height / 2)); // note that the render texture is a Node, and contains a sprite of its texture for convience, // so we can just parent it to the scene like any other Node @@ -111,7 +111,7 @@ RenderTextureSave::RenderTextureSave() auto menu = Menu::create(item1, item2, NULL); this->addChild(menu); menu->alignItemsVertically(); - menu->setPosition(Vector2(VisibleRect::rightTop().x - 80, VisibleRect::rightTop().y - 30)); + menu->setPosition(Vec2(VisibleRect::rightTop().x - 80, VisibleRect::rightTop().y - 30)); } std::string RenderTextureSave::title() const @@ -148,7 +148,7 @@ void RenderTextureSave::saveImage(cocos2d::Ref *sender) auto sprite = Sprite::create(fileName); addChild(sprite); sprite->setScale(0.3f); - sprite->setPosition(Vector2(40, 40)); + sprite->setPosition(Vec2(40, 40)); sprite->setRotation(counter * 3); }; runAction(Sequence::create(action1, CallFunc::create(func), NULL)); @@ -192,7 +192,7 @@ void RenderTextureSave::onTouchesMoved(const std::vector& touches, Event float difx = end.x - start.x; float dify = end.y - start.y; float delta = (float)i / distance; - _brushs.at(i)->setPosition(Vector2(start.x + (difx * delta), start.y + (dify * delta))); + _brushs.at(i)->setPosition(Vec2(start.x + (difx * delta), start.y + (dify * delta))); _brushs.at(i)->setRotation(rand() % 360); float r = (float)(rand() % 50 / 50.f) + 0.25f; _brushs.at(i)->setScale(r); @@ -231,10 +231,10 @@ RenderTextureIssue937::RenderTextureIssue937() auto s = Director::getInstance()->getWinSize(); auto spr_premulti = Sprite::create("Images/fire.png"); - spr_premulti->setPosition(Vector2(s.width/2-16, s.height/2+16)); + spr_premulti->setPosition(Vec2(s.width/2-16, s.height/2+16)); auto spr_nonpremulti = Sprite::create("Images/fire.png"); - spr_nonpremulti->setPosition(Vector2(s.width/2-16, s.height/2-16)); + spr_nonpremulti->setPosition(Vec2(s.width/2-16, s.height/2-16)); /* A2 & B2 setup */ auto rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888); @@ -247,7 +247,7 @@ RenderTextureIssue937::RenderTextureIssue937() auto spr_size = spr_premulti->getContentSize(); rend->setKeepMatrix(true); Size pixelSize = Director::getInstance()->getWinSizeInPixels(); - rend->setVirtualViewport(Vector2(s.width/2-32, s.height/2-32),Rect(0,0,s.width,s.height),Rect(0,0,pixelSize.width,pixelSize.height)); + rend->setVirtualViewport(Vec2(s.width/2-32, s.height/2-32),Rect(0,0,s.width,s.height),Rect(0,0,pixelSize.width,pixelSize.height)); // It's possible to modify the RenderTexture blending function by // [[rend sprite] setBlendFunc:(BlendFunc) {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; @@ -256,7 +256,7 @@ RenderTextureIssue937::RenderTextureIssue937() spr_nonpremulti->visit(); rend->end(); - rend->setPosition(Vector2(s.width/2+16, s.height/2)); + rend->setPosition(Vec2(s.width/2+16, s.height/2)); addChild(spr_nonpremulti); addChild(spr_premulti); @@ -295,15 +295,15 @@ RenderTextureZbuffer::RenderTextureZbuffer() auto size = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("vertexZ = 50", "fonts/Marker Felt.ttf", 64); - label->setPosition(Vector2(size.width / 2, size.height * 0.25f)); + label->setPosition(Vec2(size.width / 2, size.height * 0.25f)); this->addChild(label); auto label2 = Label::createWithTTF("vertexZ = 0", "fonts/Marker Felt.ttf", 64); - label2->setPosition(Vector2(size.width / 2, size.height * 0.5f)); + label2->setPosition(Vec2(size.width / 2, size.height * 0.5f)); this->addChild(label2); auto label3 = Label::createWithTTF("vertexZ = -50", "fonts/Marker Felt.ttf", 64); - label3->setPosition(Vector2(size.width / 2, size.height * 0.75f)); + label3->setPosition(Vec2(size.width / 2, size.height * 0.75f)); this->addChild(label3); label->setPositionZ(50); @@ -417,7 +417,7 @@ void RenderTextureZbuffer::renderScreenShot() auto sprite = Sprite::createWithTexture(texture->getSprite()->getTexture()); - sprite->setPosition(Vector2(256, 256)); + sprite->setPosition(Vec2(256, 256)); sprite->setOpacity(182); sprite->setFlippedY(1); this->addChild(sprite, 999999); @@ -451,7 +451,7 @@ RenderTexturePartTest::RenderTexturePartTest() _rend->retain(); _rend->setKeepMatrix(true); Size pixelSize = Director::getInstance()->getWinSizeInPixels(); - _rend->setVirtualViewport(Vector2(size.width/2-150, size.height/2-150),Rect(0,0,size.width,size.height),Rect(0,0,pixelSize.width,pixelSize.height)); + _rend->setVirtualViewport(Vec2(size.width/2-150, size.height/2-150),Rect(0,0,size.width,size.height),Rect(0,0,pixelSize.width,pixelSize.height)); _rend->beginWithClear(1, 0, 0, 1); sprite1->visit(); @@ -461,7 +461,7 @@ RenderTexturePartTest::RenderTexturePartTest() _rend->end(); _spriteDraw = Sprite::createWithTexture(_rend->getSprite()->getTexture()); - FiniteTimeAction* baseAction = MoveBy::create(1, Vector2(size.width,0)); + FiniteTimeAction* baseAction = MoveBy::create(1, Vec2(size.width,0)); _spriteDraw->setPosition(0,size.height/2); _spriteDraw->setScaleY(-1); _spriteDraw->runAction(RepeatForever::create(Sequence::create @@ -492,19 +492,19 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() _spriteDS = Sprite::create("Images/fire.png"); _spriteDS->retain(); - _spriteDS->setPosition(Vector2(s.width * 0.25f, 0)); + _spriteDS->setPosition(Vec2(s.width * 0.25f, 0)); _spriteDS->setScale(10); _spriteDraw = Sprite::create("Images/fire.png"); _spriteDraw->retain(); - _spriteDraw->setPosition(Vector2(s.width * 0.25f, 0)); + _spriteDraw->setPosition(Vec2(s.width * 0.25f, 0)); _spriteDraw->setScale(10); //! move sprite half width and height, and draw only where not marked - _spriteDraw->setPosition(_spriteDraw->getPosition() + Vector2(_spriteDraw->getContentSize().width * _spriteDraw->getScale() * 0.5, _spriteDraw->getContentSize().height * _spriteDraw->getScale() * 0.5)); + _spriteDraw->setPosition(_spriteDraw->getPosition() + Vec2(_spriteDraw->getContentSize().width * _spriteDraw->getScale() * 0.5, _spriteDraw->getContentSize().height * _spriteDraw->getScale() * 0.5)); _rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); - _rend->setPosition(Vector2(s.width * 0.5f, s.height * 0.5f)); + _rend->setPosition(Vec2(s.width * 0.5f, s.height * 0.5f)); this->addChild(_rend); } @@ -515,7 +515,7 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil() CC_SAFE_RELEASE(_spriteDS); } -void RenderTextureTestDepthStencil::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void RenderTextureTestDepthStencil::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmds[0].init(_globalZOrder); _renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this); @@ -605,7 +605,7 @@ RenderTextureTargetNode::RenderTextureTargetNode() auto renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444); this->renderTexture = renderTexture; - renderTexture->setPosition(Vector2(s.width/2, s.height/2)); + renderTexture->setPosition(Vec2(s.width/2, s.height/2)); // renderTexture->setScale(2.0f); /* add the sprites to the render texture */ @@ -626,7 +626,7 @@ RenderTextureTargetNode::RenderTextureTargetNode() auto menu = Menu::create(item, NULL); addChild(menu); - menu->setPosition(Vector2(s.width/2, s.height/2)); + menu->setPosition(Vec2(s.width/2, s.height/2)); } void RenderTextureTargetNode::touched(Ref* sender) @@ -646,8 +646,8 @@ void RenderTextureTargetNode::update(float dt) { static float time = 0; float r = 80; - sprite1->setPosition(Vector2(cosf(time * 2) * r, sinf(time * 2) * r)); - sprite2->setPosition(Vector2(sinf(time * 2) * r, cosf(time * 2) * r)); + sprite1->setPosition(Vec2(cosf(time * 2) * r, sinf(time * 2) * r)); + sprite2->setPosition(Vec2(sinf(time * 2) * r, cosf(time * 2) * r)); time += dt; } @@ -685,7 +685,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea return sprite; } -void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { if (_rt == nullptr) { @@ -707,10 +707,10 @@ SpriteRenderTextureBug::SpriteRenderTextureBug() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vector2(s.width/2, s.height/2)); + addNewSpriteWithCoords(Vec2(s.width/2, s.height/2)); } -SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::addNewSpriteWithCoords(const Vector2& p) +SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::addNewSpriteWithCoords(const Vec2& p) { int idx = CCRANDOM_0_1() * 1400 / 100; int x = (idx%5) * 85; diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h index 07e5c8a7ef..dc2fd9db86 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h @@ -85,7 +85,7 @@ public: virtual ~RenderTextureTestDepthStencil(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; private: CustomCommand _renderCmds[4]; void onBeforeClear(); @@ -139,7 +139,7 @@ public: static SimpleSprite* create(const char* filename, const Rect &rect); SimpleSprite(); ~SimpleSprite(); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated); public: RenderTexture *_rt; }; @@ -152,7 +152,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - SimpleSprite* addNewSpriteWithCoords(const Vector2& p); + SimpleSprite* addNewSpriteWithCoords(const Vec2& p); }; #endif diff --git a/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp b/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp index 0a44175ea4..e031b10f92 100644 --- a/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp +++ b/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp @@ -21,7 +21,7 @@ void TestLayer::onEnter() // NSLog( s ); auto label = Label::createWithSystemFont("cocos2d", "Tahoma", 64); - label->setPosition( Vector2(x/2,y/2) ); + label->setPosition( Vec2(x/2,y/2) ); addChild(label); } @@ -49,9 +49,9 @@ void SpriteLayer::onEnter() spriteSister1->setScale(1.5f); spriteSister2->setScale(1.5f); - sprite->setPosition(Vector2(x/2,y/2)); - spriteSister1->setPosition(Vector2(40,y/2)); - spriteSister2->setPosition(Vector2(x-40,y/2)); + sprite->setPosition(Vec2(x/2,y/2)); + spriteSister1->setPosition(Vec2(40,y/2)); + spriteSister2->setPosition(Vec2(x-40,y/2)); auto rot = RotateBy::create(16, -3600); @@ -61,7 +61,7 @@ void SpriteLayer::onEnter() sprite->runAction(rot); - auto jump1 = JumpBy::create(4, Vector2(-400,0), 100, 4); + auto jump1 = JumpBy::create(4, Vec2(-400,0), 100, 4); auto jump2 = jump1->reverse(); auto rot1 = RotateBy::create(4, 360*2); @@ -96,20 +96,20 @@ void RotateWorldMainLayer::onEnter() auto white = LayerColor::create(Color4B(255,255,255,255)); blue->setScale(0.5f); - blue->setPosition(Vector2(-x/4,-y/4)); + blue->setPosition(Vec2(-x/4,-y/4)); blue->addChild( SpriteLayer::create() ); red->setScale(0.5f); - red->setPosition(Vector2(x/4,-y/4)); + red->setPosition(Vec2(x/4,-y/4)); green->setScale(0.5f); - green->setPosition(Vector2(-x/4,y/4)); + green->setPosition(Vec2(-x/4,y/4)); green->addChild(TestLayer::create()); white->setScale(0.5f); - white->setPosition(Vector2(x/4,y/4)); + white->setPosition(Vec2(x/4,y/4)); white->ignoreAnchorPointForPosition(false); - white->setPosition(Vector2(x/4*3,y/4*3)); + white->setPosition(Vec2(x/4*3,y/4*3)); addChild(blue, -1); addChild(white); diff --git a/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp b/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp index 11c458bf00..273fcf30c5 100644 --- a/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp +++ b/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp @@ -30,7 +30,7 @@ SceneTestLayer1::SceneTestLayer1() auto s = Director::getInstance()->getWinSize(); auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); - sprite->setPosition( Vector2(s.width-40, s.height/2) ); + sprite->setPosition( Vec2(s.width-40, s.height/2) ); auto rotate = RotateBy::create(2, 360); auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); @@ -115,7 +115,7 @@ SceneTestLayer2::SceneTestLayer2() auto s = Director::getInstance()->getWinSize(); auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); - sprite->setPosition( Vector2(s.width-40, s.height/2) ); + sprite->setPosition( Vec2(s.width-40, s.height/2) ); auto rotate = RotateBy::create(2, 360); auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); @@ -184,7 +184,7 @@ bool SceneTestLayer3::init() auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); - sprite->setPosition( Vector2(s.width/2, 40) ); + sprite->setPosition( Vec2(s.width/2, 40) ); auto rotate = RotateBy::create(2, 360); auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp index 2706384a6a..cf62c50397 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp @@ -295,7 +295,7 @@ void SchedulerPauseResumeAllUser::onEnter() auto s = Director::getInstance()->getWinSize(); auto sprite = Sprite::create("Images/grossinis_sister1.png"); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -413,7 +413,7 @@ void SchedulerUnscheduleAllHard::onEnter() auto s = Director::getInstance()->getWinSize(); auto sprite = Sprite::create("Images/grossinis_sister1.png"); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -485,7 +485,7 @@ void SchedulerUnscheduleAllUserLevel::onEnter() auto s = Director::getInstance()->getWinSize(); auto sprite = Sprite::create("Images/grossinis_sister1.png"); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -846,7 +846,7 @@ void SchedulerTimeScale::onEnter() auto s = Director::getInstance()->getWinSize(); // rotate and jump - auto jump1 = JumpBy::create(4, Vector2(-s.width+80,0), 100, 4); + auto jump1 = JumpBy::create(4, Vec2(-s.width+80,0), 100, 4); auto jump2 = jump1->reverse(); auto rot1 = RotateBy::create(4, 360*2); auto rot2 = rot1->reverse(); @@ -863,9 +863,9 @@ void SchedulerTimeScale::onEnter() auto tamara = Sprite::create("Images/grossinis_sister1.png"); auto kathia = Sprite::create("Images/grossinis_sister2.png"); - grossini->setPosition(Vector2(40,80)); - tamara->setPosition(Vector2(40,80)); - kathia->setPosition(Vector2(40,80)); + grossini->setPosition(Vec2(40,80)); + tamara->setPosition(Vec2(40,80)); + kathia->setPosition(Vec2(40,80)); addChild(grossini); addChild(tamara); @@ -880,7 +880,7 @@ void SchedulerTimeScale::onEnter() addChild(emitter); _sliderCtl = sliderCtl(); - _sliderCtl->setPosition(Vector2(s.width / 2.0f, s.height / 3.0f)); + _sliderCtl->setPosition(Vec2(s.width / 2.0f, s.height / 3.0f)); addChild(_sliderCtl); } @@ -942,7 +942,7 @@ void TwoSchedulers::onEnter() auto s = Director::getInstance()->getWinSize(); // rotate and jump - auto jump1 = JumpBy::create(4, Vector2(0,0), 100, 4); + auto jump1 = JumpBy::create(4, Vec2(0,0), 100, 4); auto jump2 = jump1->reverse(); auto seq = Sequence::create(jump2, jump1, NULL); @@ -953,7 +953,7 @@ void TwoSchedulers::onEnter() // auto grossini = Sprite::create("Images/grossini.png"); addChild(grossini); - grossini->setPosition(Vector2(s.width/2,100)); + grossini->setPosition(Vec2(s.width/2,100)); grossini->runAction(action->clone()); auto defaultScheduler = Director::getInstance()->getScheduler(); @@ -979,7 +979,7 @@ void TwoSchedulers::onEnter() sprite->setActionManager(actionManager1); addChild(sprite); - sprite->setPosition(Vector2(30+15*i,100)); + sprite->setPosition(Vec2(30+15*i,100)); sprite->runAction(action->clone()); } @@ -1004,7 +1004,7 @@ void TwoSchedulers::onEnter() sprite->setActionManager(actionManager2); addChild(sprite); - sprite->setPosition(Vector2(s.width-30-15*i,100)); + sprite->setPosition(Vec2(s.width-30-15*i,100)); sprite->runAction(action->clone()); } @@ -1012,12 +1012,12 @@ void TwoSchedulers::onEnter() sliderCtl1 = sliderCtl(); addChild(sliderCtl1); sliderCtl1->retain(); - sliderCtl1->setPosition(Vector2(s.width / 4.0f, VisibleRect::top().y - 20)); + sliderCtl1->setPosition(Vec2(s.width / 4.0f, VisibleRect::top().y - 20)); sliderCtl2 = sliderCtl(); addChild(sliderCtl2); sliderCtl2->retain(); - sliderCtl2->setPosition(Vector2(s.width / 4.0f*3.0f, VisibleRect::top().y-20)); + sliderCtl2->setPosition(Vec2(s.width / 4.0f*3.0f, VisibleRect::top().y-20)); } diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 27dad3df56..c27c9510ab 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -110,8 +110,8 @@ enum }; ShaderNode::ShaderNode() -:_center(Vector2(0.0f, 0.0f)) -,_resolution(Vector2(0.0f, 0.0f)) +:_center(Vec2(0.0f, 0.0f)) +,_resolution(Vec2(0.0f, 0.0f)) ,_time(0.0f) { } @@ -146,13 +146,13 @@ bool ShaderNode::initWithVertex(const std::string &vert, const std::string &frag loadShaderVertex(vert, frag); _time = 0; - _resolution = Vector2(SIZE_X, SIZE_Y); + _resolution = Vec2(SIZE_X, SIZE_Y); getGLProgramState()->setUniformVec2("resolution", _resolution); scheduleUpdate(); setContentSize(Size(SIZE_X, SIZE_Y)); - setAnchorPoint(Vector2(0.5f, 0.5f)); + setAnchorPoint(Vec2(0.5f, 0.5f)); return true; @@ -185,22 +185,22 @@ void ShaderNode::update(float dt) _time += dt; } -void ShaderNode::setPosition(const Vector2 &newPosition) +void ShaderNode::setPosition(const Vec2 &newPosition) { Node::setPosition(newPosition); auto position = getPosition(); - _center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); + _center = Vec2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); getGLProgramState()->setUniformVec2("center", _center); } -void ShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void ShaderNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this, transform, transformUpdated); renderer->addCommand(&_customCommand); } -void ShaderNode::onDraw(const Matrix &transform, bool transformUpdated) +void ShaderNode::onDraw(const Mat4 &transform, bool transformUpdated) { float w = SIZE_X, h = SIZE_Y; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; @@ -228,7 +228,7 @@ bool ShaderMonjori::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Monjori.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); addChild(sn); @@ -262,7 +262,7 @@ bool ShaderMandelbrot::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Mandelbrot.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); addChild(sn); @@ -295,7 +295,7 @@ bool ShaderJulia::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Julia.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); addChild(sn); @@ -329,7 +329,7 @@ bool ShaderHeart::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Heart.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); addChild(sn); @@ -362,7 +362,7 @@ bool ShaderFlower::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Flower.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); addChild(sn); @@ -395,7 +395,7 @@ bool ShaderPlasma::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Plasma.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); addChild(sn); @@ -430,7 +430,7 @@ public: protected: int _blurRadius; - Vector2 _pixelSize; + Vec2 _pixelSize; int _samplingRadius; //gaussian = cons * exp( (dx*dx + dy*dy) * scale); @@ -474,7 +474,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) auto s = getTexture()->getContentSizeInPixels(); - _pixelSize = Vector2(1/s.width, 1/s.height); + _pixelSize = Vec2(1/s.width, 1/s.height); _samplingRadius = 0; this->initGLProgram(); @@ -531,7 +531,7 @@ void SpriteBlur::setBlurSize(float f) } log("_blurRadius:%d",_blurRadius); - getGLProgramState()->setUniformVec4("gaussianCoefficient", Vector4(_samplingRadius, _scale, _cons, _weightSum)); + getGLProgramState()->setUniformVec4("gaussianCoefficient", Vec4(_samplingRadius, _scale, _cons, _weightSum)); } // ShaderBlur @@ -556,11 +556,11 @@ ControlSlider* ShaderBlur::createSliderCtl() auto screenSize = Director::getInstance()->getWinSize(); ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); - slider->setAnchorPoint(Vector2(0.5f, 1.0f)); + slider->setAnchorPoint(Vec2(0.5f, 1.0f)); slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(25.0f); // Sets the max value of range - slider->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 3.0f)); + slider->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 3.0f)); // When the value of the slider will change, the given selector will be call slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), Control::EventType::VALUE_CHANGED); @@ -579,8 +579,8 @@ bool ShaderBlur::init() auto sprite = Sprite::create("Images/grossini.png"); auto s = Director::getInstance()->getWinSize(); - _blurSprite->setPosition(Vector2(s.width/3, s.height/2)); - sprite->setPosition(Vector2(2*s.width/3, s.height/2)); + _blurSprite->setPosition(Vec2(s.width/3, s.height/2)); + sprite->setPosition(Vec2(2*s.width/3, s.height/2)); addChild(_blurSprite); addChild(sprite); @@ -620,10 +620,10 @@ bool ShaderRetroEffect::init() auto s = director->getWinSize(); _label = Label::createWithBMFont("fonts/west_england-64.fnt","RETRO EFFECT"); - _label->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + _label->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _label->setGLProgram(p); - _label->setPosition(Vector2(s.width/2,s.height/2)); + _label->setPosition(Vec2(s.width/2,s.height/2)); addChild(_label); @@ -642,7 +642,7 @@ void ShaderRetroEffect::update(float dt) { auto sprite = _label->getLetter(i); auto oldPosition = sprite->getPosition(); - sprite->setPosition(Vector2( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 )); + sprite->setPosition(Vec2( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 )); // add fabs() to prevent negative scaling float scaleY = ( sinf( _accum * 2 + i/2.0 + 0.707) ); @@ -684,7 +684,7 @@ bool ShaderLensFlare::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/shadertoy_LensFlare.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); sn->setContentSize(Size(s.width/2,s.height/2)); addChild(sn); @@ -719,7 +719,7 @@ bool ShaderGlow::init() auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/shadertoy_Glow.fsh"); auto s = Director::getInstance()->getWinSize(); - sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setPosition(Vec2(s.width/2, s.height/2)); sn->setContentSize(Size(s.width/2,s.height/2)); addChild(sn); @@ -758,7 +758,7 @@ bool ShaderMultiTexture::init() addChild(sprite); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); auto glprogram = GLProgram::createWithFilenames("Shaders/example_MultiTexture.vsh", "Shaders/example_MultiTexture.fsh"); auto glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 3a58be9ed8..1c55fd4b3b 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -116,8 +116,8 @@ public: static ShaderNode* shaderNodeWithVertex(const std::string &vert, const std::string &frag); virtual void update(float dt); - virtual void setPosition(const Vector2 &newPosition); - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void setPosition(const Vec2 &newPosition); + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: ShaderNode(); @@ -126,10 +126,10 @@ protected: bool initWithVertex(const std::string &vert, const std::string &frag); void loadShaderVertex(const std::string &vert, const std::string &frag); - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); - Vector2 _center; - Vector2 _resolution; + Vec2 _center; + Vec2 _resolution; float _time; std::string _vertFileName; std::string _fragFileName; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 73d4bce1d9..0ce1c8b22b 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -170,7 +170,7 @@ protected: bool init(float blurSize); int _blurRadius; - Vector2 _pixelSize; + Vec2 _pixelSize; int _samplingRadius; float _scale; @@ -196,13 +196,13 @@ bool EffectBlur::init(float blurSize) auto s = Size(100,100); _blurRadius = 0; - _pixelSize = Vector2(1/s.width, 1/s.height); + _pixelSize = Vec2(1/s.width, 1/s.height); _samplingRadius = 0; setBlurSize(blurSize); _glprogramstate->setUniformVec2("onePixelSize", _pixelSize); - _glprogramstate->setUniformVec4("gaussianCoefficient", Vector4(_samplingRadius, _scale, _cons, _weightSum)); + _glprogramstate->setUniformVec4("gaussianCoefficient", Vec4(_samplingRadius, _scale, _cons, _weightSum)); return true; } @@ -380,7 +380,7 @@ protected: virtual void setCustomUniforms() override; int _blurRadius; - Vector2 _pixelSize; + Vec2 _pixelSize; int _samplingRadius; float _scale; @@ -397,14 +397,14 @@ void BlurSprite::setCustomUniforms() { auto s = getTexture()->getContentSizeInPixels(); _blurRadius = 0; - _pixelSize = Vector2(1/s.width, 1/s.height); + _pixelSize = Vec2(1/s.width, 1/s.height); _samplingRadius = 0; setBlurSize(3.0f); auto programState = getGLProgramState(); programState->setUniformVec2("onePixelSize", _pixelSize); - programState->setUniformVec4("gaussianCoefficient", Vector4(_samplingRadius, _scale, _cons, _weightSum)); + programState->setUniformVec4("gaussianCoefficient", Vec4(_samplingRadius, _scale, _cons, _weightSum)); } void BlurSprite::setBlurSize(float f) @@ -463,7 +463,7 @@ void NoiseSprite::setCustomUniforms() { _resolution[0] = getTexture()->getContentSizeInPixels().width; _resolution[1] = getTexture()->getContentSizeInPixels().height; - getGLProgramState()->setUniformVec2("resolution", Vector2(_resolution[0],_resolution[1])); + getGLProgramState()->setUniformVec2("resolution", Vec2(_resolution[0],_resolution[1])); } class EdgeDetectionSprite : public ShaderSprite, public ShaderSpriteCreator @@ -490,7 +490,7 @@ void EdgeDetectionSprite::setCustomUniforms() _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - programState->setUniformVec2("resolution", Vector2(_resolution[0], _resolution[1])); + programState->setUniformVec2("resolution", Vec2(_resolution[0], _resolution[1])); } class BloomSprite : public ShaderSprite, public ShaderSpriteCreator @@ -538,7 +538,7 @@ void CelShadingSprite::setCustomUniforms() _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - programState->setUniformVec2("resolution", Vector2(_resolution[0], _resolution[1])); + programState->setUniformVec2("resolution", Vec2(_resolution[0], _resolution[1])); } class LensFlareSprite : public ShaderSprite, public ShaderSpriteCreator @@ -568,8 +568,8 @@ void LensFlareSprite::setCustomUniforms() _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - programState->setUniformVec2("resolution", Vector2(_resolution[0], _resolution[1])); - programState->setUniformVec2("textureResolution", Vector2(_textureResolution[0], _textureResolution[1])); + programState->setUniformVec2("resolution", Vec2(_resolution[0], _resolution[1])); + programState->setUniformVec2("textureResolution", Vec2(_textureResolution[0], _textureResolution[1])); } NormalSpriteTest::NormalSpriteTest() @@ -578,7 +578,7 @@ NormalSpriteTest::NormalSpriteTest() { auto s = Director::getInstance()->getWinSize(); NormalSprite* sprite = NormalSprite::createSprite("Images/powered.png"); - sprite->setPosition(Vector2(s.width/2, s.height/2)); + sprite->setPosition(Vec2(s.width/2, s.height/2)); addChild(sprite); } @@ -590,9 +590,9 @@ GreyScaleSpriteTest::GreyScaleSpriteTest() { auto s = Director::getInstance()->getWinSize(); GreyScaleSprite* sprite = GreyScaleSprite::createSprite("Images/powered.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/powered.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -605,9 +605,9 @@ BlurSpriteTest::BlurSpriteTest() { auto s = Director::getInstance()->getWinSize(); BlurSprite* sprite = BlurSprite::createSprite("Images/powered.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/powered.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -620,9 +620,9 @@ NoiseSpriteTest::NoiseSpriteTest() { auto s = Director::getInstance()->getWinSize(); NoiseSprite* sprite = NoiseSprite::createSprite("Images/powered.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/powered.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -634,9 +634,9 @@ EdgeDetectionSpriteTest::EdgeDetectionSpriteTest() { auto s = Director::getInstance()->getWinSize(); EdgeDetectionSprite* sprite = EdgeDetectionSprite::createSprite("Images/powered.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/powered.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -648,9 +648,9 @@ BloomSpriteTest::BloomSpriteTest() { auto s = Director::getInstance()->getWinSize(); BloomSprite* sprite = BloomSprite::createSprite("Images/stone.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/stone.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -662,9 +662,9 @@ CelShadingSpriteTest::CelShadingSpriteTest() { auto s = Director::getInstance()->getWinSize(); CelShadingSprite* sprite = CelShadingSprite::createSprite("Images/stone.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/stone.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -678,7 +678,7 @@ LensFlareSpriteTest::LensFlareSpriteTest() LensFlareSprite* sprite = LensFlareSprite::createSprite("Images/noise.png"); Rect rect = Rect::ZERO; rect.size = Size(480,320); - sprite->setPosition(Vector2(s.width * 0.5, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.5, s.height/2)); addChild(sprite); } } @@ -704,7 +704,7 @@ OutlineSprite::OutlineSprite() void OutlineSprite::setCustomUniforms() { - Vector3 color(1.0, 0.2, 0.3); + Vec3 color(1.0, 0.2, 0.3); GLfloat radius = 0.01; GLfloat threshold = 1.75; @@ -721,9 +721,9 @@ OutlineShadingSpriteTest::OutlineShadingSpriteTest() if (ShaderTestDemo2::init()) { auto s = Director::getInstance()->getWinSize(); OutlineSprite* sprite = OutlineSprite::createSprite("Images/grossini_dance_10.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Vec2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/grossini_dance_10.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vec2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -735,10 +735,10 @@ EffectSprite_Blur::EffectSprite_Blur() if (ShaderTestDemo2::init()) { auto s = Director::getInstance()->getWinSize(); EffectSprite* sprite = EffectSprite::create("Images/grossini.png"); - sprite->setPosition(Vector2(0, s.height/2)); + sprite->setPosition(Vec2(0, s.height/2)); addChild(sprite); - auto jump = JumpBy::create(4, Vector2(s.width,0), 100, 4); + auto jump = JumpBy::create(4, Vec2(s.width,0), 100, 4); auto rot = RotateBy::create(4, 720); auto spawn = Spawn::create(jump, rot, NULL); auto rev = spawn->reverse(); diff --git a/tests/cpp-tests/Classes/SpineTest/SpineTest.cpp b/tests/cpp-tests/Classes/SpineTest/SpineTest.cpp index 5e2a0940be..4b57f848f4 100644 --- a/tests/cpp-tests/Classes/SpineTest/SpineTest.cpp +++ b/tests/cpp-tests/Classes/SpineTest/SpineTest.cpp @@ -70,7 +70,7 @@ bool SpineTestLayer::init () { NULL))); Size windowSize = Director::getInstance()->getWinSize(); - skeletonNode->setPosition(Vector2(windowSize.width / 2, 20)); + skeletonNode->setPosition(Vec2(windowSize.width / 2, 20)); addChild(skeletonNode); scheduleUpdate(); diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index cee3b33ac0..adb3919372 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -230,10 +230,10 @@ Sprite1::Sprite1() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords( Vector2(s.width/2, s.height/2) ); + addNewSpriteWithCoords( Vec2(s.width/2, s.height/2) ); } -void Sprite1::addNewSpriteWithCoords(Vector2 p) +void Sprite1::addNewSpriteWithCoords(Vec2 p) { int idx = (int)(CCRANDOM_0_1() * 1400.0f / 100.0f); int x = (idx%5) * 85; @@ -243,7 +243,7 @@ void Sprite1::addNewSpriteWithCoords(Vector2 p) auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(x,y,85,121) ); addChild( sprite ); - sprite->setPosition( Vector2( p.x, p.y) ); + sprite->setPosition( Vec2( p.x, p.y) ); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -300,10 +300,10 @@ SpriteBatchNode1::SpriteBatchNode1() addChild(BatchNode, 0, kTagSpriteBatchNode); auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords( Vector2(s.width/2, s.height/2) ); + addNewSpriteWithCoords( Vec2(s.width/2, s.height/2) ); } -void SpriteBatchNode1::addNewSpriteWithCoords(Vector2 p) +void SpriteBatchNode1::addNewSpriteWithCoords(Vec2 p) { auto BatchNode = static_cast( getChildByTag(kTagSpriteBatchNode) ); @@ -315,7 +315,7 @@ void SpriteBatchNode1::addNewSpriteWithCoords(Vector2 p) auto sprite = Sprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121)); BatchNode->addChild(sprite); - sprite->setPosition( Vector2( p.x, p.y) ); + sprite->setPosition( Vec2( p.x, p.y) ); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -378,14 +378,14 @@ SpriteColorOpacity::SpriteColorOpacity() auto sprite8 = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*3, 121*1, 85, 121)); auto s = Director::getInstance()->getWinSize(); - sprite1->setPosition( Vector2( (s.width/5)*1, (s.height/3)*1) ); - sprite2->setPosition( Vector2( (s.width/5)*2, (s.height/3)*1) ); - sprite3->setPosition( Vector2( (s.width/5)*3, (s.height/3)*1) ); - sprite4->setPosition( Vector2( (s.width/5)*4, (s.height/3)*1) ); - sprite5->setPosition( Vector2( (s.width/5)*1, (s.height/3)*2) ); - sprite6->setPosition( Vector2( (s.width/5)*2, (s.height/3)*2) ); - sprite7->setPosition( Vector2( (s.width/5)*3, (s.height/3)*2) ); - sprite8->setPosition( Vector2( (s.width/5)*4, (s.height/3)*2) ); + sprite1->setPosition( Vec2( (s.width/5)*1, (s.height/3)*1) ); + sprite2->setPosition( Vec2( (s.width/5)*2, (s.height/3)*1) ); + sprite3->setPosition( Vec2( (s.width/5)*3, (s.height/3)*1) ); + sprite4->setPosition( Vec2( (s.width/5)*4, (s.height/3)*1) ); + sprite5->setPosition( Vec2( (s.width/5)*1, (s.height/3)*2) ); + sprite6->setPosition( Vec2( (s.width/5)*2, (s.height/3)*2) ); + sprite7->setPosition( Vec2( (s.width/5)*3, (s.height/3)*2) ); + sprite8->setPosition( Vec2( (s.width/5)*4, (s.height/3)*2) ); auto action = FadeIn::create(2); auto action_back = action->reverse(); @@ -469,14 +469,14 @@ SpriteBatchNodeColorOpacity::SpriteBatchNodeColorOpacity() auto s = Director::getInstance()->getWinSize(); - sprite1->setPosition( Vector2( (s.width/5)*1, (s.height/3)*1) ); - sprite2->setPosition( Vector2( (s.width/5)*2, (s.height/3)*1) ); - sprite3->setPosition( Vector2( (s.width/5)*3, (s.height/3)*1) ); - sprite4->setPosition( Vector2( (s.width/5)*4, (s.height/3)*1) ); - sprite5->setPosition( Vector2( (s.width/5)*1, (s.height/3)*2) ); - sprite6->setPosition( Vector2( (s.width/5)*2, (s.height/3)*2) ); - sprite7->setPosition( Vector2( (s.width/5)*3, (s.height/3)*2) ); - sprite8->setPosition( Vector2( (s.width/5)*4, (s.height/3)*2) ); + sprite1->setPosition( Vec2( (s.width/5)*1, (s.height/3)*1) ); + sprite2->setPosition( Vec2( (s.width/5)*2, (s.height/3)*1) ); + sprite3->setPosition( Vec2( (s.width/5)*3, (s.height/3)*1) ); + sprite4->setPosition( Vec2( (s.width/5)*4, (s.height/3)*1) ); + sprite5->setPosition( Vec2( (s.width/5)*1, (s.height/3)*2) ); + sprite6->setPosition( Vec2( (s.width/5)*2, (s.height/3)*2) ); + sprite7->setPosition( Vec2( (s.width/5)*3, (s.height/3)*2) ); + sprite8->setPosition( Vec2( (s.width/5)*4, (s.height/3)*2) ); auto action = FadeIn::create(2); auto action_back = action->reverse(); @@ -556,20 +556,20 @@ SpriteZOrder::SpriteZOrder() for(int i=0;i<5;i++) { auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*0, 121*1, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); addChild(sprite, i); } for(int i=5;i<10;i++) { auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*0, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); addChild(sprite, 14-i); } auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*3, 121*0, 85, 121)); addChild(sprite, -1, kTagSprite1); - sprite->setPosition( Vector2(s.width/2, s.height/2 - 20) ); + sprite->setPosition( Vec2(s.width/2, s.height/2 - 20) ); sprite->setScaleX( 6 ); sprite->setColor(Color3B::RED); @@ -624,20 +624,20 @@ SpriteBatchNodeZOrder::SpriteBatchNodeZOrder() for(int i=0;i<5;i++) { auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*0, 121*1, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); batch->addChild(sprite, i); } for(int i=5;i<10;i++) { auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*0, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); batch->addChild(sprite, 14-i); } auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*3, 121*0, 85, 121)); batch->addChild(sprite, -1, kTagSprite1); - sprite->setPosition( Vector2(s.width/2, s.height/2 - 20) ); + sprite->setPosition( Vec2(s.width/2, s.height/2 - 20) ); sprite->setScaleX( 6 ); sprite->setColor(Color3B::RED); @@ -748,7 +748,7 @@ SpriteBatchNodeReorderIssue744::SpriteBatchNodeReorderIssue744() addChild(batch, 0, kTagSpriteBatchNode); auto sprite = Sprite::createWithTexture(batch->getTexture(),Rect(0, 0, 85, 121)); - sprite->setPosition( Vector2(s.width/2, s.height/2) ); + sprite->setPosition( Vec2(s.width/2, s.height/2) ); batch->addChild(sprite, 3); batch->reorderChild(sprite, 1); } @@ -799,13 +799,13 @@ SpriteBatchNodeReorderIssue766::SpriteBatchNodeReorderIssue766() addChild(batchNode, 1, 0); sprite1 = makeSpriteZ(2); - sprite1->setPosition(Vector2(200,160)); + sprite1->setPosition(Vec2(200,160)); sprite2 = makeSpriteZ(3); - sprite2->setPosition(Vector2(264,160)); + sprite2->setPosition(Vec2(264,160)); sprite3 = makeSpriteZ(4); - sprite3->setPosition(Vector2(328,160)); + sprite3->setPosition(Vec2(328,160)); schedule(schedule_selector(SpriteBatchNodeReorderIssue766::reorderSprite), 2); } @@ -841,20 +841,20 @@ SpriteBatchNodeReorderIssue767::SpriteBatchNodeReorderIssue767() // parent l1 = Sprite::createWithSpriteFrameName("father.gif"); - l1->setPosition(Vector2( s.width/2, s.height/2)); + l1->setPosition(Vec2( s.width/2, s.height/2)); aParent->addChild(l1, 0, kTagSprite2); auto l1Size = l1->getContentSize(); // child left l2a = Sprite::createWithSpriteFrameName("sister1.gif"); - l2a->setPosition(Vector2( -25 + l1Size.width/2, 0 + l1Size.height/2)); + l2a->setPosition(Vec2( -25 + l1Size.width/2, 0 + l1Size.height/2)); l1->addChild(l2a, -1, kTagSpriteLeft); auto l2aSize = l2a->getContentSize(); // child right l2b = Sprite::createWithSpriteFrameName("sister2.gif"); - l2b->setPosition(Vector2( +25 + l1Size.width/2, 0 + l1Size.height/2)); + l2b->setPosition(Vec2( +25 + l1Size.width/2, 0 + l1Size.height/2)); l1->addChild(l2b, 1, kTagSpriteRight); auto l2bSize = l2a->getContentSize(); @@ -862,25 +862,25 @@ SpriteBatchNodeReorderIssue767::SpriteBatchNodeReorderIssue767() // child left bottom l3a1 = Sprite::createWithSpriteFrameName("child1.gif"); l3a1->setScale(0.65f); - l3a1->setPosition(Vector2(0+l2aSize.width/2,-50+l2aSize.height/2)); + l3a1->setPosition(Vec2(0+l2aSize.width/2,-50+l2aSize.height/2)); l2a->addChild(l3a1, -1); // child left top l3a2 = Sprite::createWithSpriteFrameName("child1.gif"); l3a2->setScale(0.65f); - l3a2->setPosition(Vector2(0+l2aSize.width/2,+50+l2aSize.height/2)); + l3a2->setPosition(Vec2(0+l2aSize.width/2,+50+l2aSize.height/2)); l2a->addChild(l3a2, 1); // child right bottom l3b1 = Sprite::createWithSpriteFrameName("child1.gif"); l3b1->setScale(0.65f); - l3b1->setPosition(Vector2(0+l2bSize.width/2,-50+l2bSize.height/2)); + l3b1->setPosition(Vec2(0+l2bSize.width/2,-50+l2bSize.height/2)); l2b->addChild(l3b1, -1); // child right top l3b2 = Sprite::createWithSpriteFrameName("child1.gif"); l3b2->setScale(0.65f); - l3b2->setPosition(Vector2(0+l2bSize.width/2,+50+l2bSize.height/2)); + l3b2->setPosition(Vec2(0+l2bSize.width/2,+50+l2bSize.height/2)); l2b->addChild(l3b2, 1); schedule(schedule_selector(SpriteBatchNodeReorderIssue767::reorderSprites), 1); @@ -965,15 +965,15 @@ SpriteZVertex::SpriteZVertex() auto node = Node::create(); // camera uses the center of the image as the pivoting point node->setContentSize( Size(s.width,s.height) ); - node->setAnchorPoint( Vector2::ANCHOR_MIDDLE); - node->setPosition( Vector2(s.width/2, s.height/2)); + node->setAnchorPoint( Vec2::ANCHOR_MIDDLE); + node->setPosition( Vec2(s.width/2, s.height/2)); addChild(node, 0); for(int i=0;i<5;i++) { auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*0, 121*1, 85, 121)); - sprite->setPosition( Vector2((i+1)*step, s.height/2) ); + sprite->setPosition( Vec2((i+1)*step, s.height/2) ); sprite->setPositionZ( 10 + i*40 ); sprite->setGLProgram(alphaTestShader); node->addChild(sprite, 0); @@ -983,7 +983,7 @@ SpriteZVertex::SpriteZVertex() for(int i=5;i<11;i++) { auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*0, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); sprite->setPositionZ( 10 + (10-i)*40 ); sprite->setGLProgram(alphaTestShader); node->addChild(sprite, 0); @@ -1053,8 +1053,8 @@ SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() auto batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 1); // camera uses the center of the image as the pivoting point batch->setContentSize( Size(s.width,s.height)); - batch->setAnchorPoint( Vector2::ANCHOR_MIDDLE); - batch->setPosition( Vector2(s.width/2, s.height/2)); + batch->setAnchorPoint( Vec2::ANCHOR_MIDDLE); + batch->setPosition( Vec2(s.width/2, s.height/2)); batch->setGLProgram(alphaTestShader); addChild(batch, 0, kTagSpriteBatchNode); @@ -1062,7 +1062,7 @@ SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() for(int i=0;i<5;i++) { auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*0, 121*1, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); sprite->setPositionZ( 10 + i*40 ); batch->addChild(sprite, 0); @@ -1070,7 +1070,7 @@ SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() for(int i=5;i<11;i++) { auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*0, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); sprite->setPositionZ( 10 + (10-i)*40 ); batch->addChild(sprite, 0); } @@ -1105,7 +1105,7 @@ SpriteAnchorPoint::SpriteAnchorPoint() for(int i=0;i<3;i++) { auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*i, 121*1, 85, 121) ); - sprite->setPosition( Vector2( s.width/4*(i+1), s.height/2) ); + sprite->setPosition( Vec2( s.width/4*(i+1), s.height/2) ); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); @@ -1115,13 +1115,13 @@ SpriteAnchorPoint::SpriteAnchorPoint() switch(i) { case 0: - sprite->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); break; case 1: - sprite->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); break; case 2: - sprite->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -1162,7 +1162,7 @@ SpriteBatchNodeAnchorPoint::SpriteBatchNodeAnchorPoint() for(int i=0;i<3;i++) { auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*i, 121*1, 85, 121)); - sprite->setPosition( Vector2( s.width/4*(i+1), s.height/2) ); + sprite->setPosition( Vec2( s.width/4*(i+1), s.height/2) ); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); @@ -1172,13 +1172,13 @@ SpriteBatchNodeAnchorPoint::SpriteBatchNodeAnchorPoint() switch(i) { case 0: - sprite->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); break; case 1: - sprite->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); break; case 2: - sprite->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -1216,7 +1216,7 @@ Sprite6::Sprite6() auto s = Director::getInstance()->getWinSize(); - batch->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + batch->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); batch->setContentSize( Size(s.width, s.height) ); @@ -1239,7 +1239,7 @@ Sprite6::Sprite6() for(int i=0;i<3;i++) { auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*i, 121*1, 85, 121)); - sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); + sprite->setPosition( Vec2( (i+1)*step, s.height/2) ); sprite->runAction( action->clone()); batch->addChild(sprite, i); @@ -1264,11 +1264,11 @@ SpriteFlip::SpriteFlip() auto s = Director::getInstance()->getWinSize(); auto sprite1 = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*1, 85, 121)); - sprite1->setPosition( Vector2( s.width/2 - 100, s.height/2 ) ); + sprite1->setPosition( Vec2( s.width/2 - 100, s.height/2 ) ); addChild(sprite1, 0, kTagSprite1); auto sprite2 = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*1, 85, 121)); - sprite2->setPosition( Vector2( s.width/2 + 100, s.height/2 ) ); + sprite2->setPosition( Vec2( s.width/2 + 100, s.height/2 ) ); addChild(sprite2, 0, kTagSprite2); schedule( schedule_selector(SpriteFlip::flipSprites), 1); @@ -1312,11 +1312,11 @@ SpriteBatchNodeFlip::SpriteBatchNodeFlip() auto s = Director::getInstance()->getWinSize(); auto sprite1 = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*1, 85, 121)); - sprite1->setPosition( Vector2( s.width/2 - 100, s.height/2 ) ); + sprite1->setPosition( Vec2( s.width/2 - 100, s.height/2 ) ); batch->addChild(sprite1, 0, kTagSprite1); auto sprite2 = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*1, 85, 121)); - sprite2->setPosition( Vector2( s.width/2 + 100, s.height/2 ) ); + sprite2->setPosition( Vec2( s.width/2 + 100, s.height/2 ) ); batch->addChild(sprite2, 0, kTagSprite2); schedule( schedule_selector(SpriteBatchNodeFlip::flipSprites), 1); @@ -1359,11 +1359,11 @@ SpriteAliased::SpriteAliased() auto s = Director::getInstance()->getWinSize(); auto sprite1 = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*1, 85, 121)); - sprite1->setPosition( Vector2( s.width/2 - 100, s.height/2 ) ); + sprite1->setPosition( Vec2( s.width/2 - 100, s.height/2 ) ); addChild(sprite1, 0, kTagSprite1); auto sprite2 = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*1, 85, 121)); - sprite2->setPosition( Vector2( s.width/2 + 100, s.height/2 ) ); + sprite2->setPosition( Vec2( s.width/2 + 100, s.height/2 ) ); addChild(sprite2, 0, kTagSprite2); auto scale = ScaleBy::create(2, 5); @@ -1424,11 +1424,11 @@ SpriteBatchNodeAliased::SpriteBatchNodeAliased() auto s = Director::getInstance()->getWinSize(); auto sprite1 = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*1, 85, 121)); - sprite1->setPosition( Vector2( s.width/2 - 100, s.height/2 ) ); + sprite1->setPosition( Vec2( s.width/2 - 100, s.height/2 ) ); batch->addChild(sprite1, 0, kTagSprite1); auto sprite2 = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*1, 85, 121)); - sprite2->setPosition( Vector2( s.width/2 + 100, s.height/2 ) ); + sprite2->setPosition( Vec2( s.width/2 + 100, s.height/2 ) ); batch->addChild(sprite2, 0, kTagSprite2); auto scale = ScaleBy::create(2, 5); @@ -1504,7 +1504,7 @@ void SpriteNewTexture::addNewSprite() { auto s = Director::getInstance()->getWinSize(); - auto p = Vector2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); + auto p = Vec2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); int idx = CCRANDOM_0_1() * 1400 / 100; int x = (idx%5) * 85; @@ -1515,7 +1515,7 @@ void SpriteNewTexture::addNewSprite() auto sprite = Sprite::createWithTexture(_texture1, Rect(x,y,85,121)); node->addChild(sprite); - sprite->setPosition( Vector2( p.x, p.y) ); + sprite->setPosition( Vec2( p.x, p.y) ); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -1609,7 +1609,7 @@ void SpriteBatchNodeNewTexture::addNewSprite() { auto s = Director::getInstance()->getWinSize(); - auto p = Vector2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); + auto p = Vec2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); auto batch = static_cast( getChildByTag( kTagSpriteBatchNode ) ); @@ -1621,7 +1621,7 @@ void SpriteBatchNodeNewTexture::addNewSprite() auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(x,y,85,121)); batch->addChild(sprite); - sprite->setPosition( Vector2( p.x, p.y) ); + sprite->setPosition( Vec2( p.x, p.y) ); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -1686,7 +1686,7 @@ void SpriteFrameTest::onEnter() // Animation using Sprite BatchNode // _sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - _sprite1->setPosition( Vector2( s.width/2-80, s.height/2) ); + _sprite1->setPosition( Vec2( s.width/2-80, s.height/2) ); auto spritebatch = SpriteBatchNode::create("animations/grossini.png"); spritebatch->addChild(_sprite1); @@ -1713,7 +1713,7 @@ void SpriteFrameTest::onEnter() // Animation using standard Sprite // _sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - _sprite2->setPosition( Vector2( s.width/2 + 80, s.height/2) ); + _sprite2->setPosition( Vec2( s.width/2 + 80, s.height/2) ); addChild(_sprite2); @@ -1842,7 +1842,7 @@ void SpriteFrameAliasNameTest::onEnter() // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width * 0.5f, s.height * 0.5f)); + sprite->setPosition(Vec2(s.width * 0.5f, s.height * 0.5f)); auto spriteBatch = SpriteBatchNode::create("animations/grossini-aliases.png"); spriteBatch->addChild(sprite); @@ -1897,7 +1897,7 @@ SpriteOffsetAnchorRotation::SpriteOffsetAnchorRotation() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2( s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2( s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); @@ -1907,13 +1907,13 @@ SpriteOffsetAnchorRotation::SpriteOffsetAnchorRotation() switch(i) { case 0: - sprite->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); break; case 1: - sprite->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); break; case 2: - sprite->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -1979,7 +1979,7 @@ SpriteBatchNodeOffsetAnchorRotation::SpriteBatchNodeOffsetAnchorRotation() // Animation using Sprite BatchNode // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition( Vector2( s.width/4*(i+1), s.height/2)); + sprite->setPosition( Vec2( s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); @@ -1989,13 +1989,13 @@ SpriteBatchNodeOffsetAnchorRotation::SpriteBatchNodeOffsetAnchorRotation() switch(i) { case 0: - sprite->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); break; case 1: - sprite->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); break; case 2: - sprite->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -2058,7 +2058,7 @@ SpriteOffsetAnchorScale::SpriteOffsetAnchorScale() // Animation using Sprite BatchNode // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition( Vector2( s.width/4*(i+1), s.height/2) ); + sprite->setPosition( Vec2( s.width/4*(i+1), s.height/2) ); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); @@ -2068,13 +2068,13 @@ SpriteOffsetAnchorScale::SpriteOffsetAnchorScale() switch(i) { case 0: - sprite->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); break; case 1: - sprite->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); break; case 2: - sprite->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -2141,7 +2141,7 @@ SpriteBatchNodeOffsetAnchorScale::SpriteBatchNodeOffsetAnchorScale() // Animation using Sprite BatchNode // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition( Vector2( s.width/4*(i+1), s.height/2) ); + sprite->setPosition( Vec2( s.width/4*(i+1), s.height/2) ); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); @@ -2150,13 +2150,13 @@ SpriteBatchNodeOffsetAnchorScale::SpriteBatchNodeOffsetAnchorScale() switch(i) { case 0: - sprite->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); break; case 1: - sprite->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); break; case 2: - sprite->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -2227,7 +2227,7 @@ SpriteAnimationSplit::SpriteAnimationSplit() // Animation using Sprite BatchNode // auto sprite = Sprite::createWithSpriteFrame(frame0); - sprite->setPosition( Vector2( s.width/2-80, s.height/2) ); + sprite->setPosition( Vec2( s.width/2-80, s.height/2) ); addChild(sprite); Vector animFrames(6); @@ -2301,7 +2301,7 @@ SpriteHybrid::SpriteHybrid() x = CCRANDOM_0_1() * s.width; y = CCRANDOM_0_1() * s.height; } - sprite->setPosition( Vector2(x,y) ); + sprite->setPosition( Vec2(x,y) ); auto action = RotateBy::create(4, 360); sprite->runAction( RepeatForever::create(action) ); @@ -2369,13 +2369,13 @@ SpriteBatchNodeChildren::SpriteBatchNodeChildren() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini.plist"); auto sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2( s.width/3, s.height/2)); + sprite1->setPosition(Vec2( s.width/3, s.height/2)); auto sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(50,50)); + sprite2->setPosition(Vec2(50,50)); auto sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-50,-50)); + sprite3->setPosition(Vec2(-50,-50)); batch->addChild(sprite1); sprite1->addChild(sprite2); @@ -2395,7 +2395,7 @@ SpriteBatchNodeChildren::SpriteBatchNodeChildren() sprite1->runAction(RepeatForever::create( Animate::create(animation) ) ); // END NEW CODE - auto action = MoveBy::create(2, Vector2(200,0)); + auto action = MoveBy::create(2, Vec2(200,0)); auto action_back = action->reverse(); auto action_rot = RotateBy::create(2, 360); auto action_s = ScaleBy::create(2, 2); @@ -2442,13 +2442,13 @@ SpriteBatchNodeChildrenZ::SpriteBatchNodeChildrenZ() addChild(batch, 0, kTagSpriteBatchNode); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2( s.width/3, s.height/2)); + sprite1->setPosition(Vec2( s.width/3, s.height/2)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); batch->addChild(sprite1); sprite1->addChild(sprite2, 2); @@ -2459,13 +2459,13 @@ SpriteBatchNodeChildrenZ::SpriteBatchNodeChildrenZ() addChild(batch, 0, kTagSpriteBatchNode); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2( 2*s.width/3, s.height/2)); + sprite1->setPosition(Vec2( 2*s.width/3, s.height/2)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); batch->addChild(sprite1); sprite1->addChild(sprite2, -2); @@ -2476,13 +2476,13 @@ SpriteBatchNodeChildrenZ::SpriteBatchNodeChildrenZ() addChild(batch, 0, kTagSpriteBatchNode); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2( s.width/2 - 90, s.height/4)); + sprite1->setPosition(Vec2( s.width/2 - 90, s.height/4)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2( s.width/2 - 60,s.height/4)); + sprite2->setPosition(Vec2( s.width/2 - 60,s.height/4)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2( s.width/2 - 30, s.height/4)); + sprite3->setPosition(Vec2( s.width/2 - 30, s.height/4)); batch->addChild(sprite1, 10); batch->addChild(sprite2, -10); @@ -2493,13 +2493,13 @@ SpriteBatchNodeChildrenZ::SpriteBatchNodeChildrenZ() addChild(batch, 0, kTagSpriteBatchNode); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2( s.width/2 +30, s.height/4)); + sprite1->setPosition(Vec2( s.width/2 +30, s.height/4)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2( s.width/2 +60,s.height/4)); + sprite2->setPosition(Vec2( s.width/2 +60,s.height/4)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2( s.width/2 +90, s.height/4)); + sprite3->setPosition(Vec2( s.width/2 +90, s.height/4)); batch->addChild(sprite1, -10); batch->addChild(sprite2, -5); @@ -2536,19 +2536,19 @@ SpriteChildrenVisibility::SpriteChildrenVisibility() // // parents aParent = SpriteBatchNode::create("animations/grossini.png", 50); - aParent->setPosition( Vector2(s.width/3, s.height/2) ); + aParent->setPosition( Vec2(s.width/3, s.height/2) ); addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2(0,0)); + sprite1->setPosition(Vec2(0,0)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); aParent->addChild(sprite1); sprite1->addChild(sprite2, -2); @@ -2560,17 +2560,17 @@ SpriteChildrenVisibility::SpriteChildrenVisibility() // Sprite // aParent = Node::create(); - aParent->setPosition( Vector2(2*s.width/3, s.height/2) ); + aParent->setPosition( Vec2(2*s.width/3, s.height/2) ); addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2(0,0)); + sprite1->setPosition(Vec2(0,0)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); aParent->addChild(sprite1); sprite1->addChild(sprite2, -2); @@ -2608,17 +2608,17 @@ SpriteChildrenVisibilityIssue665::SpriteChildrenVisibilityIssue665() // // parents aParent = SpriteBatchNode::create("animations/grossini.png", 50); - aParent->setPosition(Vector2(s.width/3, s.height/2)); + aParent->setPosition(Vec2(s.width/3, s.height/2)); addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2(0,0)); + sprite1->setPosition(Vec2(0,0)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); // test issue #665 sprite1->setVisible(false); @@ -2631,17 +2631,17 @@ SpriteChildrenVisibilityIssue665::SpriteChildrenVisibilityIssue665() // Sprite // aParent = Node::create(); - aParent->setPosition(Vector2(2*s.width/3, s.height/2)); + aParent->setPosition(Vec2(2*s.width/3, s.height/2)); addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vector2(0,0)); + sprite1->setPosition(Vec2(0,0)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); // test issue #665 sprite1->setVisible(false); @@ -2689,18 +2689,18 @@ SpriteChildrenAnchorPoint::SpriteChildrenAnchorPoint() // anchor (0,0) sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_08.png"); - sprite1->setPosition(Vector2(s.width/4,s.height/2)); - sprite1->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite1->setPosition(Vec2(s.width/4,s.height/2)); + sprite1->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vector2(0,0)); + sprite4->setPosition(Vec2(0,0)); sprite4->setScale( 0.5f ); @@ -2717,17 +2717,17 @@ SpriteChildrenAnchorPoint::SpriteChildrenAnchorPoint() // anchor (0.5, 0.5) sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_08.png"); - sprite1->setPosition(Vector2(s.width/2,s.height/2)); - sprite1->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite1->setPosition(Vec2(s.width/2,s.height/2)); + sprite1->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vector2(0,0)); + sprite4->setPosition(Vec2(0,0)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2743,18 +2743,18 @@ SpriteChildrenAnchorPoint::SpriteChildrenAnchorPoint() // anchor (1,1) sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_08.png"); - sprite1->setPosition(Vector2(s.width/2+s.width/4,s.height/2)); - sprite1->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite1->setPosition(Vec2(s.width/2+s.width/4,s.height/2)); + sprite1->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vector2(0,0)); + sprite4->setPosition(Vec2(0,0)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2807,17 +2807,17 @@ SpriteBatchNodeChildrenAnchorPoint::SpriteBatchNodeChildrenAnchorPoint() // anchor (0,0) sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_08.png"); - sprite1->setPosition(Vector2(s.width/4,s.height/2)); - sprite1->setAnchorPoint( Vector2::ANCHOR_BOTTOM_LEFT ); + sprite1->setPosition(Vec2(s.width/4,s.height/2)); + sprite1->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vector2(0,0)); + sprite4->setPosition(Vec2(0,0)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2833,17 +2833,17 @@ SpriteBatchNodeChildrenAnchorPoint::SpriteBatchNodeChildrenAnchorPoint() // anchor (0.5, 0.5) sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_08.png"); - sprite1->setPosition(Vector2(s.width/2,s.height/2)); - sprite1->setAnchorPoint( Vector2::ANCHOR_MIDDLE ); + sprite1->setPosition(Vec2(s.width/2,s.height/2)); + sprite1->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vector2(0,0)); + sprite4->setPosition(Vec2(0,0)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2859,17 +2859,17 @@ SpriteBatchNodeChildrenAnchorPoint::SpriteBatchNodeChildrenAnchorPoint() // anchor (1,1) sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_08.png"); - sprite1->setPosition(Vector2(s.width/2+s.width/4,s.height/2)); - sprite1->setAnchorPoint( Vector2::ANCHOR_TOP_RIGHT ); + sprite1->setPosition(Vec2(s.width/2+s.width/4,s.height/2)); + sprite1->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vector2(20,30)); + sprite2->setPosition(Vec2(20,30)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vector2(-20,30)); + sprite3->setPosition(Vec2(-20,30)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vector2(0,0)); + sprite4->setPosition(Vec2(0,0)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2922,14 +2922,14 @@ SpriteBatchNodeChildrenScale::SpriteBatchNodeChildrenScale() // aParent = Node::create(); sprite1 = Sprite::createWithSpriteFrameName("grossinis_sister1.png"); - sprite1->setPosition( Vector2( s.width/4, s.height/4) ); + sprite1->setPosition( Vec2( s.width/4, s.height/4) ); sprite1->setScaleX( -0.5f ); sprite1->setScaleY( 2.0f ); sprite1->runAction(seq); sprite2 = Sprite::createWithSpriteFrameName("grossinis_sister2.png"); - sprite2->setPosition( Vector2( 50,0) ); + sprite2->setPosition( Vec2( 50,0) ); addChild(aParent); aParent->addChild(sprite1); @@ -2943,13 +2943,13 @@ SpriteBatchNodeChildrenScale::SpriteBatchNodeChildrenScale() aParent = SpriteBatchNode::create("animations/grossini_family.png"); sprite1 = Sprite::createWithSpriteFrameName("grossinis_sister1.png"); - sprite1->setPosition( Vector2( 3*s.width/4, s.height/4) ); + sprite1->setPosition( Vec2( 3*s.width/4, s.height/4) ); sprite1->setScaleX( -0.5f ); sprite1->setScaleY( 2.0f ); sprite1->runAction( seq->clone() ); sprite2 = Sprite::createWithSpriteFrameName("grossinis_sister2.png"); - sprite2->setPosition( Vector2( 50,0) ); + sprite2->setPosition( Vec2( 50,0) ); addChild(aParent); aParent->addChild(sprite1); @@ -2963,13 +2963,13 @@ SpriteBatchNodeChildrenScale::SpriteBatchNodeChildrenScale() aParent = Node::create(); sprite1 = Sprite::createWithSpriteFrameName("grossinis_sister1.png"); - sprite1->setPosition( Vector2( s.width/4, 2*s.height/3) ); + sprite1->setPosition( Vec2( s.width/4, 2*s.height/3) ); sprite1->setScaleX( 1.5f ); sprite1->setScaleY( -0.5f ); sprite1->runAction( seq->clone() ); sprite2 = Sprite::createWithSpriteFrameName("grossinis_sister2.png"); - sprite2->setPosition( Vector2( 50,0) ); + sprite2->setPosition( Vec2( 50,0) ); addChild(aParent); aParent->addChild(sprite1); @@ -2982,13 +2982,13 @@ SpriteBatchNodeChildrenScale::SpriteBatchNodeChildrenScale() aParent = SpriteBatchNode::create("animations/grossini_family.png"); sprite1 = Sprite::createWithSpriteFrameName("grossinis_sister1.png"); - sprite1->setPosition( Vector2( 3*s.width/4, 2*s.height/3) ); + sprite1->setPosition( Vec2( 3*s.width/4, 2*s.height/3) ); sprite1->setScaleX( 1.5f ); sprite1->setScaleY( -0.5f); sprite1->runAction( seq->clone() ); sprite2 = Sprite::createWithSpriteFrameName("grossinis_sister2.png"); - sprite2->setPosition( Vector2( 50,0) ); + sprite2->setPosition( Vec2( 50,0) ); addChild(aParent); aParent->addChild(sprite1); @@ -3034,14 +3034,14 @@ SpriteChildrenChildren::SpriteChildrenChildren() // parent l1 = Sprite::createWithSpriteFrameName("father.gif"); - l1->setPosition( Vector2( s.width/2, s.height/2) ); + l1->setPosition( Vec2( s.width/2, s.height/2) ); l1->runAction( seq->clone() ); aParent->addChild(l1); auto l1Size = l1->getContentSize(); // child left l2a = Sprite::createWithSpriteFrameName("sister1.gif"); - l2a->setPosition( Vector2( -50 + l1Size.width/2, 0 + l1Size.height/2) ); + l2a->setPosition( Vec2( -50 + l1Size.width/2, 0 + l1Size.height/2) ); l2a->runAction( rot_back_fe->clone() ); l1->addChild(l2a); auto l2aSize = l2a->getContentSize(); @@ -3049,7 +3049,7 @@ SpriteChildrenChildren::SpriteChildrenChildren() // child right l2b = Sprite::createWithSpriteFrameName("sister2.gif"); - l2b->setPosition( Vector2( +50 + l1Size.width/2, 0 + l1Size.height/2) ); + l2b->setPosition( Vec2( +50 + l1Size.width/2, 0 + l1Size.height/2) ); l2b->runAction( rot_back_fe->clone() ); l1->addChild(l2b); auto l2bSize = l2a->getContentSize(); @@ -3058,27 +3058,27 @@ SpriteChildrenChildren::SpriteChildrenChildren() // child left bottom l3a1 = Sprite::createWithSpriteFrameName("child1.gif"); l3a1->setScale( 0.45f ); - l3a1->setPosition( Vector2(0+l2aSize.width/2,-100+l2aSize.height/2) ); + l3a1->setPosition( Vec2(0+l2aSize.width/2,-100+l2aSize.height/2) ); l2a->addChild(l3a1); // child left top l3a2 = Sprite::createWithSpriteFrameName("child1.gif"); l3a2->setScale( 0.45f ); - l3a1->setPosition( Vector2(0+l2aSize.width/2,+100+l2aSize.height/2) ); + l3a1->setPosition( Vec2(0+l2aSize.width/2,+100+l2aSize.height/2) ); l2a->addChild(l3a2); // child right bottom l3b1 = Sprite::createWithSpriteFrameName("child1.gif"); l3b1->setScale( 0.45f); l3b1->setFlippedY( true ); - l3b1->setPosition( Vector2(0+l2bSize.width/2,-100+l2bSize.height/2) ); + l3b1->setPosition( Vec2(0+l2bSize.width/2,-100+l2bSize.height/2) ); l2b->addChild(l3b1); // child right top l3b2 = Sprite::createWithSpriteFrameName("child1.gif"); l3b2->setScale( 0.45f ); l3b2->setFlippedY( true ); - l3b1->setPosition( Vector2(0+l2bSize.width/2,+100+l2bSize.height/2) ); + l3b1->setPosition( Vec2(0+l2bSize.width/2,+100+l2bSize.height/2) ); l2b->addChild(l3b2); } @@ -3123,14 +3123,14 @@ SpriteBatchNodeChildrenChildren::SpriteBatchNodeChildrenChildren() // parent l1 = Sprite::createWithSpriteFrameName("father.gif"); - l1->setPosition( Vector2( s.width/2, s.height/2) ); + l1->setPosition( Vec2( s.width/2, s.height/2) ); l1->runAction( seq->clone() ); aParent->addChild(l1); auto l1Size = l1->getContentSize(); // child left l2a = Sprite::createWithSpriteFrameName("sister1.gif"); - l2a->setPosition( Vector2( -50 + l1Size.width/2, 0 + l1Size.height/2) ); + l2a->setPosition( Vec2( -50 + l1Size.width/2, 0 + l1Size.height/2) ); l2a->runAction( rot_back_fe->clone() ); l1->addChild(l2a); auto l2aSize = l2a->getContentSize(); @@ -3138,7 +3138,7 @@ SpriteBatchNodeChildrenChildren::SpriteBatchNodeChildrenChildren() // child right l2b = Sprite::createWithSpriteFrameName("sister2.gif"); - l2b->setPosition( Vector2( +50 + l1Size.width/2, 0 + l1Size.height/2) ); + l2b->setPosition( Vec2( +50 + l1Size.width/2, 0 + l1Size.height/2) ); l2b->runAction( rot_back_fe->clone() ); l1->addChild(l2b); auto l2bSize = l2a->getContentSize(); @@ -3147,27 +3147,27 @@ SpriteBatchNodeChildrenChildren::SpriteBatchNodeChildrenChildren() // child left bottom l3a1 = Sprite::createWithSpriteFrameName("child1.gif"); l3a1->setScale( 0.45f ); - l3a1->setPosition( Vector2(0+l2aSize.width/2,-100+l2aSize.height/2) ); + l3a1->setPosition( Vec2(0+l2aSize.width/2,-100+l2aSize.height/2) ); l2a->addChild(l3a1); // child left top l3a2 = Sprite::createWithSpriteFrameName("child1.gif"); l3a2->setScale( 0.45f ); - l3a1->setPosition( Vector2(0+l2aSize.width/2,+100+l2aSize.height/2) ); + l3a1->setPosition( Vec2(0+l2aSize.width/2,+100+l2aSize.height/2) ); l2a->addChild(l3a2); // child right bottom l3b1 = Sprite::createWithSpriteFrameName("child1.gif"); l3b1->setScale( 0.45f ); l3b1->setFlippedY( true ); - l3b1->setPosition( Vector2(0+l2bSize.width/2,-100+l2bSize.height/2) ); + l3b1->setPosition( Vec2(0+l2bSize.width/2,-100+l2bSize.height/2) ); l2b->addChild(l3b1); // child right top l3b2 = Sprite::createWithSpriteFrameName("child1.gif"); l3b2->setScale( 0.45f ); l3b2->setFlippedY( true ); - l3b1->setPosition( Vector2(0+l2bSize.width/2,+100+l2bSize.height/2) ); + l3b1->setPosition( Vec2(0+l2bSize.width/2,+100+l2bSize.height/2) ); l2b->addChild(l3b2); } @@ -3201,7 +3201,7 @@ SpriteBatchNodeSkewNegativeScaleChildren::SpriteBatchNodeSkewNegativeScaleChildr for(int i=0;i<2;i++) { auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2( s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2( s.width/4*(i+1), s.height/2)); // Skew auto skewX = SkewBy::create(2, 45, 0); @@ -3218,7 +3218,7 @@ SpriteBatchNodeSkewNegativeScaleChildren::SpriteBatchNodeSkewNegativeScaleChildr sprite->runAction(RepeatForever::create(seq_skew)); auto child1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - child1->setPosition(Vector2(sprite->getContentSize().width / 2.0f, sprite->getContentSize().height / 2.0f)); + child1->setPosition(Vec2(sprite->getContentSize().width / 2.0f, sprite->getContentSize().height / 2.0f)); child1->setScale(0.8f); @@ -3260,7 +3260,7 @@ SpriteSkewNegativeScaleChildren::SpriteSkewNegativeScaleChildren() for(int i=0;i<2;i++) { auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2( s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2( s.width/4*(i+1), s.height/2)); // Skew auto skewX = SkewBy::create(2, 45, 0); @@ -3277,7 +3277,7 @@ SpriteSkewNegativeScaleChildren::SpriteSkewNegativeScaleChildren() sprite->runAction(RepeatForever::create(seq_skew)); auto child1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - child1->setPosition(Vector2(sprite->getContentSize().width / 2.0f, sprite->getContentSize().height / 2.0f)); + child1->setPosition(Vec2(sprite->getContentSize().width / 2.0f, sprite->getContentSize().height / 2.0f)); sprite->addChild(child1); @@ -3322,14 +3322,14 @@ SpriteNilTexture::SpriteNilTexture() sprite->setTextureRect( Rect(0, 0, 300,300) ); sprite->setColor(Color3B::RED); sprite->setOpacity(128); - sprite->setPosition(Vector2(3*s.width/4, s.height/2)); + sprite->setPosition(Vec2(3*s.width/4, s.height/2)); addChild(sprite, 100); sprite = Sprite::create(); sprite->setTextureRect(Rect(0, 0, 300,300)); sprite->setColor(Color3B::BLUE); sprite->setOpacity(128); - sprite->setPosition(Vector2(1*s.width/4, s.height/2)); + sprite->setPosition(Vec2(1*s.width/4, s.height/2)); addChild(sprite, 100); } @@ -3389,14 +3389,14 @@ SpriteSubclass::SpriteSubclass() // MySprite1 MySprite1 *sprite = MySprite1::createWithSpriteFrameName("father.gif"); - sprite->setPosition(Vector2( s.width/4*1, s.height/2)); + sprite->setPosition(Vec2( s.width/4*1, s.height/2)); aParent->addChild(sprite); addChild(aParent); // MySprite2 MySprite2 *sprite2 = MySprite2::create("Images/grossini.png"); addChild(sprite2); - sprite2->setPosition(Vector2(s.width/4*3, s.height/2)); + sprite2->setPosition(Vec2(s.width/4*3, s.height/2)); } std::string SpriteSubclass::title() const @@ -3481,15 +3481,15 @@ SpriteDoubleResolution::SpriteDoubleResolution() // there is no HD resolution file of grossini_dance_08. auto spriteSD = DoubleSprite::create("Images/grossini_dance_08.png"); addChild(spriteSD); - spriteSD->setPosition(Vector2(s.width/4*1,s.height/2)); + spriteSD->setPosition(Vec2(s.width/4*1,s.height/2)); auto child1_left = DoubleSprite::create("Images/grossini_dance_08.png"); spriteSD->addChild(child1_left); - child1_left->setPosition(Vector2(-30,0)); + child1_left->setPosition(Vec2(-30,0)); auto child1_right = Sprite::create("Images/grossini.png"); spriteSD->addChild(child1_right); - child1_left->setPosition(Vector2( spriteSD->getContentSize().height, 0)); + child1_left->setPosition(Vec2( spriteSD->getContentSize().height, 0)); @@ -3499,15 +3499,15 @@ SpriteDoubleResolution::SpriteDoubleResolution() // there is an HD version of grossini.png auto spriteHD = Sprite::create("Images/grossini.png"); addChild(spriteHD); - spriteHD->setPosition(Vector2(s.width/4*3,s.height/2)); + spriteHD->setPosition(Vec2(s.width/4*3,s.height/2)); auto child2_left = DoubleSprite::create("Images/grossini_dance_08.png"); spriteHD->addChild(child2_left); - child2_left->setPosition(Vector2(-30,0)); + child2_left->setPosition(Vec2(-30,0)); auto child2_right = Sprite::create("Images/grossini.png"); spriteHD->addChild(child2_right); - child2_left->setPosition(Vector2( spriteHD->getContentSize().height, 0)); + child2_left->setPosition(Vec2( spriteHD->getContentSize().height, 0)); @@ -3618,7 +3618,7 @@ AnimationCacheTest::AnimationCacheTest() grossini->setSpriteFrame(frame); auto winSize = Director::getInstance()->getWinSize(); - grossini->setPosition(Vector2(winSize.width/2, winSize.height/2)); + grossini->setPosition(Vec2(winSize.width/2, winSize.height/2)); addChild(grossini); // run the animation @@ -3676,7 +3676,7 @@ AnimationCacheFile::AnimationCacheFile() auto winSize = Director::getInstance()->getWinSize(); - grossini->setPosition(Vector2(winSize.width/2, winSize.height/2)); + grossini->setPosition(Vec2(winSize.width/2, winSize.height/2)); addChild(grossini); @@ -3709,11 +3709,11 @@ SpriteBatchBug1217::SpriteBatchBug1217() s2->setColor(Color3B(0, 255, 0)); s3->setColor(Color3B(0, 0, 255)); - s1->setPosition(Vector2(20,200)); - s2->setPosition(Vector2(100,0)); - s3->setPosition(Vector2(100,0)); + s1->setPosition(Vec2(20,200)); + s2->setPosition(Vec2(100,0)); + s3->setPosition(Vec2(100,0)); - bn->setPosition(Vector2(0,0)); + bn->setPosition(Vec2(0,0)); //!!!!! s1->addChild(s2); @@ -3759,7 +3759,7 @@ SpriteOffsetAnchorSkew::SpriteOffsetAnchorSkew() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width / 4 * (i + 1), s.height / 2)); + sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -3769,13 +3769,13 @@ SpriteOffsetAnchorSkew::SpriteOffsetAnchorSkew() switch (i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); break; } @@ -3842,7 +3842,7 @@ SpriteBatchNodeOffsetAnchorSkew::SpriteBatchNodeOffsetAnchorSkew() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width / 4 * (i + 1), s.height / 2)); + sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -3852,13 +3852,13 @@ SpriteBatchNodeOffsetAnchorSkew::SpriteBatchNodeOffsetAnchorSkew() switch (i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -3922,7 +3922,7 @@ SpriteOffsetAnchorSkewScale::SpriteOffsetAnchorSkewScale() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width / 4 * (i + 1), s.height / 2)); + sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -3932,13 +3932,13 @@ SpriteOffsetAnchorSkewScale::SpriteOffsetAnchorSkewScale() switch (i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -4011,7 +4011,7 @@ SpriteBatchNodeOffsetAnchorSkewScale::SpriteBatchNodeOffsetAnchorSkewScale() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width / 4 * (i + 1), s.height / 2)); + sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -4021,13 +4021,13 @@ SpriteBatchNodeOffsetAnchorSkewScale::SpriteBatchNodeOffsetAnchorSkewScale() switch (i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -4099,7 +4099,7 @@ SpriteOffsetAnchorFlip::SpriteOffsetAnchorFlip() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width / 4 * (i + 1), s.height / 2)); + sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -4109,13 +4109,13 @@ SpriteOffsetAnchorFlip::SpriteOffsetAnchorFlip() switch (i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -4181,7 +4181,7 @@ SpriteBatchNodeOffsetAnchorFlip::SpriteBatchNodeOffsetAnchorFlip() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width / 4 * (i + 1), s.height / 2)); + sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); @@ -4191,13 +4191,13 @@ SpriteBatchNodeOffsetAnchorFlip::SpriteBatchNodeOffsetAnchorFlip() switch (i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT ); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT ); break; } @@ -4251,23 +4251,23 @@ NodeSort::NodeSort() addChild(_node, 0, 0); _sprite1 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite1->setPosition(Vector2(100, 160)); + _sprite1->setPosition(Vec2(100, 160)); _node->addChild(_sprite1, -6, 1); _sprite2 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite2->setPosition(Vector2(164, 160)); + _sprite2->setPosition(Vec2(164, 160)); _node->addChild(_sprite2, -6, 2); _sprite4 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite4->setPosition(Vector2(292, 160)); + _sprite4->setPosition(Vec2(292, 160)); _node->addChild(_sprite4, -3, 4); _sprite3 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite3->setPosition(Vector2(228, 160)); + _sprite3->setPosition(Vec2(228, 160)); _node->addChild(_sprite3, -4, 3); _sprite5 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite5->setPosition(Vector2(356, 160)); + _sprite5->setPosition(Vec2(356, 160)); _node->addChild(_sprite5, -3, 5); schedule(schedule_selector(NodeSort::reorderSprite)); @@ -4312,23 +4312,23 @@ SpriteBatchNodeReorderSameIndex::SpriteBatchNodeReorderSameIndex() addChild(_batchNode, 1, 0); _sprite1 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite1->setPosition(Vector2(100,160)); + _sprite1->setPosition(Vec2(100,160)); _batchNode->addChild(_sprite1, 3, 1); _sprite2= Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite2->setPosition(Vector2(164,160)); + _sprite2->setPosition(Vec2(164,160)); _batchNode->addChild(_sprite2, 4, 2); _sprite3 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite3->setPosition(Vector2(228,160)); + _sprite3->setPosition(Vec2(228,160)); _batchNode->addChild(_sprite3, 4, 3); _sprite4 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite4->setPosition(Vector2(292,160)); + _sprite4->setPosition(Vec2(292,160)); _batchNode->addChild(_sprite4, 5, 4); _sprite5 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite5->setPosition(Vector2(356,160)); + _sprite5->setPosition(Vec2(356,160)); _batchNode->addChild(_sprite5, 6, 5); @@ -4380,14 +4380,14 @@ SpriteBatchNodeReorderOneChild::SpriteBatchNodeReorderOneChild() // parent l1 = Sprite::createWithSpriteFrameName("father.gif"); - l1->setPosition(Vector2( s.width/2, s.height/2)); + l1->setPosition(Vec2( s.width/2, s.height/2)); aParent->addChild(l1); auto l1Size = l1->getContentSize(); // child left l2a = Sprite::createWithSpriteFrameName("sister1.gif"); - l2a->setPosition(Vector2( -10 + l1Size.width/2, 0 + l1Size.height/2)); + l2a->setPosition(Vec2( -10 + l1Size.width/2, 0 + l1Size.height/2)); l1->addChild(l2a, 1); auto l2aSize = l2a->getContentSize(); @@ -4395,7 +4395,7 @@ SpriteBatchNodeReorderOneChild::SpriteBatchNodeReorderOneChild() // child right l2b = Sprite::createWithSpriteFrameName("sister2.gif"); - l2b->setPosition(Vector2( +50 + l1Size.width/2, 0 + l1Size.height/2)); + l2b->setPosition(Vec2( +50 + l1Size.width/2, 0 + l1Size.height/2)); l1->addChild(l2b, 2); auto l2bSize = l2a->getContentSize(); @@ -4404,13 +4404,13 @@ SpriteBatchNodeReorderOneChild::SpriteBatchNodeReorderOneChild() // child left bottom l3a1 = Sprite::createWithSpriteFrameName("child1.gif"); l3a1->setScale(0.45f); - l3a1->setPosition(Vector2(0+l2aSize.width/2,-50+l2aSize.height/2)); + l3a1->setPosition(Vec2(0+l2aSize.width/2,-50+l2aSize.height/2)); l2a->addChild(l3a1, 1); // child left top l3a2 = Sprite::createWithSpriteFrameName("child1.gif"); l3a2->setScale(0.45f); - l3a2->setPosition(Vector2(0+l2aSize.width/2,+50+l2aSize.height/2)); + l3a2->setPosition(Vec2(0+l2aSize.width/2,+50+l2aSize.height/2)); l2a->addChild(l3a2, 2); _reorderSprite = l2a; @@ -4419,14 +4419,14 @@ SpriteBatchNodeReorderOneChild::SpriteBatchNodeReorderOneChild() l3b1 = Sprite::createWithSpriteFrameName("child1.gif"); l3b1->setScale(0.45f); l3b1->setFlippedY(true); - l3b1->setPosition(Vector2(0+l2bSize.width/2,-50+l2bSize.height/2)); + l3b1->setPosition(Vec2(0+l2bSize.width/2,-50+l2bSize.height/2)); l2b->addChild(l3b1); // child right top l3b2 = Sprite::createWithSpriteFrameName("child1.gif"); l3b2->setScale(0.45f); l3b2->setFlippedY(true); - l3b2->setPosition(Vector2(0+l2bSize.width/2,+50+l2bSize.height/2)); + l3b2->setPosition(Vec2(0+l2bSize.width/2,+50+l2bSize.height/2)); l2b->addChild(l3b2); scheduleOnce(schedule_selector(SpriteBatchNodeReorderOneChild::reorderSprite), 2.0f); @@ -4463,7 +4463,7 @@ SpriteOffsetAnchorRotationalSkew::SpriteOffsetAnchorRotationalSkew() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2(s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); @@ -4474,13 +4474,13 @@ SpriteOffsetAnchorRotationalSkew::SpriteOffsetAnchorRotationalSkew() switch(i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); break; } @@ -4546,7 +4546,7 @@ SpriteBatchNodeOffsetAnchorRotationalSkew::SpriteBatchNodeOffsetAnchorRotational // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2(s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); @@ -4557,13 +4557,13 @@ SpriteBatchNodeOffsetAnchorRotationalSkew::SpriteBatchNodeOffsetAnchorRotational switch(i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); break; } @@ -4626,7 +4626,7 @@ SpriteOffsetAnchorRotationalSkewScale::SpriteOffsetAnchorRotationalSkewScale() // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2(s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); @@ -4637,13 +4637,13 @@ SpriteOffsetAnchorRotationalSkewScale::SpriteOffsetAnchorRotationalSkewScale() switch(i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); break; } @@ -4714,7 +4714,7 @@ SpriteBatchNodeOffsetAnchorRotationalSkewScale::SpriteBatchNodeOffsetAnchorRotat // Animation using Sprite batch // auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2(s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); @@ -4725,13 +4725,13 @@ SpriteBatchNodeOffsetAnchorRotationalSkewScale::SpriteBatchNodeOffsetAnchorRotat switch(i) { case 0: - sprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); + sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); break; case 1: - sprite->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); break; case 2: - sprite->setAnchorPoint(Vector2::ANCHOR_TOP_RIGHT); + sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); break; } @@ -4801,7 +4801,7 @@ SpriteRotationalSkewNegativeScaleChildren::SpriteRotationalSkewNegativeScaleChil for(int i=0;i<2;i++) { auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2(s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); @@ -4824,7 +4824,7 @@ SpriteRotationalSkewNegativeScaleChildren::SpriteRotationalSkewNegativeScaleChil sprite->runAction(RepeatForever::create(seq_skew)); auto child1 = Sprite::create("Images/grossini_dance_01.png"); - child1->setPosition(Vector2(sprite->getContentSize().width/2.0f, sprite->getContentSize().height/2.0f)); + child1->setPosition(Vec2(sprite->getContentSize().width/2.0f, sprite->getContentSize().height/2.0f)); sprite->addChild(child1); @@ -4868,7 +4868,7 @@ SpriteBatchNodeRotationalSkewNegativeScaleChildren::SpriteBatchNodeRotationalSke for(int i=0;i<2;i++) { auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite->setPosition(Vector2(s.width/4*(i+1), s.height/2)); + sprite->setPosition(Vec2(s.width/4*(i+1), s.height/2)); auto point = Sprite::create("Images/r1.png"); @@ -4891,7 +4891,7 @@ SpriteBatchNodeRotationalSkewNegativeScaleChildren::SpriteBatchNodeRotationalSke sprite->runAction(RepeatForever::create(seq_skew)); auto child1 = Sprite::create("Images/grossini_dance_01.png"); - child1->setPosition(Vector2(sprite->getContentSize().width/2.0f, sprite->getContentSize().height/2.0f)); + child1->setPosition(Vec2(sprite->getContentSize().width/2.0f, sprite->getContentSize().height/2.0f)); sprite->addChild(child1); @@ -4930,13 +4930,13 @@ SpriteCullTest1::SpriteCullTest1() grossini->setPosition(s.width/2, s.height/2); - auto right = MoveBy::create(3, Vector2(s.width*2,0)); + auto right = MoveBy::create(3, Vec2(s.width*2,0)); auto back1 = right->reverse(); - auto left = MoveBy::create(3, Vector2(-s.width*2,0)); + auto left = MoveBy::create(3, Vec2(-s.width*2,0)); auto back2 = left->reverse(); - auto up = MoveBy::create(3, Vector2(0,s.height*2)); + auto up = MoveBy::create(3, Vec2(0,s.height*2)); auto back3 = up->reverse(); - auto down = MoveBy::create(3, Vector2(0,-s.height*2)); + auto down = MoveBy::create(3, Vec2(0,-s.height*2)); auto back4 = down->reverse(); auto seq = Sequence::create(right, back1, left, back2, up, back3, down, back4, nullptr); @@ -4969,13 +4969,13 @@ SpriteCullTest2::SpriteCullTest2() grossini->setPosition(s.width/2, s.height/2); - auto right = MoveBy::create(3, Vector2(s.width*2,0)); + auto right = MoveBy::create(3, Vec2(s.width*2,0)); auto back1 = right->reverse(); - auto left = MoveBy::create(3, Vector2(-s.width*2,0)); + auto left = MoveBy::create(3, Vec2(-s.width*2,0)); auto back2 = left->reverse(); - auto up = MoveBy::create(3, Vector2(0,s.height*2)); + auto up = MoveBy::create(3, Vec2(0,s.height*2)); auto back3 = up->reverse(); - auto down = MoveBy::create(3, Vector2(0,-s.height*2)); + auto down = MoveBy::create(3, Vec2(0,-s.height*2)); auto back4 = down->reverse(); grossini->setScale(0.1f); diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.h b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.h index 0616050e94..e02b16082f 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.h +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.h @@ -57,7 +57,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(Vector2 p); + void addNewSpriteWithCoords(Vec2 p); void onTouchesEnded(const std::vector& touches, Event* event); }; @@ -66,7 +66,7 @@ class SpriteBatchNode1: public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNode1); SpriteBatchNode1(); - void addNewSpriteWithCoords(Vector2 p); + void addNewSpriteWithCoords(Vec2 p); void onTouchesEnded(const std::vector& touches, Event* event); virtual std::string title() const override; virtual std::string subtitle() const override; diff --git a/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp b/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp index 8b19a72467..92aacdd67c 100644 --- a/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp +++ b/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp @@ -167,7 +167,7 @@ void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& in auto& children = getChildren(); Node * node = 0; ssize_t count = children.size(); - Vector2 pos; + Vec2 pos; for (int i = 0; i < count; ++i) { node = children.at(i); @@ -258,9 +258,9 @@ void TextFieldTTFDefaultTest::onEnter() #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // on android, TextFieldTTF cannot auto adjust its position when soft-keyboard pop up // so we had to set a higher position to make it visable - pTextField->setPosition(Vector2(s.width / 2, s.height/2 + 50)); + pTextField->setPosition(Vec2(s.width / 2, s.height/2 + 50)); #else - pTextField->setPosition(Vector2(s.width / 2, s.height / 2)); + pTextField->setPosition(Vec2(s.width / 2, s.height / 2)); #endif _trackNode = pTextField; @@ -320,9 +320,9 @@ void TextFieldTTFActionTest::onEnter() #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // on android, TextFieldTTF cannot auto adjust its position when soft-keyboard pop up // so we had to set a higher position - _textField->setPosition(Vector2(s.width / 2, s.height/2 + 50)); + _textField->setPosition(Vec2(s.width / 2, s.height/2 + 50)); #else - _textField->setPosition(Vector2(s.width / 2, s.height / 2)); + _textField->setPosition(Vec2(s.width / 2, s.height / 2)); #endif _trackNode = _textField; @@ -383,7 +383,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * sender, const endPos.x += sender->getContentSize().width / 2; } auto inputTextSize = label->getContentSize(); - Vector2 beginPos(endPos.x, Director::getInstance()->getWinSize().height - inputTextSize.height * 2); + Vec2 beginPos(endPos.x, Director::getInstance()->getWinSize().height - inputTextSize.height * 2); float duration = 0.5; label->setPosition(beginPos); @@ -414,7 +414,7 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * sender, co beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f; auto winSize = Director::getInstance()->getWinSize(); - Vector2 endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)rand() / (2.0f * RAND_MAX))); + Vec2 endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)rand() / (2.0f * RAND_MAX))); float duration = 1; float rotateDuration = 0.2f; diff --git a/tests/cpp-tests/Classes/TextInputTest/TextInputTest.h b/tests/cpp-tests/Classes/TextInputTest/TextInputTest.h index c029af1326..6b3cfc415f 100644 --- a/tests/cpp-tests/Classes/TextInputTest/TextInputTest.h +++ b/tests/cpp-tests/Classes/TextInputTest/TextInputTest.h @@ -45,7 +45,7 @@ public: protected: Node * _trackNode; - Vector2 _beginPos; + Vec2 _beginPos; }; ////////////////////////////////////////////////////////////////////////// diff --git a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp index c1ee3b2d87..d7a0e0eef4 100644 --- a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp +++ b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp @@ -212,7 +212,7 @@ void TextureTIFF::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image.tiff"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); this->addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); @@ -236,7 +236,7 @@ void TextureTGA::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("TileMaps/levelmap.tga"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); this->addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -258,7 +258,7 @@ void TexturePNG::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image.png"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -279,7 +279,7 @@ void TextureJPEG::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image.jpeg"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -300,7 +300,7 @@ void TextureWEBP::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image.webp"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -329,12 +329,12 @@ void TextureMipMap::onEnter() auto img0 = Sprite::createWithTexture(texture0); img0->setTextureRect(Rect(85, 121, 85, 121)); - img0->setPosition(Vector2( s.width/3.0f, s.height/2.0f)); + img0->setPosition(Vec2( s.width/3.0f, s.height/2.0f)); addChild(img0); auto img1 = Sprite::createWithTexture(texture1); img1->setTextureRect(Rect(85, 121, 85, 121)); - img1->setPosition(Vector2( 2*s.width/3.0f, s.height/2.0f)); + img1->setPosition(Vec2( 2*s.width/3.0f, s.height/2.0f)); addChild(img1); @@ -374,7 +374,7 @@ void TexturePVRMipMap::onEnter() auto imgMipMap = Sprite::create("Images/logo-mipmap.pvr"); if( imgMipMap ) { - imgMipMap->setPosition(Vector2( s.width/2.0f-100, s.height/2.0f)); + imgMipMap->setPosition(Vec2( s.width/2.0f-100, s.height/2.0f)); addChild(imgMipMap); // support mipmap filtering @@ -385,7 +385,7 @@ void TexturePVRMipMap::onEnter() auto img = Sprite::create("Images/logo-nomipmap.pvr"); if( img ) { - img->setPosition(Vector2( s.width/2.0f+100, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f+100, s.height/2.0f)); addChild(img); auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3); @@ -420,7 +420,7 @@ void TexturePVRMipMap2::onEnter() auto s = Director::getInstance()->getWinSize(); auto imgMipMap = Sprite::create("Images/test_image_rgba4444_mipmap.pvr"); - imgMipMap->setPosition(Vector2( s.width/2.0f-100, s.height/2.0f)); + imgMipMap->setPosition(Vec2( s.width/2.0f-100, s.height/2.0f)); addChild(imgMipMap); // support mipmap filtering @@ -428,7 +428,7 @@ void TexturePVRMipMap2::onEnter() imgMipMap->getTexture()->setTexParameters(texParams); auto img = Sprite::create("Images/test_image.png"); - img->setPosition(Vector2( s.width/2.0f+100, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f+100, s.height/2.0f)); addChild(img); auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3); @@ -468,7 +468,7 @@ void TexturePVR2BPP::onEnter() if( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); @@ -495,7 +495,7 @@ void TexturePVRTest::onEnter() if( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } else @@ -527,7 +527,7 @@ void TexturePVR4BPP::onEnter() if( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } else @@ -555,7 +555,7 @@ void TexturePVRRGBA8888::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_rgba8888.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -580,7 +580,7 @@ void TexturePVRBGRA8888::onEnter() auto img = Sprite::create("Images/test_image_bgra8888.pvr"); if( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } else @@ -608,7 +608,7 @@ void TexturePVRRGBA5551::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_rgba5551.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -631,7 +631,7 @@ void TexturePVRRGBA4444::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_rgba4444.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -659,7 +659,7 @@ void TexturePVRRGBA4444GZ::onEnter() #else auto img = Sprite::create("Images/test_image_rgba4444.pvr.gz"); #endif - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -687,7 +687,7 @@ void TexturePVRRGBA4444CCZ::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_rgba4444.pvr.ccz"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -715,7 +715,7 @@ void TexturePVRRGB565::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_rgb565.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -736,7 +736,7 @@ void TexturePVRRGB888::onEnter() auto img = Sprite::create("Images/test_image_rgb888.pvr"); if (img != NULL) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -761,7 +761,7 @@ void TexturePVRA8::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_a8.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); @@ -785,7 +785,7 @@ void TexturePVRI8::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_i8.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -808,7 +808,7 @@ void TexturePVRAI88::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/test_image_ai88.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -828,7 +828,7 @@ void TexturePVR2BPPv3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -855,7 +855,7 @@ void TexturePVRII2BPPv3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -882,7 +882,7 @@ void TexturePVR4BPPv3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } else @@ -917,7 +917,7 @@ void TexturePVRII4BPPv3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } else @@ -948,7 +948,7 @@ void TexturePVRRGBA8888v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -975,7 +975,7 @@ void TexturePVRBGRA8888v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } else @@ -1006,7 +1006,7 @@ void TexturePVRRGBA5551v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1033,7 +1033,7 @@ void TexturePVRRGBA4444v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1060,7 +1060,7 @@ void TexturePVRRGB565v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1087,7 +1087,7 @@ void TexturePVRRGB888v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1114,7 +1114,7 @@ void TexturePVRA8v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1141,7 +1141,7 @@ void TexturePVRI8v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1168,7 +1168,7 @@ void TexturePVRAI88v3::onEnter() if (img) { - img->setPosition(Vector2(s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2(s.width/2.0f, s.height/2.0f)); addChild(img); } @@ -1200,7 +1200,7 @@ void TexturePVRBadEncoding::onEnter() auto img = Sprite::create("Images/test_image-bad_encoding.pvr"); if( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } } @@ -1226,7 +1226,7 @@ void TexturePVRNonSquare::onEnter() auto s = Director::getInstance()->getWinSize(); auto img = Sprite::create("Images/grossini_128x256_mipmap.pvr"); - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } @@ -1254,7 +1254,7 @@ void TexturePVRNPOT4444::onEnter() auto img = Sprite::create("Images/grossini_pvr_rgba4444.pvr"); if ( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); @@ -1283,7 +1283,7 @@ void TexturePVRNPOT8888::onEnter() auto img = Sprite::create("Images/grossini_pvr_rgba8888.pvr"); if( img ) { - img->setPosition(Vector2( s.width/2.0f, s.height/2.0f)); + img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); } log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); @@ -1315,7 +1315,7 @@ void TextureAlias::onEnter() // Default filter is GL_LINEAR auto sprite = Sprite::create("Images/grossinis_sister1.png"); - sprite->setPosition(Vector2( s.width/3.0f, s.height/2.0f)); + sprite->setPosition(Vec2( s.width/3.0f, s.height/2.0f)); addChild(sprite); // this is the default filterting @@ -1326,7 +1326,7 @@ void TextureAlias::onEnter() // auto sprite2 = Sprite::create("Images/grossinis_sister2.png"); - sprite2->setPosition(Vector2( 2*s.width/3.0f, s.height/2.0f)); + sprite2->setPosition(Vec2( 2*s.width/3.0f, s.height/2.0f)); addChild(sprite2); // Use Nearest in this one @@ -1377,7 +1377,7 @@ void TexturePixelFormat::onEnter() // RGBA 8888 image (32-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); auto sprite1 = Sprite::create("Images/test-rgba1.png"); - sprite1->setPosition(Vector2(1*s.width/7, s.height/2+32)); + sprite1->setPosition(Vec2(1*s.width/7, s.height/2+32)); addChild(sprite1, 0); // remove texture from texture manager @@ -1386,7 +1386,7 @@ void TexturePixelFormat::onEnter() // RGBA 4444 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); auto sprite2 = Sprite::create("Images/test-rgba1.png"); - sprite2->setPosition(Vector2(2*s.width/7, s.height/2-32)); + sprite2->setPosition(Vec2(2*s.width/7, s.height/2-32)); addChild(sprite2, 0); // remove texture from texture manager @@ -1395,7 +1395,7 @@ void TexturePixelFormat::onEnter() // RGB5A1 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); auto sprite3 = Sprite::create("Images/test-rgba1.png"); - sprite3->setPosition(Vector2(3*s.width/7, s.height/2+32)); + sprite3->setPosition(Vec2(3*s.width/7, s.height/2+32)); addChild(sprite3, 0); // remove texture from texture manager @@ -1404,7 +1404,7 @@ void TexturePixelFormat::onEnter() // RGB888 image Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB888); auto sprite4 = Sprite::create("Images/test-rgba1.png"); - sprite4->setPosition(Vector2(4*s.width/7, s.height/2-32)); + sprite4->setPosition(Vec2(4*s.width/7, s.height/2-32)); addChild(sprite4, 0); // remove texture from texture manager @@ -1413,7 +1413,7 @@ void TexturePixelFormat::onEnter() // RGB565 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565); auto sprite5 = Sprite::create("Images/test-rgba1.png"); - sprite5->setPosition(Vector2(5*s.width/7, s.height/2+32)); + sprite5->setPosition(Vec2(5*s.width/7, s.height/2+32)); addChild(sprite5, 0); // remove texture from texture manager @@ -1422,7 +1422,7 @@ void TexturePixelFormat::onEnter() // A8 image (8-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); auto sprite6 = Sprite::create("Images/test-rgba1.png"); - sprite6->setPosition(Vector2(6*s.width/7, s.height/2-32)); + sprite6->setPosition(Vec2(6*s.width/7, s.height/2-32)); addChild(sprite6, 0); // remove texture from texture manager @@ -1473,14 +1473,14 @@ void TextureBlend::onEnter() // they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA auto cloud = Sprite::create("Images/test_blend.png"); addChild(cloud, i+1, 100+i); - cloud->setPosition(Vector2(50+25*i, 80)); + cloud->setPosition(Vec2(50+25*i, 80)); cloud->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); // CENTER sprites have also alpha pre-multiplied // they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA cloud = Sprite::create("Images/test_blend.png"); addChild(cloud, i+1, 200+i); - cloud->setPosition(Vector2(50+25*i, 160)); + cloud->setPosition(Vec2(50+25*i, 160)); BlendFunc blendFunc2 = { GL_ONE_MINUS_DST_COLOR, GL_ZERO }; cloud->setBlendFunc(blendFunc2); @@ -1488,7 +1488,7 @@ void TextureBlend::onEnter() // You can set any blend function to your sprites cloud = Sprite::create("Images/test_blend.png"); addChild(cloud, i+1, 200+i); - cloud->setPosition(Vector2(50+25*i, 320-80)); + cloud->setPosition(Vec2(50+25*i, 320-80)); BlendFunc blendFunc3 = { GL_SRC_ALPHA, GL_ONE }; cloud->setBlendFunc(blendFunc3); // additive blending } @@ -1520,7 +1520,7 @@ void TextureAsync::onEnter() auto size = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("Loading...", "fonts/Marker Felt.ttf", 32); - label->setPosition(Vector2( size.width/2, size.height/2)); + label->setPosition(Vec2( size.width/2, size.height/2)); addChild(label, 10); auto scale = ScaleBy::create(0.3f, 2); @@ -1565,12 +1565,12 @@ void TextureAsync::imageLoaded(Texture2D* texture) // This test just creates a sprite based on the Texture auto sprite = Sprite::createWithTexture(texture); - sprite->setAnchorPoint(Vector2(0,0)); + sprite->setAnchorPoint(Vec2(0,0)); addChild(sprite, -1); auto size = director->getWinSize(); int i = _imageOffset * 32; - sprite->setPosition(Vector2( i % (int)size.width, (i / (int)size.width) * 32 )); + sprite->setPosition(Vec2( i % (int)size.width, (i / (int)size.width) * 32 )); _imageOffset++; @@ -1603,7 +1603,7 @@ void TextureGlClamp::onEnter() // eg: 32x64, 512x128, 256x1024, 64x64, etc.. auto sprite = Sprite::create("Images/pattern1.png", Rect(0,0,512,256)); addChild(sprite, -1, kTagSprite1); - sprite->setPosition(Vector2(size.width/2,size.height/2)); + sprite->setPosition(Vec2(size.width/2,size.height/2)); Texture2D::TexParams params = {GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE}; sprite->getTexture()->setTexParameters(params); @@ -1640,7 +1640,7 @@ void TextureGlRepeat::onEnter() // eg: 32x64, 512x128, 256x1024, 64x64, etc.. auto sprite = Sprite::create("Images/pattern1.png", Rect(0, 0, 4096, 4096)); addChild(sprite, -1, kTagSprite1); - sprite->setPosition(Vector2(size.width/2,size.height/2)); + sprite->setPosition(Vec2(size.width/2,size.height/2)); Texture2D::TexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT}; sprite->getTexture()->setTexParameters(params); @@ -1725,7 +1725,7 @@ void TextureCache1::onEnter() Sprite *sprite; sprite = Sprite::create("Images/grossinis_sister1.png"); - sprite->setPosition(Vector2(s.width/5*1, s.height/2)); + sprite->setPosition(Vec2(s.width/5*1, s.height/2)); sprite->getTexture()->setAliasTexParameters(); sprite->setScale(2); addChild(sprite); @@ -1733,7 +1733,7 @@ void TextureCache1::onEnter() Director::getInstance()->getTextureCache()->removeTexture(sprite->getTexture()); sprite = Sprite::create("Images/grossinis_sister1.png"); - sprite->setPosition(Vector2(s.width/5*2, s.height/2)); + sprite->setPosition(Vec2(s.width/5*2, s.height/2)); sprite->getTexture()->setAntiAliasTexParameters(); sprite->setScale(2); addChild(sprite); @@ -1741,7 +1741,7 @@ void TextureCache1::onEnter() // 2nd set of sprites sprite = Sprite::create("Images/grossinis_sister2.png"); - sprite->setPosition(Vector2(s.width/5*3, s.height/2)); + sprite->setPosition(Vec2(s.width/5*3, s.height/2)); sprite->getTexture()->setAliasTexParameters(); sprite->setScale(2); addChild(sprite); @@ -1749,7 +1749,7 @@ void TextureCache1::onEnter() Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister2.png"); sprite = Sprite::create("Images/grossinis_sister2.png"); - sprite->setPosition(Vector2(s.width/5*4, s.height/2)); + sprite->setPosition(Vec2(s.width/5*4, s.height/2)); sprite->getTexture()->setAntiAliasTexParameters(); sprite->setScale(2); addChild(sprite); @@ -1793,7 +1793,7 @@ std::string TextureDrawAtPoint::subtitle() const return "draws 2 textures using drawAtPoint"; } -void TextureDrawAtPoint::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TextureDrawAtPoint::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { TextureDemo::draw(renderer, transform, transformUpdated); @@ -1803,7 +1803,7 @@ void TextureDrawAtPoint::draw(Renderer *renderer, const Matrix &transform, bool } -void TextureDrawAtPoint::onDraw(const Matrix &transform, bool transformUpdated) +void TextureDrawAtPoint::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1812,8 +1812,8 @@ void TextureDrawAtPoint::onDraw(const Matrix &transform, bool transformUpdated) auto s = Director::getInstance()->getWinSize(); - _tex1->drawAtPoint(Vector2(s.width/2-50, s.height/2 - 50)); - _Tex2F->drawAtPoint(Vector2(s.width/2+50, s.height/2 - 50)); + _tex1->drawAtPoint(Vec2(s.width/2-50, s.height/2 - 50)); + _Tex2F->drawAtPoint(Vec2(s.width/2+50, s.height/2 - 50)); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } @@ -1836,7 +1836,7 @@ TextureDrawInRect::~TextureDrawInRect() _Tex2F->release(); } -void TextureDrawInRect::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TextureDrawInRect::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { TextureDemo::draw(renderer, transform, transformUpdated); @@ -1845,7 +1845,7 @@ void TextureDrawInRect::draw(Renderer *renderer, const Matrix &transform, bool t renderer->addCommand(&_renderCmd); } -void TextureDrawInRect::onDraw(const Matrix &transform, bool transformUpdated) +void TextureDrawInRect::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1926,7 +1926,7 @@ void TextureMemoryAlloc::onEnter() addChild(menu2); auto s = Director::getInstance()->getWinSize(); - menu2->setPosition(Vector2(s.width/2, s.height/4)); + menu2->setPosition(Vec2(s.width/2, s.height/4)); } void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::Ref *sender) @@ -1989,7 +1989,7 @@ void TextureMemoryAlloc::updateImage(cocos2d::Ref *sender) _background->setVisible(false); auto s = Director::getInstance()->getWinSize(); - _background->setPosition(Vector2(s.width/2, s.height/2)); + _background->setPosition(Vec2(s.width/2, s.height/2)); } std::string TextureMemoryAlloc::title() const @@ -2014,13 +2014,13 @@ TexturePVRv3Premult::TexturePVRv3Premult() // PVR premultiplied auto pvr1 = Sprite::create("Images/grossinis_sister1-testalpha_premult.pvr"); addChild(pvr1, 0); - pvr1->setPosition(Vector2(size.width/4*1, size.height/2)); + pvr1->setPosition(Vec2(size.width/4*1, size.height/2)); transformSprite(pvr1); // PVR non-premultiplied auto pvr2 = Sprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr"); addChild(pvr2, 0); - pvr2->setPosition(Vector2(size.width/4*2, size.height/2)); + pvr2->setPosition(Vec2(size.width/4*2, size.height/2)); transformSprite(pvr2); // PNG @@ -2028,7 +2028,7 @@ TexturePVRv3Premult::TexturePVRv3Premult() Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png"); auto png = Sprite::create("Images/grossinis_sister1-testalpha.png"); addChild(png, 0); - png->setPosition(Vector2(size.width/4*3, size.height/2)); + png->setPosition(Vec2(size.width/4*3, size.height/2)); transformSprite(png); } @@ -2070,7 +2070,7 @@ TextureETC1::TextureETC1() auto sprite = Sprite::create("Images/ETC1.pkm"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width/2, size.height/2)); + sprite->setPosition(Vec2(size.width/2, size.height/2)); addChild(sprite); } @@ -2091,7 +2091,7 @@ TextureS3TCDxt1::TextureS3TCDxt1() auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt1_mipmaps.dds"); //auto sprite = Sprite::create("Images/water_2_dxt1.dds"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height / 2)); + sprite->setPosition(Vec2(size.width / 2, size.height / 2)); addChild(sprite); } @@ -2110,7 +2110,7 @@ TextureS3TCDxt3::TextureS3TCDxt3() auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt3_mipmaps.dds"); //auto sprite = Sprite::create("Images/water_2_dxt3.dds"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height / 2)); + sprite->setPosition(Vec2(size.width / 2, size.height / 2)); addChild(sprite); } @@ -2129,7 +2129,7 @@ TextureS3TCDxt5::TextureS3TCDxt5() auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds"); //auto sprite = Sprite::create("Images/water_2_dxt5.dds"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height / 2)); + sprite->setPosition(Vec2(size.width / 2, size.height / 2)); addChild(sprite); } @@ -2147,7 +2147,7 @@ TextureS3TCWithNoMipmaps::TextureS3TCWithNoMipmaps() { auto sprite = Sprite::create("Images/test_512x512_s3tc_dxt5_with_no_mipmaps.dds"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height / 2)); + sprite->setPosition(Vec2(size.width / 2, size.height / 2)); addChild(sprite); } @@ -2162,7 +2162,7 @@ TextureATITCRGB::TextureATITCRGB() auto sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height / 2)); + sprite->setPosition(Vec2(size.width / 2, size.height / 2)); addChild(sprite); } @@ -2180,7 +2180,7 @@ TextureATITCExplicit::TextureATITCExplicit() auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height / 2)); + sprite->setPosition(Vec2(size.width / 2, size.height / 2)); addChild(sprite); } @@ -2198,7 +2198,7 @@ TextureATITCInterpolated::TextureATITCInterpolated() auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx"); auto size = Director::getInstance()->getWinSize(); - sprite->setPosition(Vector2(size.width / 2, size.height /2)); + sprite->setPosition(Vec2(size.width / 2, size.height /2)); addChild(sprite); } @@ -2215,7 +2215,7 @@ static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path { Texture2D::setDefaultAlphaPixelFormat(format); auto sprite = Sprite::create(path); - sprite->setPosition(Vector2(x, y)); + sprite->setPosition(Vec2(x, y)); demo.addChild(sprite, 0); //remove texture from texture manager diff --git a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h index 218af02427..814b2f01ba 100644 --- a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h +++ b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h @@ -465,9 +465,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); CustomCommand _renderCmd; Texture2D* _tex1, *_Tex2F; @@ -481,9 +481,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); CustomCommand _renderCmd; Texture2D* _tex1, *_Tex2F; diff --git a/tests/cpp-tests/Classes/TextureCacheTest/TextureCacheTest.cpp b/tests/cpp-tests/Classes/TextureCacheTest/TextureCacheTest.cpp index 1c91e8f766..52b3e5d864 100644 --- a/tests/cpp-tests/Classes/TextureCacheTest/TextureCacheTest.cpp +++ b/tests/cpp-tests/Classes/TextureCacheTest/TextureCacheTest.cpp @@ -15,8 +15,8 @@ TextureCacheTest::TextureCacheTest() _labelLoading = Label::createWithTTF("loading...", "fonts/arial.ttf", 15); _labelPercent = Label::createWithTTF("%0", "fonts/arial.ttf", 15); - _labelLoading->setPosition(Vector2(size.width / 2, size.height / 2 - 20)); - _labelPercent->setPosition(Vector2(size.width / 2, size.height / 2 + 20)); + _labelLoading->setPosition(Vec2(size.width / 2, size.height / 2 - 20)); + _labelPercent->setPosition(Vec2(size.width / 2, size.height / 2 + 20)); this->addChild(_labelLoading); this->addChild(_labelPercent); @@ -66,7 +66,7 @@ void TextureCacheTest::addSprite() // create sprites auto bg = Sprite::create("Images/HelloWorld.png"); - bg->setPosition(Vector2(size.width / 2, size.height / 2)); + bg->setPosition(Vec2(size.width / 2, size.height / 2)); auto s1 = Sprite::create("Images/grossini.png"); auto s2 = Sprite::create("Images/grossini_dance_01.png"); @@ -90,23 +90,23 @@ void TextureCacheTest::addSprite() Sprite::create("Images/background3.png"); Sprite::create("Images/blocks.png"); - s1->setPosition(Vector2(50, 50)); - s2->setPosition(Vector2(60, 50)); - s3->setPosition(Vector2(70, 50)); - s4->setPosition(Vector2(80, 50)); - s5->setPosition(Vector2(90, 50)); - s6->setPosition(Vector2(100, 50)); + s1->setPosition(Vec2(50, 50)); + s2->setPosition(Vec2(60, 50)); + s3->setPosition(Vec2(70, 50)); + s4->setPosition(Vec2(80, 50)); + s5->setPosition(Vec2(90, 50)); + s6->setPosition(Vec2(100, 50)); - s7->setPosition(Vector2(50, 180)); - s8->setPosition(Vector2(60, 180)); - s9->setPosition(Vector2(70, 180)); - s10->setPosition(Vector2(80, 180)); - s11->setPosition(Vector2(90, 180)); - s12->setPosition(Vector2(100, 180)); + s7->setPosition(Vec2(50, 180)); + s8->setPosition(Vec2(60, 180)); + s9->setPosition(Vec2(70, 180)); + s10->setPosition(Vec2(80, 180)); + s11->setPosition(Vec2(90, 180)); + s12->setPosition(Vec2(100, 180)); - s13->setPosition(Vector2(50, 270)); - s14->setPosition(Vector2(60, 270)); - s15->setPosition(Vector2(70, 270)); + s13->setPosition(Vec2(50, 270)); + s14->setPosition(Vec2(60, 270)); + s15->setPosition(Vec2(70, 270)); this->addChild(bg); diff --git a/tests/cpp-tests/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp b/tests/cpp-tests/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp index aa5579a850..7e1d939990 100644 --- a/tests/cpp-tests/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp +++ b/tests/cpp-tests/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp @@ -18,14 +18,14 @@ void TextureAtlasEncryptionDemo::onEnter() auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 28); - label->setPosition( Vector2(s.width/2, s.height * 0.75f) ); + label->setPosition( Vec2(s.width/2, s.height * 0.75f) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { auto subLabel = Label::createWithTTF(strSubtitle.c_str(), "fonts/Thonburi.ttf", 16); - subLabel->setPosition( Vector2(s.width/2, s.height-80) ); + subLabel->setPosition( Vec2(s.width/2, s.height-80) ); this->addChild(subLabel, 1); } @@ -34,11 +34,11 @@ void TextureAtlasEncryptionDemo::onEnter() // Create a sprite from the non-encrypted atlas auto nonencryptedSprite = Sprite::createWithSpriteFrameName("Icon.png"); - nonencryptedSprite->setPosition(Vector2(s.width * 0.25f, s.height * 0.5f)); + nonencryptedSprite->setPosition(Vec2(s.width * 0.25f, s.height * 0.5f)); this->addChild(nonencryptedSprite); auto nonencryptedSpriteLabel = Label::createWithTTF("non-encrypted", "fonts/arial.ttf", 28); - nonencryptedSpriteLabel->setPosition(Vector2(s.width * 0.25f, nonencryptedSprite->getBoundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2)); + nonencryptedSpriteLabel->setPosition(Vec2(s.width * 0.25f, nonencryptedSprite->getBoundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2)); this->addChild(nonencryptedSpriteLabel, 1); // Load the encrypted atlas @@ -61,11 +61,11 @@ void TextureAtlasEncryptionDemo::onEnter() // 3) Create a sprite from the encrypted atlas auto encryptedSprite = Sprite::createWithSpriteFrameName("powered.png"); - encryptedSprite->setPosition(Vector2(s.width * 0.75f, s.height * 0.5f)); + encryptedSprite->setPosition(Vec2(s.width * 0.75f, s.height * 0.5f)); this->addChild(encryptedSprite); auto encryptedSpriteLabel = Label::createWithTTF("encrypted", "fonts/arial.ttf", 28); - encryptedSpriteLabel->setPosition(Vector2(s.width * 0.75f, encryptedSprite->getBoundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2)); + encryptedSpriteLabel->setPosition(Vec2(s.width * 0.75f, encryptedSprite->getBoundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2)); this->addChild(encryptedSpriteLabel, 1); } diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp index e079a94206..8a129a3f93 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp @@ -190,7 +190,7 @@ TileMapTest::TileMapTest() addChild(map, 0, kTagTileMap); - map->setAnchorPoint( Vector2(0, 0.5f) ); + map->setAnchorPoint( Vec2(0, 0.5f) ); auto scale = ScaleBy::create(4, 0.8f); auto scaleBack = scale->reverse(); @@ -226,8 +226,8 @@ TileMapEditTest::TileMapEditTest() addChild(map, 0, kTagTileMap); - map->setAnchorPoint( Vector2(0, 0) ); - map->setPosition( Vector2(-20,-200) ); + map->setAnchorPoint( Vec2(0, 0) ); + map->setPosition( Vec2(-20,-200) ); } void TileMapEditTest::updateMap(float dt) @@ -252,14 +252,14 @@ void TileMapEditTest::updateMap(float dt) // } // NEW since v0.7 - Color3B c = tilemap->getTileAt(Vector2(13,21)); + Color3B c = tilemap->getTileAt(Vec2(13,21)); c.r++; c.r %= 50; if( c.r==0) c.r=1; // NEW since v0.7 - tilemap->setTile(c, Vector2(13,21) ); + tilemap->setTile(c, Vec2(13,21) ); } std::string TileMapEditTest::title() const @@ -369,7 +369,7 @@ TMXOrthoTest3::TMXOrthoTest3() } map->setScale(0.2f); - map->setAnchorPoint( Vector2(0.5f, 0.5f) ); + map->setAnchorPoint( Vec2(0.5f, 0.5f) ); } std::string TMXOrthoTest3::title() const @@ -399,19 +399,19 @@ TMXOrthoTest4::TMXOrthoTest4() child->getTexture()->setAntiAliasTexParameters(); } - map->setAnchorPoint(Vector2(0, 0)); + map->setAnchorPoint(Vec2(0, 0)); auto layer = map->getLayer("Layer 0"); auto s = layer->getLayerSize(); Sprite* sprite; - sprite = layer->getTileAt(Vector2(0,0)); + sprite = layer->getTileAt(Vec2(0,0)); sprite->setScale(2); - sprite = layer->getTileAt(Vector2(s.width-1,0)); + sprite = layer->getTileAt(Vec2(s.width-1,0)); sprite->setScale(2); - sprite = layer->getTileAt(Vector2(0,s.height-1)); + sprite = layer->getTileAt(Vec2(0,s.height-1)); sprite->setScale(2); - sprite = layer->getTileAt(Vector2(s.width-1,s.height-1)); + sprite = layer->getTileAt(Vec2(s.width-1,s.height-1)); sprite->setScale(2); schedule( schedule_selector(TMXOrthoTest4::removeSprite), 2 ); @@ -426,10 +426,10 @@ void TMXOrthoTest4::removeSprite(float dt) auto layer = map->getLayer("Layer 0"); auto s = layer->getLayerSize(); - auto sprite = layer->getTileAt( Vector2(s.width-1,0) ); - auto sprite2 = layer->getTileAt(Vector2(s.width-1, s.height-1)); + auto sprite = layer->getTileAt( Vec2(s.width-1,0) ); + auto sprite2 = layer->getTileAt(Vec2(s.width-1, s.height-1)); layer->removeChild(sprite, true); - auto sprite3 = layer->getTileAt(Vector2(2, s.height-1)); + auto sprite3 = layer->getTileAt(Vec2(2, s.height-1)); layer->removeChild(sprite3, true); layer->removeChild(sprite2, true); } @@ -467,16 +467,16 @@ TMXReadWriteTest::TMXReadWriteTest() map->setScale( 1 ); - auto tile0 = layer->getTileAt(Vector2(1,63)); - auto tile1 = layer->getTileAt(Vector2(2,63)); - auto tile2 = layer->getTileAt(Vector2(3,62));//Vector2(1,62)); - auto tile3 = layer->getTileAt(Vector2(2,62)); - tile0->setAnchorPoint( Vector2(0.5f, 0.5f) ); - tile1->setAnchorPoint( Vector2(0.5f, 0.5f) ); - tile2->setAnchorPoint( Vector2(0.5f, 0.5f) ); - tile3->setAnchorPoint( Vector2(0.5f, 0.5f) ); + auto tile0 = layer->getTileAt(Vec2(1,63)); + auto tile1 = layer->getTileAt(Vec2(2,63)); + auto tile2 = layer->getTileAt(Vec2(3,62));//Vec2(1,62)); + auto tile3 = layer->getTileAt(Vec2(2,62)); + tile0->setAnchorPoint( Vec2(0.5f, 0.5f) ); + tile1->setAnchorPoint( Vec2(0.5f, 0.5f) ); + tile2->setAnchorPoint( Vec2(0.5f, 0.5f) ); + tile3->setAnchorPoint( Vec2(0.5f, 0.5f) ); - auto move = MoveBy::create(0.5f, Vector2(0,160)); + auto move = MoveBy::create(0.5f, Vec2(0,160)); auto rotate = RotateBy::create(2, 360); auto scale = ScaleBy::create(2, 5); auto opacity = FadeOut::create(2); @@ -494,7 +494,7 @@ TMXReadWriteTest::TMXReadWriteTest() tile3->runAction(seq3); - _gid = layer->getTileGIDAt(Vector2(0,63)); + _gid = layer->getTileGIDAt(Vec2(0,63)); ////----CCLOG("Tile GID at:(0,63) is: %d", _gid); schedule(schedule_selector(TMXReadWriteTest::updateCol), 2.0f); @@ -533,7 +533,7 @@ void TMXReadWriteTest::updateCol(float dt) for( int y=0; y< s.height; y++ ) { - layer->setTileGID(_gid2, Vector2((float)3, (float)y)); + layer->setTileGID(_gid2, Vec2((float)3, (float)y)); } _gid2 = (_gid2 + 1) % 80; @@ -550,8 +550,8 @@ void TMXReadWriteTest::repaintWithGID(float dt) for( int x=0; xgetTileGIDAt( Vector2((float)x, (float)y) ); - layer->setTileGID(tmpgid+1, Vector2((float)x, (float)y)); + unsigned int tmpgid = layer->getTileGIDAt( Vec2((float)x, (float)y) ); + layer->setTileGID(tmpgid+1, Vec2((float)x, (float)y)); } } @@ -565,7 +565,7 @@ void TMXReadWriteTest::removeTiles(float dt) for( int y=0; y< s.height; y++ ) { - layer->removeTileAt( Vector2(5.0, (float)y) ); + layer->removeTileAt( Vec2(5.0, (float)y) ); } } @@ -614,7 +614,7 @@ TMXIsoTest::TMXIsoTest() // move map to the center of the screen auto ms = map->getMapSize(); auto ts = map->getTileSize(); - map->runAction( MoveTo::create(1.0f, Vector2( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ); + map->runAction( MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ); } std::string TMXIsoTest::title() const @@ -638,7 +638,7 @@ TMXIsoTest1::TMXIsoTest1() Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - map->setAnchorPoint(Vector2(0.5f, 0.5f)); + map->setAnchorPoint(Vec2(0.5f, 0.5f)); } std::string TMXIsoTest1::title() const @@ -665,7 +665,7 @@ TMXIsoTest2::TMXIsoTest2() // move map to the center of the screen auto ms = map->getMapSize(); auto ts = map->getTileSize(); - map->runAction( MoveTo::create(1.0f, Vector2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); + map->runAction( MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); } std::string TMXIsoTest2::title() const @@ -692,7 +692,7 @@ TMXUncompressedTest::TMXUncompressedTest() // move map to the center of the screen auto ms = map->getMapSize(); auto ts = map->getTileSize(); - map->runAction(MoveTo::create(1.0f, Vector2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); + map->runAction(MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); // testing release map TMXLayer* layer; @@ -759,14 +759,14 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() CCLOG("%s", objectsVal.getDescription().c_str()); } -void TMXOrthoObjectsTest::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TMXOrthoObjectsTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this, transform, transformUpdated); renderer->addCommand(&_renderCmd); } -void TMXOrthoObjectsTest::onDraw(const Matrix &transform, bool transformUpdated) +void TMXOrthoObjectsTest::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -790,10 +790,10 @@ void TMXOrthoObjectsTest::onDraw(const Matrix &transform, bool transformUpdated) glLineWidth(3); - DrawPrimitives::drawLine( pos + Vector2(x, y), pos + Vector2((x+width), y) ); - DrawPrimitives::drawLine( pos + Vector2((x+width), y), pos + Vector2((x+width), (y+height)) ); - DrawPrimitives::drawLine( pos + Vector2((x+width), (y+height)), pos + Vector2(x, (y+height)) ); - DrawPrimitives::drawLine( pos + Vector2(x, (y+height)), pos + Vector2(x, y) ); + DrawPrimitives::drawLine( pos + Vec2(x, y), pos + Vec2((x+width), y) ); + DrawPrimitives::drawLine( pos + Vec2((x+width), y), pos + Vec2((x+width), (y+height)) ); + DrawPrimitives::drawLine( pos + Vec2((x+width), (y+height)), pos + Vec2(x, (y+height)) ); + DrawPrimitives::drawLine( pos + Vec2(x, (y+height)), pos + Vec2(x, y) ); glLineWidth(1); } @@ -834,14 +834,14 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() CCLOG("%s", objectsVal.getDescription().c_str()); } -void TMXIsoObjectsTest::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TMXIsoObjectsTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this, transform, transformUpdated); renderer->addCommand(&_renderCmd); } -void TMXIsoObjectsTest::onDraw(const Matrix &transform, bool transformUpdated) +void TMXIsoObjectsTest::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -863,10 +863,10 @@ void TMXIsoObjectsTest::onDraw(const Matrix &transform, bool transformUpdated) glLineWidth(3); - DrawPrimitives::drawLine( pos + Vector2(x,y), pos + Vector2(x+width,y) ); - DrawPrimitives::drawLine( pos + Vector2(x+width,y), pos + Vector2(x+width,y+height) ); - DrawPrimitives::drawLine( pos + Vector2(x+width,y+height), pos + Vector2(x,y+height) ); - DrawPrimitives::drawLine( pos + Vector2(x,y+height), pos + Vector2(x,y) ); + DrawPrimitives::drawLine( pos + Vec2(x,y), pos + Vec2(x+width,y) ); + DrawPrimitives::drawLine( pos + Vec2(x+width,y), pos + Vec2(x+width,y+height) ); + DrawPrimitives::drawLine( pos + Vec2(x+width,y+height), pos + Vec2(x,y+height) ); + DrawPrimitives::drawLine( pos + Vec2(x,y+height), pos + Vec2(x,y) ); glLineWidth(1); } @@ -907,7 +907,7 @@ TMXResizeTest::TMXResizeTest() { for (unsigned int x = 0; x < ls.width; x++) { - layer->setTileGID(1, Vector2( x, y ) ); + layer->setTileGID(1, Vec2( x, y ) ); } } } @@ -935,17 +935,17 @@ TMXIsoZorder::TMXIsoZorder() auto s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - map->setPosition(Vector2(-s.width/2,0)); + map->setPosition(Vec2(-s.width/2,0)); _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, (int)map->getChildren().size() ); _tamara->retain(); int mapWidth = map->getMapSize().width * map->getTileSize().width; - _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vector2( mapWidth/2,0))); - _tamara->setAnchorPoint(Vector2(0.5f,0)); + _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2,0))); + _tamara->setAnchorPoint(Vec2(0.5f,0)); - auto move = MoveBy::create(10, Vector2(300,250)); + auto move = MoveBy::create(10, Vec2(300,250)); auto back = move->reverse(); auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq) ); @@ -1008,10 +1008,10 @@ TMXOrthoZorder::TMXOrthoZorder() _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, (int)map->getChildren().size()); _tamara->retain(); - _tamara->setAnchorPoint(Vector2(0.5f,0)); + _tamara->setAnchorPoint(Vec2(0.5f,0)); - auto move = MoveBy::create(10, Vector2(400,450)); + auto move = MoveBy::create(10, Vec2(400,450)); auto back = move->reverse(); auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq)); @@ -1064,16 +1064,16 @@ TMXIsoVertexZ::TMXIsoVertexZ() addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); - map->setPosition( Vector2(-s.width/2,0) ); + map->setPosition( Vec2(-s.width/2,0) ); CCLOG("ContentSize: %f, %f", s.width,s.height); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any Sprite and it will work OK. auto layer = map->getLayer("Trees"); - _tamara = layer->getTileAt( Vector2(29,29) ); + _tamara = layer->getTileAt( Vec2(29,29) ); _tamara->retain(); - auto move = MoveBy::create(10, Vector2(300,250) * (1/CC_CONTENT_SCALE_FACTOR())); + auto move = MoveBy::create(10, Vec2(300,250) * (1/CC_CONTENT_SCALE_FACTOR())); auto back = move->reverse(); auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq) ); @@ -1141,11 +1141,11 @@ TMXOrthoVertexZ::TMXOrthoVertexZ() // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any Sprite and it will work OK. auto layer = map->getLayer("trees"); - _tamara = layer->getTileAt(Vector2(0,11)); + _tamara = layer->getTileAt(Vec2(0,11)); CCLOG("%p vertexZ: %f", _tamara, _tamara->getPositionZ()); _tamara->retain(); - auto move = MoveBy::create(10, Vector2(400,450) * (1/CC_CONTENT_SCALE_FACTOR())); + auto move = MoveBy::create(10, Vec2(400,450) * (1/CC_CONTENT_SCALE_FACTOR())); auto back = move->reverse(); auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq)); @@ -1206,7 +1206,7 @@ TMXIsoMoveLayer::TMXIsoMoveLayer() auto map = TMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); - map->setPosition(Vector2(-700,-50)); + map->setPosition(Vec2(-700,-50)); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); @@ -1347,7 +1347,7 @@ void TMXOrthoFlipRunTimeTest::flipIt(float dt) auto layer = map->getLayer("Layer 0"); //blue diamond - auto tileCoord = Vector2(1,10); + auto tileCoord = Vec2(1,10); int flags; unsigned int GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags); // Vertical @@ -1358,7 +1358,7 @@ void TMXOrthoFlipRunTimeTest::flipIt(float dt) layer->setTileGID(GID ,tileCoord, (TMXTileFlags)flags); - tileCoord = Vector2(1,8); + tileCoord = Vec2(1,8); GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags); // Vertical if( flags & kTMXTileVerticalFlag ) @@ -1368,7 +1368,7 @@ void TMXOrthoFlipRunTimeTest::flipIt(float dt) layer->setTileGID(GID ,tileCoord, (TMXTileFlags)flags); - tileCoord = Vector2(2,8); + tileCoord = Vec2(2,8); GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags); // Horizontal if( flags & kTMXTileHorizontalFlag ) @@ -1467,9 +1467,9 @@ TMXBug987::TMXBug987() node->getTexture()->setAntiAliasTexParameters(); } - map->setAnchorPoint(Vector2(0, 0)); + map->setAnchorPoint(Vec2(0, 0)); auto layer = map->getLayer("Tile Layer 1"); - layer->setTileGID(3, Vector2(2,2)); + layer->setTileGID(3, Vec2(2,2)); } std::string TMXBug987::title() const @@ -1523,14 +1523,14 @@ TMXGIDObjectsTest::TMXGIDObjectsTest() } -void TMXGIDObjectsTest::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +void TMXGIDObjectsTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) { _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this, transform, transformUpdated); renderer->addCommand(&_renderCmd); } -void TMXGIDObjectsTest::onDraw(const Matrix &transform, bool transformUpdated) +void TMXGIDObjectsTest::onDraw(const Mat4 &transform, bool transformUpdated) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1553,10 +1553,10 @@ void TMXGIDObjectsTest::onDraw(const Matrix &transform, bool transformUpdated) glLineWidth(3); - DrawPrimitives::drawLine(pos + Vector2(x, y), pos + Vector2(x + width, y)); - DrawPrimitives::drawLine(pos + Vector2(x + width, y), pos + Vector2(x + width, y + height)); - DrawPrimitives::drawLine(pos + Vector2(x + width,y + height), pos + Vector2(x,y + height)); - DrawPrimitives::drawLine(pos + Vector2(x,y + height), pos + Vector2(x,y)); + DrawPrimitives::drawLine(pos + Vec2(x, y), pos + Vec2(x + width, y)); + DrawPrimitives::drawLine(pos + Vec2(x + width, y), pos + Vec2(x + width, y + height)); + DrawPrimitives::drawLine(pos + Vec2(x + width,y + height), pos + Vec2(x,y + height)); + DrawPrimitives::drawLine(pos + Vec2(x,y + height), pos + Vec2(x,y)); glLineWidth(1); } diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h index 6c886af030..be8f3ec5ab 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h @@ -134,11 +134,11 @@ public: TMXOrthoObjectsTest(void); virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); }; class TMXIsoObjectsTest : public TileDemo @@ -147,11 +147,11 @@ public: TMXIsoObjectsTest(void); virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); }; class TMXResizeTest : public TileDemo @@ -292,11 +292,11 @@ public: TMXGIDObjectsTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; protected: CustomCommand _renderCmd; - void onDraw(const Matrix &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, bool transformUpdated); }; diff --git a/tests/cpp-tests/Classes/TouchesTest/Ball.cpp b/tests/cpp-tests/Classes/TouchesTest/Ball.cpp index bb827430cc..6dddfc50f0 100644 --- a/tests/cpp-tests/Classes/TouchesTest/Ball.cpp +++ b/tests/cpp-tests/Classes/TouchesTest/Ball.cpp @@ -30,12 +30,12 @@ void Ball::move(float delta) if (getPosition().x > VisibleRect::right().x - radius()) { - setPosition( Vector2( VisibleRect::right().x - radius(), getPosition().y) ); + setPosition( Vec2( VisibleRect::right().x - radius(), getPosition().y) ); _velocity.x *= -1; } else if (getPosition().x < VisibleRect::left().x + radius()) { - setPosition( Vector2(VisibleRect::left().x + radius(), getPosition().y) ); + setPosition( Vec2(VisibleRect::left().x + radius(), getPosition().y) ); _velocity.x *= -1; } } @@ -60,13 +60,13 @@ void Ball::collideWithPaddle(Paddle* paddle) if (getPosition().y > midY && getPosition().y <= highY + radius()) { - setPosition( Vector2(getPosition().x, highY + radius()) ); + setPosition( Vec2(getPosition().x, highY + radius()) ); hit = true; angleOffset = (float)M_PI / 2; } else if (getPosition().y < midY && getPosition().y >= lowY - radius()) { - setPosition( Vector2(getPosition().x, lowY - radius()) ); + setPosition( Vec2(getPosition().x, lowY - radius()) ); hit = true; angleOffset = -(float)M_PI / 2; } @@ -78,7 +78,7 @@ void Ball::collideWithPaddle(Paddle* paddle) float scalarVelocity = _velocity.getLength() * 1.05f; float velocityAngle = -_velocity.getAngle() + 0.5f * hitAngle; - _velocity = Vector2::forAngle(velocityAngle) * scalarVelocity; + _velocity = Vec2::forAngle(velocityAngle) * scalarVelocity; } } } diff --git a/tests/cpp-tests/Classes/TouchesTest/Ball.h b/tests/cpp-tests/Classes/TouchesTest/Ball.h index 1f95ff75ee..18356e4315 100644 --- a/tests/cpp-tests/Classes/TouchesTest/Ball.h +++ b/tests/cpp-tests/Classes/TouchesTest/Ball.h @@ -9,7 +9,7 @@ USING_NS_CC; class Ball : public Sprite { - Vector2 _velocity; + Vec2 _velocity; public: Ball(void); virtual ~Ball(void); @@ -22,8 +22,8 @@ public: public: - void setVelocity(Vector2 velocity){_velocity = velocity;} - Vector2 getVelocity(){return _velocity;} + void setVelocity(Vec2 velocity){_velocity = velocity;} + Vec2 getVelocity(){return _velocity;} public: static Ball* ballWithTexture(Texture2D* aTexture); diff --git a/tests/cpp-tests/Classes/TouchesTest/Paddle.cpp b/tests/cpp-tests/Classes/TouchesTest/Paddle.cpp index 9abd3ae98e..b173580d75 100644 --- a/tests/cpp-tests/Classes/TouchesTest/Paddle.cpp +++ b/tests/cpp-tests/Classes/TouchesTest/Paddle.cpp @@ -87,7 +87,7 @@ void Paddle::onTouchMoved(Touch* touch, Event* event) auto touchPoint = touch->getLocation(); - setPosition( Vector2(touchPoint.x, getPosition().y) ); + setPosition( Vec2(touchPoint.x, getPosition().y) ); } Paddle* Paddle::clone() const diff --git a/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp b/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp index 526ab86056..a752f6d8c8 100644 --- a/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp +++ b/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp @@ -37,7 +37,7 @@ PongScene::PongScene() //------------------------------------------------------------------ PongLayer::PongLayer() { - _ballStartingVelocity = Vector2(20.0f, -100.0f); + _ballStartingVelocity = Vec2(20.0f, -100.0f); _ball = Ball::ballWithTexture( Director::getInstance()->getTextureCache()->addImage(s_Ball) ); _ball->setPosition( VisibleRect::center() ); @@ -49,19 +49,19 @@ PongLayer::PongLayer() Vector paddlesM(4); Paddle* paddle = Paddle::createWithTexture(paddleTexture); - paddle->setPosition( Vector2(VisibleRect::center().x, VisibleRect::bottom().y + 15) ); + paddle->setPosition( Vec2(VisibleRect::center().x, VisibleRect::bottom().y + 15) ); paddlesM.pushBack( paddle ); paddle = Paddle::createWithTexture( paddleTexture ); - paddle->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 15) ); + paddle->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 15) ); paddlesM.pushBack( paddle ); paddle = Paddle::createWithTexture( paddleTexture ); - paddle->setPosition( Vector2(VisibleRect::center().x, VisibleRect::bottom().y + 100) ); + paddle->setPosition( Vec2(VisibleRect::center().x, VisibleRect::bottom().y + 100) ); paddlesM.pushBack( paddle ); paddle = Paddle::createWithTexture( paddleTexture ); - paddle->setPosition( Vector2(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 100) ); + paddle->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 100) ); paddlesM.pushBack( paddle ); _paddles = paddlesM; diff --git a/tests/cpp-tests/Classes/TouchesTest/TouchesTest.h b/tests/cpp-tests/Classes/TouchesTest/TouchesTest.h index bca0f1d393..873ced2c58 100644 --- a/tests/cpp-tests/Classes/TouchesTest/TouchesTest.h +++ b/tests/cpp-tests/Classes/TouchesTest/TouchesTest.h @@ -21,7 +21,7 @@ class PongLayer : public Layer private: Ball* _ball; Vector _paddles; - Vector2 _ballStartingVelocity; + Vec2 _ballStartingVelocity; public: PongLayer(); ~PongLayer(); diff --git a/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp b/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp index 6050745eb9..5091bc29a5 100644 --- a/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp +++ b/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp @@ -262,17 +262,17 @@ TestLayer1::TestLayer1(void) y = size.height; auto bg1 = Sprite::create(s_back1); - bg1->setPosition( Vector2(size.width/2, size.height/2) ); + bg1->setPosition( Vec2(size.width/2, size.height/2) ); addChild(bg1, -1); auto title = Label::createWithTTF( (transitions[s_nSceneIdx]).name, "fonts/Thonburi.ttf", 32 ); addChild(title); title->setColor( Color3B(255,32,32) ); - title->setPosition( Vector2(x/2, y-100) ); + title->setPosition( Vec2(x/2, y-100) ); auto label = Label::createWithTTF("SCENE 1", "fonts/Marker Felt.ttf", 38); label->setColor( Color3B(16,16,255)); - label->setPosition( Vector2(x/2,y/2)); + label->setPosition( Vec2(x/2,y/2)); addChild( label); // menu @@ -282,10 +282,10 @@ TestLayer1::TestLayer1(void) auto menu = Menu::create(item1, item2, item3, NULL); - menu->setPosition( Vector2::ZERO ); - item1->setPosition(Vector2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vector2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + menu->setPosition( Vec2::ZERO ); + item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 1); @@ -392,17 +392,17 @@ TestLayer2::TestLayer2() y = size.height; auto bg1 = Sprite::create(s_back2); - bg1->setPosition( Vector2(size.width/2, size.height/2) ); + bg1->setPosition( Vec2(size.width/2, size.height/2) ); addChild(bg1, -1); auto title = Label::createWithTTF((transitions[s_nSceneIdx]).name, "fonts/Thonburi.ttf", 32 ); addChild(title); title->setColor( Color3B(255,32,32) ); - title->setPosition( Vector2(x/2, y-100) ); + title->setPosition( Vec2(x/2, y-100) ); auto label = Label::createWithTTF("SCENE 2", "fonts/Marker Felt.ttf", 38); label->setColor( Color3B(16,16,255)); - label->setPosition( Vector2(x/2,y/2)); + label->setPosition( Vec2(x/2,y/2)); addChild( label); // menu @@ -412,10 +412,10 @@ TestLayer2::TestLayer2() auto menu = Menu::create(item1, item2, item3, NULL); - menu->setPosition( Vector2::ZERO ); - item1->setPosition(Vector2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vector2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vector2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + menu->setPosition( Vec2::ZERO ); + item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); + item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 1); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp index 1a2a14b52e..8b4538ea94 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp @@ -58,7 +58,7 @@ static const int g_maxTests = sizeof(g_guisTests) / sizeof(g_guisTests[0]); // //////////////////////////////////////////////////////// -static Vector2 _curPos = Vector2::ZERO; +static Vec2 _curPos = Vec2::ZERO; void CocoStudioGUIMainLayer::onEnter() { @@ -69,13 +69,13 @@ void CocoStudioGUIMainLayer::onEnter() Size s = Director::getInstance()->getWinSize(); _itemMenu = CCMenu::create(); - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); CCMenuItemFont::setFontName("fonts/arial.ttf"); CCMenuItemFont::setFontSize(24); for (int i = 0; i < g_maxTests; ++i) { auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback); - pItem->setPosition(Vector2(s.width / 2, s.height / 4 * 3 - (i + 1) * LINE_SPACE)); + pItem->setPosition(Vec2(s.width / 2, s.height / 4 * 3 - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -111,8 +111,8 @@ void CocoStudioGUITestScene::onEnter() Menu* pMenu = Menu::create(pMenuItem, NULL); - pMenu->setPosition( Vector2::ZERO ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + pMenu->setPosition( Vec2::ZERO ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(pMenu, 1); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.h index 4c0bcb4fc3..88ae14ef3d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.h @@ -13,7 +13,7 @@ public: // void onTouchesMoved(const std::vector& touches, Event *event); private: - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 708adbc641..4575ca7505 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -228,7 +228,7 @@ g_guisTests[] = static const int g_maxTests = sizeof(g_guisTests) / sizeof(g_guisTests[0]); -static Vector2 s_tCurPos = Vector2::ZERO; +static Vec2 s_tCurPos = Vec2::ZERO; //////////////////////////////////////////////////////// // @@ -248,7 +248,7 @@ void CocosGUITestMainLayer::onEnter() for (int i = 0; i < g_maxTests; ++i) { auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback); - pItem->setPosition(Vector2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); + pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -276,17 +276,17 @@ void CocosGUITestMainLayer::onTouchesMoved(const std::vector& touches, E float nMoveY = touchLocation.y - _beginPos.y; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } @@ -311,8 +311,8 @@ void CocosGUITestScene::onEnter() Menu* pMenu =Menu::create(pMenuItem, NULL); - pMenu->setPosition( Vector2::ZERO ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + pMenu->setPosition( Vec2::ZERO ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(pMenu, 1); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.h index 2c9d57ccde..c8dd312d8e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.h @@ -42,7 +42,7 @@ public: void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; int _testcount; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp index 95a1c5c73a..ab993ab32f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp @@ -47,7 +47,7 @@ static const int g_maxTests = sizeof(g_guisTests) / sizeof(g_guisTests[0]); // //////////////////////////////////////////////////////// -static Vector2 _curPos = Vector2::ZERO; +static Vec2 _curPos = Vec2::ZERO; void CustomGUITestMainLayer::onEnter() @@ -63,8 +63,8 @@ void CustomGUITestMainLayer::onEnter() for (int i = 0; i < g_maxTests; ++i) { auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback); -// pItem->setPosition(Vector2(s.width / 2, s.height / 2)); - pItem->setPosition(Vector2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); +// pItem->setPosition(Vec2(s.width / 2, s.height / 2)); + pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -93,8 +93,8 @@ void CustomGUITestMainLayer::onTouchesMoved(const std::vector &touches, float nMoveY = touchLocation.y - _beginPos.y; - Vector2 curPos = _itemMenu->getPosition(); - Vector2 nextPos = ccp(curPos.x, curPos.y + nMoveY); + Vec2 curPos = _itemMenu->getPosition(); + Vec2 nextPos = ccp(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { @@ -124,8 +124,8 @@ void CustomGUITestScene::onEnter() Menu* pMenu = Menu::create(pMenuItem, NULL); - pMenu->setPosition( Vector2::ZERO ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + pMenu->setPosition( Vec2::ZERO ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(pMenu, 1); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h index b685b6b1d5..366f5f24d8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h @@ -22,7 +22,7 @@ public: void touchEvent(Ref* pSender, Widget::TouchEventType type); private: - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp index e1428bf3d0..0bd735b7b4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp @@ -42,8 +42,8 @@ void CustomImageScene::onEnter() Menu* pMenu = Menu::create(pMenuItem, NULL); - pMenu->setPosition( Vector2::ZERO ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + pMenu->setPosition( Vec2::ZERO ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(pMenu, 1); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp index 75a40bef2b..ea7463c809 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp @@ -56,8 +56,8 @@ void CustomParticleWidgetScene::onEnter() Menu* pMenu = Menu::create(pMenuItem, NULL); - pMenu->setPosition( Vector2::ZERO ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + pMenu->setPosition( Vec2::ZERO ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(pMenu, 1); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp index ede108fd62..cfc0dee635 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp @@ -82,14 +82,14 @@ const char* CustomParticleWidget::getParticlePlist() const return _emitterPlist; } -void CustomParticleWidget::setParticlePosition(const Vector2 &pos) +void CustomParticleWidget::setParticlePosition(const Vec2 &pos) { _emitter->setPosition(pos); _emitterPostion = pos; } -const Vector2& CustomParticleWidget::getParticlePosition() const +const Vec2& CustomParticleWidget::getParticlePosition() const { return _emitterPostion; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h index 22e2f9047f..1714e04a8a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h @@ -24,8 +24,8 @@ public: void setParticlePlist(const char* plist); const char* getParticlePlist() const; - void setParticlePosition(const cocos2d::Vector2& pos); - const cocos2d::Vector2& getParticlePosition() const; + void setParticlePosition(const cocos2d::Vec2& pos); + const cocos2d::Vec2& getParticlePosition() const; void playParticle(); @@ -40,7 +40,7 @@ protected: protected: cocos2d::ParticleSystem* _emitter; const char* _emitterPlist; - cocos2d::Vector2 _emitterPostion; + cocos2d::Vec2 _emitterPostion; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp index 07ce30fe5d..3eaef33bb4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp @@ -256,7 +256,7 @@ g_guisTests[] = static const int g_maxTests = sizeof(g_guisTests) / sizeof(g_guisTests[0]); -static Vector2 s_tCurPos = Vector2::ZERO; +static Vec2 s_tCurPos = Vec2::ZERO; //////////////////////////////////////////////////////// // @@ -276,7 +276,7 @@ void GUIEditorMainLayer::onEnter() for (int i = 0; i < g_maxTests; ++i) { auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback); - pItem->setPosition(Vector2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); + pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -304,17 +304,17 @@ void GUIEditorMainLayer::onTouchesMoved(const std::vector& touches, Even float nMoveY = touchLocation.y - _beginPos.y; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } @@ -339,8 +339,8 @@ void GUIEditorTestScene::onEnter() Menu* pMenu =CCMenu::create(pMenuItem, nullptr); - pMenu->setPosition( Vector2::ZERO ); - pMenuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + pMenu->setPosition( Vec2::ZERO ); + pMenuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(pMenu, 1); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.h index 7a6e6a2d7c..48fa4a31cb 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/GUIEditorTest.h @@ -13,7 +13,7 @@ public: void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); private: - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; int _testcount; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 51904b8368..9e4d5f9bef 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -22,15 +22,15 @@ bool UIButtonTest::init() // Add a label in which the button events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("Button","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); @@ -38,7 +38,7 @@ bool UIButtonTest::init() // Create the button Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); // button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent)); button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest::touchEvent, this)); _uiLayer->addChild(button); @@ -94,14 +94,14 @@ bool UIButtonTest_Scale9::init() // Add a label in which the button events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("Button scale9 render", "fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); @@ -109,7 +109,7 @@ bool UIButtonTest_Scale9::init() Button* button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); // open scale9 render button->setScale9Enabled(true); - button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); button->setSize(Size(150, 70)); // button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent)); button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9::touchEvent, this)); @@ -163,15 +163,15 @@ bool UIButtonTest_PressedAction::init() // Add a label in which the button events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("Button Pressed Action", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); @@ -179,7 +179,7 @@ bool UIButtonTest_PressedAction::init() // Create the button Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); button->setPressedActionEnabled(true); - button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); // button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent)); button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_PressedAction::touchEvent, this)); _uiLayer->addChild(button); @@ -233,14 +233,14 @@ bool UIButtonTest_Title::init() // Add a label in which the text button events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("Button with title", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); @@ -248,7 +248,7 @@ bool UIButtonTest_Title::init() // Create the button with title Button* button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); button->setTitleText("Title Button"); - button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); // button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent)); button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Title::touchEvent, this)); _uiLayer->addChild(button); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp index 73c41acc5d..92f99b224d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp @@ -24,7 +24,7 @@ bool UIButtonTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -51,7 +51,7 @@ bool UIButtonTest_Editor::init() _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); _displayValueLabel->setFontSize(30); _displayValueLabel->setString("No event"); - _displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2, + _displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2, _layout->getSize().height - _displayValueLabel->getSize().height * 1.75f)); _touchGroup->addChild(_displayValueLabel); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index a91cce09f5..a8741a1ae8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -22,14 +22,14 @@ bool UICheckBoxTest::init() // Add a label in which the checkbox events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("CheckBox","fonts/Marker Felt.ttf",30 ); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the checkbox @@ -38,7 +38,7 @@ bool UICheckBoxTest::init() "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); - checkBox->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this)); _uiLayer->addChild(checkBox); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp index 283105c988..5ea65d689a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp @@ -24,7 +24,7 @@ bool UICheckBoxTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -41,7 +41,7 @@ bool UICheckBoxTest_Editor::init() _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); _displayValueLabel->setFontSize(30); _displayValueLabel->setString("No event"); - _displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2, + _displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2, _layout->getSize().height - _displayValueLabel->getSize().height * 1.75f)); _touchGroup->addChild(_displayValueLabel); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp index 585c4f39e6..5cf01a629c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp @@ -30,23 +30,23 @@ bool UIFocusTestBase::init() auto winSize = Director::getInstance()->getVisibleSize(); auto leftItem = MenuItemFont::create("Left", CC_CALLBACK_0(UIFocusTestBase::onLeftKeyPressed, this)); - leftItem->setPosition(Vector2(winSize.width - 100, winSize.height/2)); + leftItem->setPosition(Vec2(winSize.width - 100, winSize.height/2)); _dpadMenu->addChild(leftItem); auto rightItem = MenuItemFont::create("Right", CC_CALLBACK_0(UIFocusTestBase::onRightKeyPressed, this)); - rightItem->setPosition(Vector2(winSize.width - 30, winSize.height/2)); + rightItem->setPosition(Vec2(winSize.width - 30, winSize.height/2)); _dpadMenu->addChild(rightItem); auto upItem = MenuItemFont::create("Up", CC_CALLBACK_0(UIFocusTestBase::onUpKeyPressed, this)); - upItem->setPosition(Vector2(winSize.width - 60, winSize.height/2 + 50)); + upItem->setPosition(Vec2(winSize.width - 60, winSize.height/2 + 50)); _dpadMenu->addChild(upItem); auto downItem = MenuItemFont::create("Down", CC_CALLBACK_0(UIFocusTestBase::onDownKeyPressed, this)); - downItem->setPosition(Vector2(winSize.width - 60, winSize.height/2 - 50)); + downItem->setPosition(Vec2(winSize.width - 60, winSize.height/2 - 50)); _dpadMenu->addChild(downItem); - _dpadMenu->setPosition(Vector2::ZERO); + _dpadMenu->setPosition(Vec2::ZERO); _uiLayer->addChild(_dpadMenu); _eventListener = EventListenerFocus::create(); @@ -153,7 +153,7 @@ bool UIFocusTestHorizontal::init() Size winSize = Director::getInstance()->getVisibleSize(); _horizontalLayout = HBox::create(); - _horizontalLayout->setPosition(Vector2(20, winSize.height/2 + 40)); + _horizontalLayout->setPosition(Vec2(20, winSize.height/2 + 40)); _uiLayer->addChild(_horizontalLayout); _horizontalLayout->setFocused(true); @@ -171,13 +171,13 @@ bool UIFocusTestHorizontal::init() } _loopText = Text::create("loop enabled", "Airal", 20); - _loopText->setPosition(Vector2(winSize.width/2, winSize.height - 50)); + _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50)); _loopText->setColor(Color3B::GREEN); this->addChild(_loopText); auto btn = Button::create("cocosui/switch-mask.png"); btn->setTitleText("Toggle Loop"); - btn->setPosition(Vector2(60, winSize.height - 50)); + btn->setPosition(Vec2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestHorizontal::toggleFocusLoop,this)); this->addChild(btn); @@ -222,7 +222,7 @@ bool UIFocusTestVertical::init() Size winSize = Director::getInstance()->getVisibleSize(); _verticalLayout = VBox::create(); - _verticalLayout->setPosition(Vector2(winSize.width/2 - 100, winSize.height - 70)); + _verticalLayout->setPosition(Vec2(winSize.width/2 - 100, winSize.height - 70)); _uiLayer->addChild(_verticalLayout); _verticalLayout->setTag(100); _verticalLayout->setScale(0.5); @@ -244,13 +244,13 @@ bool UIFocusTestVertical::init() } _loopText = Text::create("loop enabled", "Airal", 20); - _loopText->setPosition(Vector2(winSize.width/2, winSize.height - 50)); + _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50)); _loopText->setColor(Color3B::GREEN); this->addChild(_loopText); auto btn = Button::create("cocosui/switch-mask.png"); btn->setTitleText("Toggle Loop"); - btn->setPosition(Vector2(60, winSize.height - 50)); + btn->setPosition(Vec2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestVertical::toggleFocusLoop, this)); this->addChild(btn); @@ -292,7 +292,7 @@ bool UIFocusTestNestedLayout1::init() Size winSize = Director::getInstance()->getVisibleSize(); _verticalLayout = VBox::create(); - _verticalLayout->setPosition(Vector2(winSize.width/2 - 80, winSize.height - 70)); + _verticalLayout->setPosition(Vec2(winSize.width/2 - 80, winSize.height - 70)); _uiLayer->addChild(_verticalLayout); _verticalLayout->setScale(0.5); @@ -304,7 +304,7 @@ bool UIFocusTestNestedLayout1::init() int count1 = 1; for (int i=0; isetAnchorPoint(Vector2::ZERO); + w->setAnchorPoint(Vec2::ZERO); w->setTouchEnabled(true); w->setScaleX(2.5); w->setTag(i+count1); @@ -321,7 +321,7 @@ bool UIFocusTestNestedLayout1::init() int count2 = 2; for (int i=0; i < count2; ++i) { ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); - w->setAnchorPoint(Vector2(0,1)); + w->setAnchorPoint(Vec2(0,1)); w->setScaleY(2.0); w->setTouchEnabled(true); w->setTag(i+count1+count2); @@ -346,13 +346,13 @@ bool UIFocusTestNestedLayout1::init() } _loopText = Text::create("loop enabled", "Airal", 20); - _loopText->setPosition(Vector2(winSize.width/2, winSize.height - 50)); + _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50)); _loopText->setColor(Color3B::GREEN); this->addChild(_loopText); auto btn = Button::create("cocosui/switch-mask.png"); btn->setTitleText("Toggle Loop"); - btn->setPosition(Vector2(60, winSize.height - 50)); + btn->setPosition(Vec2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::toggleFocusLoop, this)); this->addChild(btn); @@ -394,7 +394,7 @@ bool UIFocusTestNestedLayout2::init() Size winSize = Director::getInstance()->getVisibleSize(); _horizontalLayout = HBox::create(); - _horizontalLayout->setPosition(Vector2(winSize.width/2 - 200, winSize.height - 70)); + _horizontalLayout->setPosition(Vec2(winSize.width/2 - 200, winSize.height - 70)); _uiLayer->addChild(_horizontalLayout); _horizontalLayout->setScale(0.6); @@ -406,7 +406,7 @@ bool UIFocusTestNestedLayout2::init() int count1 = 2; for (int i=0; isetAnchorPoint(Vector2(0,1)); + w->setAnchorPoint(Vec2(0,1)); w->setTouchEnabled(true); w->setTag(i+count1); w->setScaleY(2.4); @@ -423,7 +423,7 @@ bool UIFocusTestNestedLayout2::init() int count2 = 2; for (int i=0; i < count2; ++i) { ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); - w->setAnchorPoint(Vector2(0,1)); + w->setAnchorPoint(Vec2(0,1)); w->setScaleX(2.0); w->setTouchEnabled(true); w->setTag(i+count1+count2); @@ -448,13 +448,13 @@ bool UIFocusTestNestedLayout2::init() } _loopText = Text::create("loop enabled", "Airal", 20); - _loopText->setPosition(Vector2(winSize.width/2, winSize.height - 50)); + _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50)); _loopText->setColor(Color3B::GREEN); this->addChild(_loopText); auto btn = Button::create("cocosui/switch-mask.png"); btn->setTitleText("Toggle Loop"); - btn->setPosition(Vector2(60, winSize.height - 50)); + btn->setPosition(Vec2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::toggleFocusLoop, this)); this->addChild(btn); @@ -496,7 +496,7 @@ bool UIFocusTestNestedLayout3::init() Size winSize = Director::getInstance()->getVisibleSize(); _verticalLayout = VBox::create(); - _verticalLayout->setPosition(Vector2(40, winSize.height - 70)); + _verticalLayout->setPosition(Vec2(40, winSize.height - 70)); _uiLayer->addChild(_verticalLayout); _verticalLayout->setScale(0.8); @@ -558,13 +558,13 @@ bool UIFocusTestNestedLayout3::init() _loopText = Text::create("loop enabled", "Airal", 20); - _loopText->setPosition(Vector2(winSize.width/2, winSize.height - 50)); + _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50)); _loopText->setColor(Color3B::GREEN); this->addChild(_loopText); auto btn = Button::create("cocosui/switch-mask.png"); btn->setTitleText("Toggle Loop"); - btn->setPosition(Vector2(60, winSize.height - 50)); + btn->setPosition(Vec2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout3::toggleFocusLoop, this)); this->addChild(btn); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index b5ac88cc59..57159b104a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -13,14 +13,14 @@ bool UIImageViewTest::init() Text* alert = Text::create("ImageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the imageview ImageView* imageView = ImageView::create("cocosui/ccicon.png"); - imageView->setPosition(Vector2(widgetSize.width / 2.0f, + imageView->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(imageView); @@ -43,7 +43,7 @@ bool UIImageViewTest_Scale9::init() Text* alert = Text::create("ImageView scale9 render", "fonts/Marker Felt.ttf", 26); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f)); _uiLayer->addChild(alert); @@ -52,7 +52,7 @@ bool UIImageViewTest_Scale9::init() ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png"); imageView->setScale9Enabled(true); imageView->setSize(Size(300, 115)); - imageView->setPosition(Vector2(widgetSize.width / 2.0f, + imageView->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(imageView); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp index c0cf97ad2e..c0e9f0ba16 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp @@ -13,7 +13,7 @@ bool UIImageViewTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 9d0d26090e..3f84b98642 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -22,7 +22,7 @@ bool UILayoutTest::init() // Add the alert Text* alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 ); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); @@ -35,26 +35,26 @@ bool UILayoutTest::init() Layout* layout = Layout::create(); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); _uiLayer->addChild(layout); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(button->getSize().width / 2.0f, + button->setPosition(Vec2(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f)); layout->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f, + button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); layout->addChild(button_scale9); @@ -84,7 +84,7 @@ bool UILayoutTest_Color::init() // Add the alert Text* alert = Text::create("Layout color render", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); @@ -99,27 +99,27 @@ bool UILayoutTest_Color::init() layout->setBackGroundColor(Color3B(128, 128, 128)); layout->setSize(Size(280, 150)); Size backgroundSize = background->getContentSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); _uiLayer->addChild(layout); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(button->getSize().width / 2.0f, + button->setPosition(Vec2(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f)); layout->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f, + button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); layout->addChild(button_scale9); @@ -148,7 +148,7 @@ bool UILayoutTest_Gradient::init() // Add the alert Text* alert = Text::create("Layout gradient render", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); @@ -163,27 +163,27 @@ bool UILayoutTest_Gradient::init() layout->setBackGroundColor(Color3B(64, 64, 64), Color3B(192, 192, 192)); layout->setSize(Size(280, 150)); Size backgroundSize = background->getContentSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); _uiLayer->addChild(layout); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(button->getSize().width / 2.0f, + button->setPosition(Vec2(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f)); layout->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f, + button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); layout->addChild(button_scale9); @@ -212,7 +212,7 @@ bool UILayoutTest_BackGroundImage::init() // Add the alert Text* alert = Text::create("Layout background image", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -225,26 +225,26 @@ bool UILayoutTest_BackGroundImage::init() layout->setBackGroundImage("cocosui/Hello.png"); layout->setSize(Size(280, 150)); Size backgroundSize = background->getContentSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); _uiLayer->addChild(layout); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(button->getSize().width / 2.0f, + button->setPosition(Vec2(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f)); layout->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f, + button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); layout->addChild(button_scale9); @@ -273,7 +273,7 @@ bool UILayoutTest_BackGroundImage_Scale9::init() // Add the alert Text* alert = Text::create("Layout background image scale9", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -286,27 +286,27 @@ bool UILayoutTest_BackGroundImage_Scale9::init() layout->setBackGroundImage("cocosui/green_edit.png"); layout->setSize(Size(280, 150)); Size backgroundSize = background->getContentSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); _uiLayer->addChild(layout); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(button->getSize().width / 2.0f, + button->setPosition(Vec2(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f)); layout->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f, + button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); layout->addChild(button_scale9); @@ -334,7 +334,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() // Add the alert Text* alert = Text::create("Layout Linear Vertical", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); _uiLayer->addChild(alert); @@ -348,7 +348,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() layout->setLayoutType(LayoutType::VERTICAL); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); @@ -410,7 +410,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() // Add the alert Text* alert = Text::create("Layout Linear Horizontal", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -423,7 +423,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() layout->setClippingEnabled(true); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); @@ -484,7 +484,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() // Add the alert Text* alert = Text::create("Layout Relative Align Parent", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -498,7 +498,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID); layout->setBackGroundColor(Color3B::GREEN); Size backgroundSize = background->getSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); @@ -619,7 +619,7 @@ bool UILayoutTest_Layout_Relative_Location::init() // Add the alert Text* alert = Text::create("Layout Relative Location", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -631,7 +631,7 @@ bool UILayoutTest_Layout_Relative_Location::init() layout->setLayoutType(LayoutType::RELATIVE); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); - layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - layout->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - layout->getSize().height) / 2.0f)); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp index 73bb29be55..792ed2b36a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp @@ -23,7 +23,7 @@ bool UILayoutTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -35,7 +35,7 @@ bool UILayoutTest_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -44,7 +44,7 @@ bool UILayoutTest_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -78,7 +78,7 @@ bool UILayoutTest_Color_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -90,7 +90,7 @@ bool UILayoutTest_Color_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -99,7 +99,7 @@ bool UILayoutTest_Color_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -133,7 +133,7 @@ bool UILayoutTest_Gradient_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -145,7 +145,7 @@ bool UILayoutTest_Gradient_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -154,7 +154,7 @@ bool UILayoutTest_Gradient_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -188,7 +188,7 @@ bool UILayoutTest_BackGroundImage_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -200,7 +200,7 @@ bool UILayoutTest_BackGroundImage_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -209,7 +209,7 @@ bool UILayoutTest_BackGroundImage_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -243,7 +243,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -255,7 +255,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -264,7 +264,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -298,7 +298,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -310,7 +310,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -319,7 +319,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -353,7 +353,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -365,7 +365,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -374,7 +374,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -409,7 +409,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -421,7 +421,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -430,7 +430,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -464,7 +464,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -476,7 +476,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -485,7 +485,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index 7420215b41..f99d14485e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -25,15 +25,15 @@ bool UIListViewTest_Vertical::init() Size widgetSize = _widget->getSize(); _displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); Text* alert = Text::create("ListView vertical", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); @@ -62,7 +62,7 @@ bool UIListViewTest_Vertical::init() listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); listView->setSize(Size(240, 130)); - listView->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getSize().height) / 2.0f)); @@ -77,7 +77,7 @@ bool UIListViewTest_Vertical::init() Layout* default_item = Layout::create(); default_item->setTouchEnabled(true); default_item->setSize(default_button->getSize()); - default_button->setPosition(Vector2(default_item->getSize().width / 2.0f, + default_button->setPosition(Vec2(default_item->getSize().width / 2.0f, default_item->getSize().height / 2.0f)); default_item->addChild(default_button); @@ -106,7 +106,7 @@ bool UIListViewTest_Vertical::init() Layout *custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); - custom_button->setPosition(Vector2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); + custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->pushBackCustomItem(custom_item); @@ -123,7 +123,7 @@ bool UIListViewTest_Vertical::init() Layout *custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); - custom_button->setPosition(Vector2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); + custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->insertCustomItem(custom_item, items_count); @@ -201,8 +201,8 @@ bool UIListViewTest_Horizontal::init() Size widgetSize = _widget->getSize(); _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); @@ -211,7 +211,7 @@ bool UIListViewTest_Horizontal::init() Text* alert = Text::create("ListView horizontal", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -239,7 +239,7 @@ bool UIListViewTest_Horizontal::init() listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); listView->setSize(Size(240, 130)); - listView->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getSize().height) / 2.0f)); @@ -254,7 +254,7 @@ bool UIListViewTest_Horizontal::init() Layout *default_item = Layout::create(); default_item->setTouchEnabled(true); default_item->setSize(default_button->getSize()); - default_button->setPosition(Vector2(default_item->getSize().width / 2.0f, default_item->getSize().height / 2.0f)); + default_button->setPosition(Vec2(default_item->getSize().width / 2.0f, default_item->getSize().height / 2.0f)); default_item->addChild(default_button); // set model @@ -282,7 +282,7 @@ bool UIListViewTest_Horizontal::init() Layout* custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); - custom_button->setPosition(Vector2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); + custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->pushBackCustomItem(custom_item); @@ -299,7 +299,7 @@ bool UIListViewTest_Horizontal::init() Layout* custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); - custom_button->setPosition(Vector2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); + custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->insertCustomItem(custom_item, items_count); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp index a1ac86f748..15f5f5567a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp @@ -23,7 +23,7 @@ bool UIListViewTest_Vertical_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -38,7 +38,7 @@ bool UIListViewTest_Vertical_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this)); @@ -49,7 +49,7 @@ bool UIListViewTest_Vertical_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -84,7 +84,7 @@ bool UIListViewTest_Horizontal_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -96,7 +96,7 @@ bool UIListViewTest_Horizontal_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this)); @@ -105,7 +105,7 @@ bool UIListViewTest_Horizontal_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 7722f2e3b5..97fe852f1e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -27,13 +27,13 @@ bool UILoadingBarTest_Left::init() // Add the alert Text* alert = Text::create("LoadingBar left", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the loading bar LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png"); loadingBar->setTag(0); - loadingBar->setPosition(Vector2(widgetSize.width / 2.0f, + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); _uiLayer->addChild(loadingBar); @@ -105,7 +105,7 @@ bool UILoadingBarTest_Right::init() // Add the alert Text *alert = Text::create("LoadingBar right", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the loading bar @@ -113,7 +113,7 @@ bool UILoadingBarTest_Right::init() loadingBar->setTag(0); loadingBar->setDirection(LoadingBar::Direction::RIGHT); - loadingBar->setPosition(Vector2(widgetSize.width / 2.0f, + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); _uiLayer->addChild(loadingBar); @@ -185,7 +185,7 @@ bool UILoadingBarTest_Left_Scale9::init() // Add the alert Text* alert = Text::create("LoadingBar left scale9 render", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f)); _uiLayer->addChild(alert); // Create the loading bar @@ -195,7 +195,7 @@ bool UILoadingBarTest_Left_Scale9::init() loadingBar->setCapInsets(Rect(0, 0, 0, 0)); loadingBar->setSize(Size(300, 13)); - loadingBar->setPosition(Vector2(widgetSize.width / 2.0f, + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); _uiLayer->addChild(loadingBar); @@ -267,7 +267,7 @@ bool UILoadingBarTest_Right_Scale9::init() // Add the alert Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f)); _uiLayer->addChild(alert); // Create the loading bar @@ -278,7 +278,7 @@ bool UILoadingBarTest_Right_Scale9::init() loadingBar->setSize(Size(300, 13)); loadingBar->setDirection(LoadingBar::Direction::RIGHT); - loadingBar->setPosition(Vector2(widgetSize.width / 2.0f, + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); _uiLayer->addChild(loadingBar); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp index 7e5b0e9d75..63c0c15386 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp @@ -25,7 +25,7 @@ bool UILoadingBarTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 6fa60775b1..55364c7fbb 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -22,8 +22,8 @@ bool UIPageViewTest::init() // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); @@ -31,7 +31,7 @@ bool UIPageViewTest::init() // Add the black background Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -42,7 +42,7 @@ bool UIPageViewTest::init() PageView* pageView = PageView::create(); pageView->setSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); - pageView->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - pageView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getSize().height) / 2.0f)); @@ -55,12 +55,12 @@ bool UIPageViewTest::init() ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); imageView->setSize(Size(240, 130)); - imageView->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + imageView->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(imageView); Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); - label->setPosition(Vector2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); + label->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(label); pageView->addPage(layout); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp index 2e672da0ed..cec0c535f9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp @@ -24,7 +24,7 @@ bool UIPageViewTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -36,7 +36,7 @@ bool UIPageViewTest_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -45,7 +45,7 @@ bool UIPageViewTest_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp index c2de04c2ba..455dd43d4d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp @@ -23,14 +23,14 @@ bool UIRichTextTest::init() // Add the alert Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.125)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.125)); _widget->addChild(alert); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); button->setTouchEnabled(true); button->setTitleText("switch"); - button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5)); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5)); // button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent)); button->addTouchEventListener(CC_CALLBACK_2(UIRichTextTest::touchEvent, this)); button->setLocalZOrder(10); @@ -65,7 +65,7 @@ bool UIRichTextTest::init() _richText->pushBackElement(recustom); _richText->pushBackElement(re6); - _richText->setPosition(Vector2(widgetSize.width / 2, widgetSize.height / 2)); + _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2)); _richText->setLocalZOrder(10); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp index 5f95948878..7d739ba69a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp @@ -31,7 +31,7 @@ bool UIScene::init() Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _widget->getSize(); - _uiLayer->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _uiLayer->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -55,7 +55,7 @@ bool UIScene::init() mainMenuLabel->setText("MainMenu"); mainMenuLabel->setFontSize(20); mainMenuLabel->setTouchScaleChangeEnabled(true); - mainMenuLabel->setPosition(Vector2(430,30)); + mainMenuLabel->setPosition(Vec2(430,30)); mainMenuLabel->setTouchEnabled(true); mainMenuLabel->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback)); _uiLayer->addWidget(mainMenuLabel); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp index 14948b75f5..cec7e6ca6f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp @@ -22,15 +22,15 @@ bool UIScrollViewTest_Vertical::init() // Add a label in which the scrollview alert will be displayed _displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("ScrollView vertical", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -41,7 +41,7 @@ bool UIScrollViewTest_Vertical::init() ui::ScrollView* scrollView = ui::ScrollView::create(); scrollView->setSize(Size(280.0f, 150.0f)); Size backgroundSize = background->getContentSize(); - scrollView->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - scrollView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - scrollView->getSize().height) / 2.0f)); @@ -55,21 +55,21 @@ bool UIScrollViewTest_Vertical::init() scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f)); + button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f)); scrollView->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(innerWidth / 2.0f, button->getBottomInParent() - button->getSize().height)); + titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomInParent() - button->getSize().height)); scrollView->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height)); + button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height)); scrollView->addChild(button_scale9); - imageView->setPosition(Vector2(innerWidth / 2.0f, imageView->getSize().height / 2.0f)); + imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getSize().height / 2.0f)); scrollView->addChild(imageView); return true; @@ -97,13 +97,13 @@ bool UIScrollViewTest_Horizontal::init() // Add a label in which the scrollview alert will be displayed _displayValueLabel = Text::create("Move by horizontal direction","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); Text* alert = Text::create("ScrollView horizontal","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -117,7 +117,7 @@ bool UIScrollViewTest_Horizontal::init() scrollView->setSize(Size(280.0f, 150.0f)); scrollView->setInnerContainerSize(scrollView->getSize()); Size backgroundSize = background->getContentSize(); - scrollView->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - scrollView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - scrollView->getSize().height) / 2.0f)); @@ -131,24 +131,24 @@ bool UIScrollViewTest_Horizontal::init() scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button->setPosition(Vector2(button->getSize().width / 2.0f, + button->setPosition(Vec2(button->getSize().width / 2.0f, scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f)); scrollView->addChild(button); Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png"); titleButton->setTitleText("Title Button"); - titleButton->setPosition(Vector2(button->getRightInParent() + button->getSize().width / 2.0f, + titleButton->setPosition(Vec2(button->getRightInParent() + button->getSize().width / 2.0f, button->getBottomInParent() - button->getSize().height / 2.0f)); scrollView->addChild(titleButton); Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); - button_scale9->setPosition(Vector2(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f, + button_scale9->setPosition(Vec2(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f)); scrollView->addChild(button_scale9); - imageView->setPosition(Vector2(innerWidth - imageView->getSize().width / 2.0f, + imageView->setPosition(Vec2(innerWidth - imageView->getSize().width / 2.0f, button_scale9->getBottomInParent() - button_scale9->getSize().height / 2.0f)); scrollView->addChild(imageView); @@ -177,14 +177,14 @@ bool UIScrollViewTest_Both::init() // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Move by any direction","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("ScrollView both","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -200,7 +200,7 @@ bool UIScrollViewTest_Both::init() scrollView->setBackGroundImage("cocosui/green_edit.png"); scrollView->setSize(Size(210, 122.5)); Size backgroundSize = background->getContentSize(); - scrollView->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - scrollView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - scrollView->getSize().height) / 2.0f)); @@ -209,7 +209,7 @@ bool UIScrollViewTest_Both::init() scrollView->setInnerContainerSize(imageView->getContentSize()); Size innerSize = scrollView->getInnerContainerSize(); - imageView->setPosition(Vector2(innerSize.width / 2.0f, innerSize.height / 2.0f)); + imageView->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f)); _uiLayer->addChild(scrollView); @@ -238,14 +238,14 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",30); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("ScrollView scroll to percent both directrion","fonts/Marker Felt.ttf",20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -259,13 +259,13 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() sc->setInnerContainerSize(Size(480, 320)); sc->setSize(Size(100,100)); Size backgroundSize = background->getContentSize(); - sc->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - sc->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - sc->getSize().height) / 2.0f)); - sc->scrollToPercentBothDirection(Vector2(50, 50), 1, true); + sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true); ImageView* iv = ImageView::create("cocosui/Hello.png"); - iv->setPosition(Vector2(240, 160)); + iv->setPosition(Vec2(240, 160)); sc->addChild(iv); _uiLayer->addChild(sc); @@ -293,14 +293,14 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init() // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("ScrollView scroll to percent both directrion bounce","fonts/Marker Felt.ttf",20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5)); _uiLayer->addChild(alert); Layout* root = static_cast(_uiLayer->getChildByTag(81)); @@ -315,13 +315,13 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init() sc->setInnerContainerSize(Size(480, 320)); sc->setSize(Size(100,100)); Size backgroundSize = background->getContentSize(); - sc->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + + sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - sc->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - sc->getSize().height) / 2.0f)); - sc->scrollToPercentBothDirection(Vector2(50, 50), 1, true); + sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true); ImageView* iv = ImageView::create("cocosui/Hello.png"); - iv->setPosition(Vector2(240, 160)); + iv->setPosition(Vec2(240, 160)); sc->addChild(iv); _uiLayer->addChild(sc); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp index 44b4a3f5d2..dc7584afe9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp @@ -23,7 +23,7 @@ bool UIScrollViewTest_Vertical_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -35,7 +35,7 @@ bool UIScrollViewTest_Vertical_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -44,7 +44,7 @@ bool UIScrollViewTest_Vertical_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -78,7 +78,7 @@ bool UIScrollViewTest_Horizontal_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -90,7 +90,7 @@ bool UIScrollViewTest_Horizontal_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -99,7 +99,7 @@ bool UIScrollViewTest_Horizontal_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -133,7 +133,7 @@ bool UIScrollViewTest_Both_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -145,7 +145,7 @@ bool UIScrollViewTest_Both_Editor::init() Button* left_button = Button::create(); left_button->loadTextures("Images/b1.png", "Images/b2.png", ""); - left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, + left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); @@ -154,7 +154,7 @@ bool UIScrollViewTest_Both_Editor::init() Button* right_button = Button::create(); right_button->loadTextures("Images/f1.png", "Images/f2.png", ""); - right_button->setPosition(Vector2(_layout->getSize().width / 2 + right_button->getSize().width, + right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width, right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); @@ -188,7 +188,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -234,7 +234,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 1dafc7582d..04ab088cc5 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -23,14 +23,14 @@ bool UISliderTest::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("Move the slider thumb","Move the slider thumb",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("Slider","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the slider @@ -38,7 +38,7 @@ bool UISliderTest::init() slider->loadBarTexture("cocosui/sliderTrack.png"); slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 2.0f*/)); + slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 2.0f*/)); slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this)); _uiLayer->addChild(slider); @@ -78,14 +78,14 @@ bool UISliderTest_Scale9::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("Move the slider thumb","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text *alert = Text::create("Slider scale9 render","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the slider @@ -96,7 +96,7 @@ bool UISliderTest_Scale9::init() slider->setScale9Enabled(true); slider->setCapInsets(Rect(0, 0, 0, 0)); slider->setSize(Size(250.0f, 19)); - slider->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 3.0f*/)); + slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 3.0f*/)); slider->addEventListener(CC_CALLBACK_2(UISliderTest_Scale9::sliderEvent, this)); _uiLayer->addChild(slider); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp index 69bb9273e0..c6d0e0ea45 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp @@ -24,7 +24,7 @@ bool UISliderTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -46,7 +46,7 @@ bool UISliderTest_Editor::init() _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); _displayValueLabel->setFontSize(30); _displayValueLabel->setString("No event"); - _displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2, + _displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2, _layout->getSize().height - _displayValueLabel->getSize().height * 1.75f)); _touchGroup->addChild(_displayValueLabel); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp index 2d0998723c..1bf5bee405 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp @@ -14,12 +14,12 @@ bool UITextAtlasTest::init() // Add the alert Text* alert = Text::create("TextAtlas","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the text atlas TextAtlas* textAtlas = TextAtlas::create("1234567890", "cocosui/labelatlas.png", 17, 22, "0"); - textAtlas->setPosition(Vector2((widgetSize.width) / 2, widgetSize.height / 2.0f)); + textAtlas->setPosition(Vec2((widgetSize.width) / 2, widgetSize.height / 2.0f)); _uiLayer->addChild(textAtlas); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp index 6077d19e18..396337a5eb 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp @@ -12,7 +12,7 @@ bool UITextAtlasTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp index 3501d4f860..916ba0efbf 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp @@ -13,12 +13,12 @@ bool UITextBMFontTest::init() Text* alert = Text::create("TextBMFont","TextBMFont",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the TextBMFont TextBMFont* textBMFont = TextBMFont::create("BMFont", "cocosui/bitmapFontTest2.fnt"); - textBMFont->setPosition(Vector2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f)); + textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f)); _uiLayer->addChild(textBMFont); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp index b053f267b4..5b2bdcee10 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp @@ -13,7 +13,7 @@ bool UITextBMFontTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 6f40044104..f67469e9cb 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -21,20 +21,20 @@ bool UITextFieldTest::init() // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text* alert = Text::create("TextField","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); // Create the textfield TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30); - textField->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest::textFieldEvent, this)); _uiLayer->addChild(textField); @@ -53,7 +53,7 @@ void UITextFieldTest::textFieldEvent(Ref *pSender, TextField::EventType type) TextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); textField->runAction(CCMoveTo::create(0.225f, - Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); + Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("attach with IME")->getCString()); } break; @@ -62,7 +62,7 @@ void UITextFieldTest::textFieldEvent(Ref *pSender, TextField::EventType type) { TextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175f, Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("detach with IME")->getCString()); } break; @@ -99,21 +99,21 @@ bool UITextFieldTest_MaxLength::init() // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text *alert = Text::create("TextField max length","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); // Create the textfield TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30); textField->setMaxLengthEnabled(true); textField->setMaxLength(3); - textField->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + textField->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest_MaxLength::textFieldEvent, this)); _uiLayer->addChild(textField); @@ -131,7 +131,7 @@ void UITextFieldTest_MaxLength::textFieldEvent(Ref *pSender, TextField::EventTyp TextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); textField->runAction(CCMoveTo::create(0.225f, - Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); + Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString()); } break; @@ -140,7 +140,7 @@ void UITextFieldTest_MaxLength::textFieldEvent(Ref *pSender, TextField::EventTyp { TextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175f, Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString()); } break; @@ -183,21 +183,21 @@ bool UITextFieldTest_Password::init() // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text *alert = Text::create("TextField password","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f)); + alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f)); _uiLayer->addChild(alert); // Create the textfield TextField* textField = TextField::create("input password here","fonts/Marker Felt.ttf",30); textField->setPasswordEnabled(true); textField->setPasswordStyleText("*"); - textField->setPosition(Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)); + textField->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest_Password::textFieldEvent, this)); _uiLayer->addChild(textField); @@ -215,7 +215,7 @@ void UITextFieldTest_Password::textFieldEvent(Ref *pSender, TextField::EventType TextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); textField->runAction(CCMoveTo::create(0.225f, - Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); + Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("attach with IME password")->getCString()); } break; @@ -224,7 +224,7 @@ void UITextFieldTest_Password::textFieldEvent(Ref *pSender, TextField::EventType { TextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175f, Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("detach with IME password")->getCString()); } break; @@ -262,14 +262,14 @@ bool UITextFieldTest_LineWrap::init() // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",30); - _displayValueLabel->setAnchorPoint(Vector2(0.5f, -1)); - _displayValueLabel->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text *alert = Text::create("TextField line wrap","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075)); _uiLayer->addChild(alert); // Create the textfield @@ -278,7 +278,7 @@ bool UITextFieldTest_LineWrap::init() textField->setSize(Size(240, 160)); textField->setTextHorizontalAlignment(TextHAlignment::CENTER); textField->setTextVerticalAlignment(TextVAlignment::CENTER); - textField->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest_LineWrap::textFieldEvent, this)); _uiLayer->addChild(textField); @@ -296,7 +296,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextField::EventType TextField* textField = dynamic_cast(pSender); Size widgetSize = _widget->getSize(); textField->runAction(CCMoveTo::create(0.225f, - Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + textField->getContentSize().height / 2))); + Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + textField->getContentSize().height / 2))); textField->setTextHorizontalAlignment(TextHAlignment::LEFT); textField->setTextVerticalAlignment(TextVAlignment::TOP); @@ -308,7 +308,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextField::EventType { TextField* textField = dynamic_cast(pSender); Size widgetSize = _widget->getSize(); - textField->runAction(CCMoveTo::create(0.175f, Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f))); textField->setTextHorizontalAlignment(TextHAlignment::CENTER); textField->setTextVerticalAlignment(TextVAlignment::CENTER); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp index ee13dd3969..fe9bc0f924 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp @@ -24,7 +24,7 @@ bool UITextFieldTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -47,7 +47,7 @@ bool UITextFieldTest_Editor::init() _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); _displayValueLabel->setFontSize(30); _displayValueLabel->setString("No event"); - _displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2, + _displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2, _layout->getSize().height - _displayValueLabel->getSize().height * 1.75f)); _touchGroup->addChild(_displayValueLabel); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp index 3aaddc3059..d64ba12a10 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp @@ -13,12 +13,12 @@ bool UITextTest::init() Text* alert = Text::create("Text","fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the text Text* text = Text::create("Text", "AmericanTypewriter", 30); - text->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f)); + text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f)); _uiLayer->addChild(text); return true; @@ -36,7 +36,7 @@ bool UITextTest_LineWrap::init() Text* alert = Text::create("Text line wrap","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the line wrap @@ -44,7 +44,7 @@ bool UITextTest_LineWrap::init() text->ignoreContentAdaptWithSize(false); text->setSize(Size(280, 150)); text->setTextHorizontalAlignment(TextHAlignment::CENTER); - text->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getSize().height / 8.0f)); + text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getSize().height / 8.0f)); _uiLayer->addChild(text); return true; @@ -66,7 +66,7 @@ bool UILabelTest_Effect::init() alert->setFontName("fonts/Marker Felt.ttf"); alert->setFontSize(30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.05f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.05f)); _uiLayer->addChild(alert); @@ -88,7 +88,7 @@ bool UILabelTest_Effect::init() shadow_label->setTextDefinition(shadowTextDef); shadow_label->setText("Shadow"); - shadow_label->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + shadow_label->getSize().height)); + shadow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + shadow_label->getSize().height)); _uiLayer->addChild(shadow_label); @@ -111,7 +111,7 @@ bool UILabelTest_Effect::init() stroke_label->setTextDefinition(strokeTextDef); stroke_label->setText("Stroke"); - stroke_label->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + stroke_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(stroke_label); @@ -140,7 +140,7 @@ bool UILabelTest_Effect::init() strokeAndShadow_label->setTextDefinition(strokeShaodwTextDef); // strokeAndShadow_label->setFontFillColor(tintColorRed); strokeAndShadow_label->setText("Stroke and Shadow"); - strokeAndShadow_label->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - shadow_label->getSize().height)); + strokeAndShadow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - shadow_label->getSize().height)); _uiLayer->addChild(strokeAndShadow_label); @@ -161,12 +161,12 @@ bool UITextTest_TTF::init() Text* alert = Text::create("Text set TTF font","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); _uiLayer->addChild(alert); // Create the text, and set font with .ttf Text* text = Text::create("Text","fonts/A Damn Mess.ttf",30); - text->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f)); + text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f)); _uiLayer->addChild(text); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp index effd3883e3..e8ef5acf1b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp @@ -15,7 +15,7 @@ bool UITextTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp index cdaaceac7b..f6d3a05ff7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp @@ -15,45 +15,45 @@ bool VideoPlayerTest::init() MenuItemFont::setFontSize(16); auto fullSwitch = MenuItemFont::create("FullScreenSwitch", CC_CALLBACK_1(VideoPlayerTest::menuFullScreenCallback, this)); - fullSwitch->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - fullSwitch->setPosition(Vector2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 50)); + fullSwitch->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + fullSwitch->setPosition(Vec2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 50)); auto pauseItem = MenuItemFont::create("Pause", CC_CALLBACK_1(VideoPlayerTest::menuPauseCallback, this)); - pauseItem->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - pauseItem->setPosition(Vector2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 100)); + pauseItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + pauseItem->setPosition(Vec2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 100)); auto resumeItem = MenuItemFont::create("Resume", CC_CALLBACK_1(VideoPlayerTest::menuResumeCallback, this)); - resumeItem->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - resumeItem->setPosition(Vector2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 150)); + resumeItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + resumeItem->setPosition(Vec2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 150)); auto stopItem = MenuItemFont::create("Stop", CC_CALLBACK_1(VideoPlayerTest::menuStopCallback, this)); - stopItem->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - stopItem->setPosition(Vector2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 200)); + stopItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + stopItem->setPosition(Vec2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 200)); auto hintItem = MenuItemFont::create("Hint", CC_CALLBACK_1(VideoPlayerTest::menuHintCallback, this)); - hintItem->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); - hintItem->setPosition(Vector2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 250)); + hintItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + hintItem->setPosition(Vec2(_visibleRect.origin.x + 10,_visibleRect.origin.y + 250)); //------------------------------------------------------------------------------------------------------------------- auto resourceVideo = MenuItemFont::create("Play resource video", CC_CALLBACK_1(VideoPlayerTest::menuResourceVideoCallback, this)); - resourceVideo->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - resourceVideo->setPosition(Vector2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 50)); + resourceVideo->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + resourceVideo->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 50)); auto onlineVideo = MenuItemFont::create("Play online video", CC_CALLBACK_1(VideoPlayerTest::menuOnlineVideoCallback, this)); - onlineVideo->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - onlineVideo->setPosition(Vector2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 100)); + onlineVideo->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + onlineVideo->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 100)); auto ratioSwitch = MenuItemFont::create("KeepRatioSwitch", CC_CALLBACK_1(VideoPlayerTest::menuRatioCallback, this)); - ratioSwitch->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - ratioSwitch->setPosition(Vector2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 150)); + ratioSwitch->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + ratioSwitch->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 150)); auto menu = Menu::create(resourceVideo,onlineVideo,ratioSwitch,fullSwitch,pauseItem,resumeItem,stopItem,hintItem,nullptr); - menu->setPosition(Vector2::ZERO); + menu->setPosition(Vec2::ZERO); _uiLayer->addChild(menu); _videoStateLabel = Label::createWithSystemFont("IDLE","Arial",16); - _videoStateLabel->setAnchorPoint(Vector2::ANCHOR_MIDDLE_RIGHT); - _videoStateLabel->setPosition(Vector2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 200)); + _videoStateLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); + _videoStateLabel->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 200)); _uiLayer->addChild(_videoStateLabel); createVideo(); @@ -137,13 +137,13 @@ void VideoPlayerTest::menuHintCallback(Ref* sender) void VideoPlayerTest::createVideo() { - auto centerPos = Vector2(_visibleRect.origin.x + _visibleRect.size.width / 2,_visibleRect.origin.y + _visibleRect.size.height /2); + auto centerPos = Vec2(_visibleRect.origin.x + _visibleRect.size.width / 2,_visibleRect.origin.y + _visibleRect.size.height /2); auto widgetSize = _widget->getSize(); _videoPlayer = VideoPlayer::create(); _videoPlayer->setPosition(centerPos); - _videoPlayer->setAnchorPoint(Vector2::ANCHOR_MIDDLE); + _videoPlayer->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _videoPlayer->setContentSize(Size(widgetSize.width * 0.4f,widgetSize.height * 0.4f)); _uiLayer->addChild(_videoPlayer); @@ -152,14 +152,14 @@ void VideoPlayerTest::createVideo() void VideoPlayerTest::createSlider() { - auto centerPos = Vector2(_visibleRect.origin.x + _visibleRect.size.width / 2,_visibleRect.origin.y + _visibleRect.size.height /2); + auto centerPos = Vec2(_visibleRect.origin.x + _visibleRect.size.width / 2,_visibleRect.origin.y + _visibleRect.size.height /2); auto hSlider = ui::Slider::create(); hSlider->setTouchEnabled(true); hSlider->loadBarTexture("cocosui/sliderTrack.png"); hSlider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); hSlider->loadProgressBarTexture("cocosui/sliderProgress.png"); - hSlider->setPosition(Vector2(centerPos.x, _visibleRect.origin.y + _visibleRect.size.height * 0.15f)); + hSlider->setPosition(Vec2(centerPos.x, _visibleRect.origin.y + _visibleRect.size.height * 0.15f)); hSlider->setPercent(50); hSlider->addEventListener(CC_CALLBACK_2(VideoPlayerTest::sliderCallback, this)); _uiLayer->addChild(hSlider,0,1); @@ -169,7 +169,7 @@ void VideoPlayerTest::createSlider() vSlider->loadBarTexture("cocosui/sliderTrack.png"); vSlider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); vSlider->loadProgressBarTexture("cocosui/sliderProgress.png"); - vSlider->setPosition(Vector2(_visibleRect.origin.x + _visibleRect.size.width * 0.15f, centerPos.y)); + vSlider->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width * 0.15f, centerPos.y)); vSlider->setRotation(90); vSlider->setPercent(50); vSlider->addEventListener(CC_CALLBACK_2(VideoPlayerTest::sliderCallback, this)); @@ -186,7 +186,7 @@ void VideoPlayerTest::sliderCallback(Ref *sender, ui::Slider::EventType eventTyp auto newPosX = _visibleRect.origin.x + _visibleRect.size.width / 2 + hSlider->getPercent() - 50; auto newPosY = _visibleRect.origin.y + _visibleRect.size.height / 2 + 50 - vSlider->getPercent(); - _videoPlayer->setPosition(Vector2(newPosX,newPosY)); + _videoPlayer->setPosition(Vec2(newPosX,newPosY)); } } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp index cf7ad6e7ea..ce6f6b36ed 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp @@ -26,16 +26,16 @@ bool UIWidgetAddNodeTest::init() alert->setFontName("fonts/Marker Felt.ttf"); alert->setFontSize(30); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75)); _uiLayer->addChild(alert); // Create the ui node container Widget* widget = Widget::create(); - widget->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + widget->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(widget); Sprite* sprite = Sprite::create("cocosui/ccicon.png"); - sprite->setPosition(Vector2(0, sprite->getBoundingBox().size.height / 4)); + sprite->setPosition(Vec2(0, sprite->getBoundingBox().size.height / 4)); widget->addChild(sprite); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp index cb91a6dad4..31d176084d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp @@ -23,7 +23,7 @@ bool UIWidgetAddNodeTest_Editor::init() _touchGroup->addChild(_layout); Size screenSize = CCDirector::getInstance()->getWinSize(); Size rootSize = _layout->getSize(); - _touchGroup->setPosition(Vector2((screenSize.width - rootSize.width) / 2, + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); Layout* root = static_cast(_layout->getChildByName("root_Panel")); @@ -36,7 +36,7 @@ bool UIWidgetAddNodeTest_Editor::init() // Create the ui widget Widget* widget = Widget::create(); - widget->setPosition(Vector2(rootSize.width / 2.0f, rootSize.height / 2.0f)); + widget->setPosition(Vec2(rootSize.width / 2.0f, rootSize.height / 2.0f)); widget->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(widget); diff --git a/tests/cpp-tests/Classes/UserDefaultTest/UserDefaultTest.cpp b/tests/cpp-tests/Classes/UserDefaultTest/UserDefaultTest.cpp index a6f187c374..05011cef6a 100644 --- a/tests/cpp-tests/Classes/UserDefaultTest/UserDefaultTest.cpp +++ b/tests/cpp-tests/Classes/UserDefaultTest/UserDefaultTest.cpp @@ -10,7 +10,7 @@ UserDefaultTest::UserDefaultTest() auto s = Director::getInstance()->getWinSize(); auto label = Label::createWithTTF("CCUserDefault test see log", "fonts/arial.ttf", 28); addChild(label, 0); - label->setPosition( Vector2(s.width/2, s.height-50) ); + label->setPosition( Vec2(s.width/2, s.height-50) ); doTest(); } diff --git a/tests/cpp-tests/Classes/VisibleRect.cpp b/tests/cpp-tests/Classes/VisibleRect.cpp index 6010c559e3..639aac8ed7 100644 --- a/tests/cpp-tests/Classes/VisibleRect.cpp +++ b/tests/cpp-tests/Classes/VisibleRect.cpp @@ -41,56 +41,56 @@ Rect VisibleRect::getVisibleRect() return s_visibleRect; } -Vector2 VisibleRect::left() +Vec2 VisibleRect::left() { lazyInit(); - return Vector2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height/2); + return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height/2); } -Vector2 VisibleRect::right() +Vec2 VisibleRect::right() { lazyInit(); - return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height/2); + return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height/2); } -Vector2 VisibleRect::top() +Vec2 VisibleRect::top() { lazyInit(); - return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height); + return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height); } -Vector2 VisibleRect::bottom() +Vec2 VisibleRect::bottom() { lazyInit(); - return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y); + return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y); } -Vector2 VisibleRect::center() +Vec2 VisibleRect::center() { lazyInit(); - return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height/2); + return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height/2); } -Vector2 VisibleRect::leftTop() +Vec2 VisibleRect::leftTop() { lazyInit(); - return Vector2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height); + return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height); } -Vector2 VisibleRect::rightTop() +Vec2 VisibleRect::rightTop() { lazyInit(); - return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height); + return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height); } -Vector2 VisibleRect::leftBottom() +Vec2 VisibleRect::leftBottom() { lazyInit(); return s_visibleRect.origin; } -Vector2 VisibleRect::rightBottom() +Vec2 VisibleRect::rightBottom() { lazyInit(); - return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y); + return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y); } diff --git a/tests/cpp-tests/Classes/VisibleRect.h b/tests/cpp-tests/Classes/VisibleRect.h index 1eeef0dbd1..625f7c3f5f 100644 --- a/tests/cpp-tests/Classes/VisibleRect.h +++ b/tests/cpp-tests/Classes/VisibleRect.h @@ -8,15 +8,15 @@ class VisibleRect public: static cocos2d::Rect getVisibleRect(); - static cocos2d::Vector2 left(); - static cocos2d::Vector2 right(); - static cocos2d::Vector2 top(); - static cocos2d::Vector2 bottom(); - static cocos2d::Vector2 center(); - static cocos2d::Vector2 leftTop(); - static cocos2d::Vector2 rightTop(); - static cocos2d::Vector2 leftBottom(); - static cocos2d::Vector2 rightBottom(); + static cocos2d::Vec2 left(); + static cocos2d::Vec2 right(); + static cocos2d::Vec2 top(); + static cocos2d::Vec2 bottom(); + static cocos2d::Vec2 center(); + static cocos2d::Vec2 leftTop(); + static cocos2d::Vec2 rightTop(); + static cocos2d::Vec2 leftBottom(); + static cocos2d::Vec2 rightBottom(); private: static void lazyInit(); static cocos2d::Rect s_visibleRect; diff --git a/tests/cpp-tests/Classes/ZwoptexTest/ZwoptexTest.cpp b/tests/cpp-tests/Classes/ZwoptexTest/ZwoptexTest.cpp index 85f34a2b1b..333a0c0f8b 100644 --- a/tests/cpp-tests/Classes/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/cpp-tests/Classes/ZwoptexTest/ZwoptexTest.cpp @@ -107,22 +107,22 @@ void ZwoptexGenericTest::onEnter() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini-generic.plist"); auto layer1 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121); - layer1->setPosition(Vector2(s.width/2-80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); + layer1->setPosition(Vec2(s.width/2-80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer1); sprite1 = Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini_dance_01.png")); - sprite1->setPosition(Vector2( s.width/2-80, s.height/2)); + sprite1->setPosition(Vec2( s.width/2-80, s.height/2)); addChild(sprite1); sprite1->setFlippedX(false); sprite1->setFlippedY(false); auto layer2 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121); - layer2->setPosition(Vector2(s.width/2+80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); + layer2->setPosition(Vec2(s.width/2+80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer2); sprite2 = Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini_dance_generic_01.png")); - sprite2->setPosition(Vector2( s.width/2 + 80, s.height/2)); + sprite2->setPosition(Vec2( s.width/2 + 80, s.height/2)); addChild(sprite2); sprite2->setFlippedX(false); diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index aa46f47eda..2eb8c52ce7 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -112,7 +112,7 @@ static int g_testCount = sizeof(g_aTestNames) / sizeof(g_aTestNames[0]); static Controller *currentController = nullptr; #define LINE_SPACE 40 -static Vector2 s_tCurPos = Vector2::ZERO; +static Vec2 s_tCurPos = Vec2::ZERO; //sleep for t seconds static void wait(int t) @@ -122,14 +122,14 @@ static void wait(int t) } TestController::TestController() -: _beginPos(Vector2::ZERO) +: _beginPos(Vec2::ZERO) { // add close menu auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, CC_CALLBACK_1(TestController::closeCallback, this) ); auto menu =Menu::create(closeItem, NULL); - menu->setPosition( Vector2::ZERO ); - closeItem->setPosition(Vector2( VisibleRect::right().x - 30, VisibleRect::top().y - 30)); + menu->setPosition( Vec2::ZERO ); + closeItem->setPosition(Vec2( VisibleRect::right().x - 30, VisibleRect::top().y - 30)); // add menu items for tests TTFConfig ttfConfig("fonts/arial.ttf", 24); @@ -140,7 +140,7 @@ TestController::TestController() auto menuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this)); _itemMenu->addChild(menuItem, i + 10000); - menuItem->setPosition( Vector2( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); + menuItem->setPosition( Vec2( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); } _itemMenu->setContentSize(Size(VisibleRect::getVisibleRect().size.width, (g_testCount + 1) * (LINE_SPACE))); @@ -210,17 +210,17 @@ void TestController::onTouchMoved(Touch* touch, Event *event) float nMoveY = touchLocation.y - _beginPos.y; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } @@ -235,17 +235,17 @@ void TestController::onMouseScroll(Event *event) float nMoveY = mouseEvent->getScrollY() * 6; auto curPos = _itemMenu->getPosition(); - auto nextPos = Vector2(curPos.x, curPos.y + nMoveY); + auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { - _itemMenu->setPosition(Vector2::ZERO); + _itemMenu->setPosition(Vec2::ZERO); return; } if (nextPos.y > ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) { - _itemMenu->setPosition(Vector2(0, ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + _itemMenu->setPosition(Vec2(0, ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); return; } diff --git a/tests/cpp-tests/Classes/controller.h b/tests/cpp-tests/Classes/controller.h index f5139cd61e..136dd0cccc 100644 --- a/tests/cpp-tests/Classes/controller.h +++ b/tests/cpp-tests/Classes/controller.h @@ -23,7 +23,7 @@ public: void startAutoRun(); ssize_t readline(int fd, char* ptr, size_t maxlen); private: - Vector2 _beginPos; + Vec2 _beginPos; Menu* _itemMenu; }; diff --git a/tests/cpp-tests/Classes/testBasic.cpp b/tests/cpp-tests/Classes/testBasic.cpp index 05f46a7fc9..9c0ea38104 100644 --- a/tests/cpp-tests/Classes/testBasic.cpp +++ b/tests/cpp-tests/Classes/testBasic.cpp @@ -43,8 +43,8 @@ void TestScene::onEnter() auto menuItem = MenuItemLabel::create(label, testScene_callback ); auto menu = Menu::create(menuItem, NULL); - menu->setPosition( Vector2::ZERO ); - menuItem->setPosition( Vector2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + menu->setPosition( Vec2::ZERO ); + menuItem->setPosition( Vec2( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); addChild(menu, 1); }