mirror of https://github.com/axmolengine/axmol.git
replace Point with Vector2 in cocos folder cpp file
This commit is contained in:
parent
e2a24dec84
commit
63b52dd287
|
@ -215,7 +215,7 @@ bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO*
|
|||
_boundaryFullyCovered = false;
|
||||
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
_fullScreenSize = Point(winSize.width, winSize.height);
|
||||
_fullScreenSize = Vector2(winSize.width, winSize.height);
|
||||
_halfScreenSize = _fullScreenSize * 0.5f;
|
||||
|
||||
if (_boundarySet)
|
||||
|
@ -257,9 +257,9 @@ void Follow::step(float dt)
|
|||
if(_boundaryFullyCovered)
|
||||
return;
|
||||
|
||||
Point tempPos = _halfScreenSize - _followedNode->getPosition();
|
||||
Vector2 tempPos = _halfScreenSize - _followedNode->getPosition();
|
||||
|
||||
_target->setPosition(Point(clampf(tempPos.x, _leftBoundary, _rightBoundary),
|
||||
_target->setPosition(Vector2(clampf(tempPos.x, _leftBoundary, _rightBoundary),
|
||||
clampf(tempPos.y, _bottomBoundary, _topBoundary)));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -94,9 +94,9 @@ 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);
|
||||
|
||||
Point anchorPoint = _target->getAnchorPointInPoints();
|
||||
Vector2 anchorPoint = _target->getAnchorPointInPoints();
|
||||
|
||||
bool needsTranslation = !anchorPoint.equals(Point::ZERO);
|
||||
bool needsTranslation = !anchorPoint.equals(Vector2::ZERO);
|
||||
|
||||
Matrix mv = Matrix::identity();
|
||||
|
||||
|
|
|
@ -62,18 +62,18 @@ PointArray* PointArray::create(ssize_t capacity)
|
|||
|
||||
bool PointArray::initWithCapacity(ssize_t capacity)
|
||||
{
|
||||
_controlPoints = new vector<Point*>();
|
||||
_controlPoints = new vector<Vector2*>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PointArray* PointArray::clone() const
|
||||
{
|
||||
vector<Point*> *newArray = new vector<Point*>();
|
||||
vector<Point*>::iterator iter;
|
||||
vector<Vector2*> *newArray = new vector<Vector2*>();
|
||||
vector<Vector2*>::iterator iter;
|
||||
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
|
||||
{
|
||||
newArray->push_back(new Point((*iter)->x, (*iter)->y));
|
||||
newArray->push_back(new Vector2((*iter)->x, (*iter)->y));
|
||||
}
|
||||
|
||||
PointArray *points = new PointArray();
|
||||
|
@ -88,7 +88,7 @@ PointArray::~PointArray()
|
|||
{
|
||||
CCLOGINFO("deallocing PointArray: %p", this);
|
||||
|
||||
vector<Point*>::iterator iter;
|
||||
vector<Vector2*>::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<Point*>* PointArray::getControlPoints() const
|
||||
const std::vector<Vector2*>* PointArray::getControlPoints() const
|
||||
{
|
||||
return _controlPoints;
|
||||
}
|
||||
|
||||
void PointArray::setControlPoints(vector<Point*> *controlPoints)
|
||||
void PointArray::setControlPoints(vector<Vector2*> *controlPoints)
|
||||
{
|
||||
CCASSERT(controlPoints != nullptr, "control points should not be nullptr");
|
||||
|
||||
// delete old points
|
||||
vector<Point*>::iterator iter;
|
||||
vector<Vector2*>::iterator iter;
|
||||
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
|
||||
{
|
||||
delete *iter;
|
||||
|
@ -118,35 +118,35 @@ void PointArray::setControlPoints(vector<Point*> *controlPoints)
|
|||
_controlPoints = controlPoints;
|
||||
}
|
||||
|
||||
void PointArray::addControlPoint(Point controlPoint)
|
||||
void PointArray::addControlPoint(Vector2 controlPoint)
|
||||
{
|
||||
_controlPoints->push_back(new Point(controlPoint.x, controlPoint.y));
|
||||
_controlPoints->push_back(new Vector2(controlPoint.x, controlPoint.y));
|
||||
}
|
||||
|
||||
void PointArray::insertControlPoint(Point &controlPoint, ssize_t index)
|
||||
void PointArray::insertControlPoint(Vector2 &controlPoint, ssize_t index)
|
||||
{
|
||||
Point *temp = new Point(controlPoint.x, controlPoint.y);
|
||||
Vector2 *temp = new Vector2(controlPoint.x, controlPoint.y);
|
||||
_controlPoints->insert(_controlPoints->begin() + index, temp);
|
||||
}
|
||||
|
||||
Point PointArray::getControlPointAtIndex(ssize_t index)
|
||||
Vector2 PointArray::getControlPointAtIndex(ssize_t index)
|
||||
{
|
||||
index = MIN(static_cast<ssize_t>(_controlPoints->size())-1, MAX(index, 0));
|
||||
return *(_controlPoints->at(index));
|
||||
}
|
||||
|
||||
void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, ssize_t index)
|
||||
void PointArray::replaceControlPoint(cocos2d::Vector2 &controlPoint, ssize_t index)
|
||||
{
|
||||
|
||||
Point *temp = _controlPoints->at(index);
|
||||
Vector2 *temp = _controlPoints->at(index);
|
||||
temp->x = controlPoint.x;
|
||||
temp->y = controlPoint.y;
|
||||
}
|
||||
|
||||
void PointArray::removeControlPointAtIndex(ssize_t index)
|
||||
{
|
||||
vector<Point*>::iterator iter = _controlPoints->begin() + index;
|
||||
Point* removedPoint = *iter;
|
||||
vector<Vector2*>::iterator iter = _controlPoints->begin() + index;
|
||||
Vector2* removedPoint = *iter;
|
||||
_controlPoints->erase(iter);
|
||||
delete removedPoint;
|
||||
}
|
||||
|
@ -158,13 +158,13 @@ ssize_t PointArray::count() const
|
|||
|
||||
PointArray* PointArray::reverse() const
|
||||
{
|
||||
vector<Point*> *newArray = new vector<Point*>();
|
||||
vector<Point*>::reverse_iterator iter;
|
||||
Point *point = nullptr;
|
||||
vector<Vector2*> *newArray = new vector<Vector2*>();
|
||||
vector<Vector2*>::reverse_iterator iter;
|
||||
Vector2 *point = nullptr;
|
||||
for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter)
|
||||
{
|
||||
point = *iter;
|
||||
newArray->push_back(new Point(point->x, point->y));
|
||||
newArray->push_back(new Vector2(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();
|
||||
Point *p1 = nullptr;
|
||||
Point *p2 = nullptr;
|
||||
Vector2 *p1 = nullptr;
|
||||
Vector2 *p2 = nullptr;
|
||||
float x, y;
|
||||
for (size_t i = 0; i < l/2; ++i)
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ void PointArray::reverseInline()
|
|||
}
|
||||
|
||||
// CatmullRom Spline formula:
|
||||
Point ccCardinalSplineAt(Point &p0, Point &p1, Point &p2, Point &p3, float tension, float t)
|
||||
Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t)
|
||||
{
|
||||
float t2 = t * t;
|
||||
float t3 = t2 * t;
|
||||
|
@ -213,7 +213,7 @@ Point ccCardinalSplineAt(Point &p0, Point &p1, Point &p2, Point &p3, float tensi
|
|||
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 Point(x,y);
|
||||
return Vector2(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 = Point::ZERO;
|
||||
_accumulatedDiff = Vector2::ZERO;
|
||||
}
|
||||
|
||||
CardinalSplineTo* CardinalSplineTo::clone() const
|
||||
|
@ -307,17 +307,17 @@ void CardinalSplineTo::update(float time)
|
|||
}
|
||||
|
||||
// Interpolate
|
||||
Point pp0 = _points->getControlPointAtIndex(p-1);
|
||||
Point pp1 = _points->getControlPointAtIndex(p+0);
|
||||
Point pp2 = _points->getControlPointAtIndex(p+1);
|
||||
Point pp3 = _points->getControlPointAtIndex(p+2);
|
||||
Vector2 pp0 = _points->getControlPointAtIndex(p-1);
|
||||
Vector2 pp1 = _points->getControlPointAtIndex(p+0);
|
||||
Vector2 pp2 = _points->getControlPointAtIndex(p+1);
|
||||
Vector2 pp3 = _points->getControlPointAtIndex(p+2);
|
||||
|
||||
Point newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt);
|
||||
Vector2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt);
|
||||
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
// Support for stacked actions
|
||||
Node *node = _target;
|
||||
Point diff = node->getPosition() - _previousPosition;
|
||||
Vector2 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::Point &newPos)
|
||||
void CardinalSplineTo::updatePosition(cocos2d::Vector2 &newPos)
|
||||
{
|
||||
_target->setPosition(newPos);
|
||||
_previousPosition = newPos;
|
||||
|
@ -365,9 +365,9 @@ CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0)
|
|||
{
|
||||
}
|
||||
|
||||
void CardinalSplineBy::updatePosition(cocos2d::Point &newPos)
|
||||
void CardinalSplineBy::updatePosition(cocos2d::Vector2 &newPos)
|
||||
{
|
||||
Point p = newPos + _startPosition;
|
||||
Vector2 p = newPos + _startPosition;
|
||||
_target->setPosition(p);
|
||||
_previousPosition = p;
|
||||
}
|
||||
|
@ -379,11 +379,11 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
Point p = copyConfig->getControlPointAtIndex(0);
|
||||
Vector2 p = copyConfig->getControlPointAtIndex(0);
|
||||
for (ssize_t i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
Point current = copyConfig->getControlPointAtIndex(i);
|
||||
Point diff = current - p;
|
||||
Vector2 current = copyConfig->getControlPointAtIndex(i);
|
||||
Vector2 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)
|
||||
{
|
||||
Point current = pReverse->getControlPointAtIndex(i);
|
||||
Vector2 current = pReverse->getControlPointAtIndex(i);
|
||||
current = -current;
|
||||
Point abs = current + p;
|
||||
Vector2 abs = current + p;
|
||||
pReverse->replaceControlPoint(abs, i);
|
||||
|
||||
p = abs;
|
||||
|
@ -524,11 +524,11 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
Point p = copyConfig->getControlPointAtIndex(0);
|
||||
Vector2 p = copyConfig->getControlPointAtIndex(0);
|
||||
for (ssize_t i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
Point current = copyConfig->getControlPointAtIndex(i);
|
||||
Point diff = current - p;
|
||||
Vector2 current = copyConfig->getControlPointAtIndex(i);
|
||||
Vector2 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)
|
||||
{
|
||||
Point current = reverse->getControlPointAtIndex(i);
|
||||
Vector2 current = reverse->getControlPointAtIndex(i);
|
||||
current = -current;
|
||||
Point abs = current + p;
|
||||
Vector2 abs = current + p;
|
||||
reverse->replaceControlPoint(abs, i);
|
||||
|
||||
p = abs;
|
||||
|
|
|
@ -103,19 +103,19 @@ GridBase* Grid3DAction::getGrid()
|
|||
return Grid3D::create(_gridSize);
|
||||
}
|
||||
|
||||
Vector3 Grid3DAction::getVertex(const Point& position) const
|
||||
Vector3 Grid3DAction::getVertex(const Vector2& position) const
|
||||
{
|
||||
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getVertex(position);
|
||||
}
|
||||
|
||||
Vector3 Grid3DAction::getOriginalVertex(const Point& position) const
|
||||
Vector3 Grid3DAction::getOriginalVertex(const Vector2& position) const
|
||||
{
|
||||
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getOriginalVertex(position);
|
||||
}
|
||||
|
||||
void Grid3DAction::setVertex(const Point& position, const Vector3& vertex)
|
||||
void Grid3DAction::setVertex(const Vector2& position, const Vector3& 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 Point& pos) const
|
||||
Quad3 TiledGrid3DAction::getTile(const Vector2& pos) const
|
||||
{
|
||||
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getTile(pos);
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3DAction::getOriginalTile(const Point& pos) const
|
||||
Quad3 TiledGrid3DAction::getOriginalTile(const Vector2& pos) const
|
||||
{
|
||||
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getOriginalTile(pos);
|
||||
}
|
||||
|
||||
void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords)
|
||||
void TiledGrid3DAction::setTile(const Vector2& pos, const Quad3& coords)
|
||||
{
|
||||
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||
return g->setTile(pos, coords);
|
||||
|
|
|
@ -79,10 +79,10 @@ void Waves3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i ,j));
|
||||
Vector3 v = getOriginalVertex(Vector2(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(Point(i, j), v);
|
||||
setVertex(Vector2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,30 +144,30 @@ void FlipX3D::update(float time)
|
|||
|
||||
Vector3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Point(1, 1));
|
||||
v1 = getOriginalVertex(Point(0, 0));
|
||||
v0 = getOriginalVertex(Vector2(1, 1));
|
||||
v1 = getOriginalVertex(Vector2(0, 0));
|
||||
|
||||
float x0 = v0.x;
|
||||
float x1 = v1.x;
|
||||
float x;
|
||||
Point a, b, c, d;
|
||||
Vector2 a, b, c, d;
|
||||
|
||||
if ( x0 > x1 )
|
||||
{
|
||||
// Normal Grid
|
||||
a = Point(0,0);
|
||||
b = Point(0,1);
|
||||
c = Point(1,0);
|
||||
d = Point(1,1);
|
||||
a = Vector2(0,0);
|
||||
b = Vector2(0,1);
|
||||
c = Vector2(1,0);
|
||||
d = Vector2(1,1);
|
||||
x = x0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
c = Point(0,0);
|
||||
d = Point(0,1);
|
||||
a = Point(1,0);
|
||||
b = Point(1,1);
|
||||
c = Vector2(0,0);
|
||||
d = Vector2(0,1);
|
||||
a = Vector2(1,0);
|
||||
b = Vector2(1,1);
|
||||
x = x1;
|
||||
}
|
||||
|
||||
|
@ -238,30 +238,30 @@ void FlipY3D::update(float time)
|
|||
|
||||
Vector3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Point(1, 1));
|
||||
v1 = getOriginalVertex(Point(0, 0));
|
||||
v0 = getOriginalVertex(Vector2(1, 1));
|
||||
v1 = getOriginalVertex(Vector2(0, 0));
|
||||
|
||||
float y0 = v0.y;
|
||||
float y1 = v1.y;
|
||||
float y;
|
||||
Point a, b, c, d;
|
||||
Vector2 a, b, c, d;
|
||||
|
||||
if (y0 > y1)
|
||||
{
|
||||
// Normal Grid
|
||||
a = Point(0,0);
|
||||
b = Point(0,1);
|
||||
c = Point(1,0);
|
||||
d = Point(1,1);
|
||||
a = Vector2(0,0);
|
||||
b = Vector2(0,1);
|
||||
c = Vector2(1,0);
|
||||
d = Vector2(1,1);
|
||||
y = y0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
b = Point(0,0);
|
||||
a = Point(0,1);
|
||||
d = Point(1,0);
|
||||
c = Point(1,1);
|
||||
b = Vector2(0,0);
|
||||
a = Vector2(0,1);
|
||||
d = Vector2(1,0);
|
||||
c = Vector2(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 Point& position, float radius)
|
||||
Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& position, float radius)
|
||||
{
|
||||
Lens3D *action = new Lens3D();
|
||||
|
||||
|
@ -315,11 +315,11 @@ Lens3D* Lens3D::create(float duration, const Size& gridSize, const Point& positi
|
|||
return action;
|
||||
}
|
||||
|
||||
bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Point& position, float radius)
|
||||
bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius)
|
||||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
_position = Point(-1, -1);
|
||||
_position = Vector2(-1, -1);
|
||||
setPosition(position);
|
||||
_radius = radius;
|
||||
_lensEffect = 0.7f;
|
||||
|
@ -361,8 +361,8 @@ void Lens3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i, j));
|
||||
Point vect = _position - Point(v.x, v.y);
|
||||
Vector3 v = getOriginalVertex(Vector2(i, j));
|
||||
Vector2 vect = _position - Vector2(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 = vect.normalize();
|
||||
Point new_vect = vect * new_r;
|
||||
Vector2 new_vect = vect * new_r;
|
||||
v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect;
|
||||
}
|
||||
}
|
||||
|
||||
setVertex(Point(i, j), v);
|
||||
setVertex(Vector2(i, j), v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ void Lens3D::update(float time)
|
|||
|
||||
// implementation of Ripple3D
|
||||
|
||||
Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude)
|
||||
Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2& 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 Point& po
|
|||
return action;
|
||||
}
|
||||
|
||||
bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude)
|
||||
bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude)
|
||||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
|
@ -453,8 +453,8 @@ void Ripple3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i, j));
|
||||
Point vect = _position - Point(v.x,v.y);
|
||||
Vector3 v = getOriginalVertex(Vector2(i, j));
|
||||
Vector2 vect = _position - Vector2(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(Point(i, j), v);
|
||||
setVertex(Vector2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ void Shaky3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i ,j));
|
||||
Vector3 v = getOriginalVertex(Vector2(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(Point(i, j), v);
|
||||
setVertex(Vector2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,10 +586,10 @@ void Liquid::update(float time)
|
|||
{
|
||||
for (j = 1; j < _gridSize.height; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i, j));
|
||||
Vector3 v = getOriginalVertex(Vector2(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(Point(i, j), v);
|
||||
setVertex(Vector2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ void Waves::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i, j));
|
||||
Vector3 v = getOriginalVertex(Vector2(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(Point(i, j), v);
|
||||
setVertex(Vector2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// implementation of Twirl
|
||||
|
||||
Twirl* Twirl::create(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude)
|
||||
Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude)
|
||||
{
|
||||
Twirl *action = new Twirl();
|
||||
|
||||
|
@ -686,7 +686,7 @@ Twirl* Twirl::create(float duration, const Size& gridSize, Point position, unsig
|
|||
return action;
|
||||
}
|
||||
|
||||
bool Twirl::initWithDuration(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude)
|
||||
bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude)
|
||||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
|
@ -718,28 +718,28 @@ Twirl *Twirl::clone() const
|
|||
void Twirl::update(float time)
|
||||
{
|
||||
int i, j;
|
||||
Point c = _position;
|
||||
Vector2 c = _position;
|
||||
|
||||
for (i = 0; i < (_gridSize.width+1); ++i)
|
||||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Point(i ,j));
|
||||
Vector3 v = getOriginalVertex(Vector2(i ,j));
|
||||
|
||||
Point avg = Point(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
Vector2 avg = Vector2(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;
|
||||
|
||||
Point d = Point(
|
||||
Vector2 d = Vector2(
|
||||
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(Point(i ,j), v);
|
||||
setVertex(Vector2(i ,j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ FlipY * FlipY::clone() const
|
|||
// Place
|
||||
//
|
||||
|
||||
Place* Place::create(const Point& pos)
|
||||
Place* Place::create(const Vector2& pos)
|
||||
{
|
||||
Place *ret = new Place();
|
||||
|
||||
|
@ -291,7 +291,7 @@ Place* Place::create(const Point& pos)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool Place::initWithPosition(const Point& pos) {
|
||||
bool Place::initWithPosition(const Vector2& pos) {
|
||||
_position = pos;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -970,7 +970,7 @@ RotateBy* RotateBy::reverse() const
|
|||
// MoveBy
|
||||
//
|
||||
|
||||
MoveBy* MoveBy::create(float duration, const Point& deltaPosition)
|
||||
MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition)
|
||||
{
|
||||
MoveBy *ret = new MoveBy();
|
||||
ret->initWithDuration(duration, deltaPosition);
|
||||
|
@ -979,7 +979,7 @@ MoveBy* MoveBy::create(float duration, const Point& deltaPosition)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool MoveBy::initWithDuration(float duration, const Point& deltaPosition)
|
||||
bool MoveBy::initWithDuration(float duration, const Vector2& deltaPosition)
|
||||
{
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
|
@ -1007,7 +1007,7 @@ void MoveBy::startWithTarget(Node *target)
|
|||
|
||||
MoveBy* MoveBy::reverse() const
|
||||
{
|
||||
return MoveBy::create(_duration, Point( -_positionDelta.x, -_positionDelta.y));
|
||||
return MoveBy::create(_duration, Vector2( -_positionDelta.x, -_positionDelta.y));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1016,10 +1016,10 @@ void MoveBy::update(float t)
|
|||
if (_target)
|
||||
{
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Point currentPos = _target->getPosition();
|
||||
Point diff = currentPos - _previousPosition;
|
||||
Vector2 currentPos = _target->getPosition();
|
||||
Vector2 diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
Point newPos = _startPosition + (_positionDelta * t);
|
||||
Vector2 newPos = _startPosition + (_positionDelta * t);
|
||||
_target->setPosition(newPos);
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
|
@ -1032,7 +1032,7 @@ void MoveBy::update(float t)
|
|||
// MoveTo
|
||||
//
|
||||
|
||||
MoveTo* MoveTo::create(float duration, const Point& position)
|
||||
MoveTo* MoveTo::create(float duration, const Vector2& position)
|
||||
{
|
||||
MoveTo *ret = new MoveTo();
|
||||
ret->initWithDuration(duration, position);
|
||||
|
@ -1041,7 +1041,7 @@ MoveTo* MoveTo::create(float duration, const Point& position)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool MoveTo::initWithDuration(float duration, const Point& position)
|
||||
bool MoveTo::initWithDuration(float duration, const Vector2& position)
|
||||
{
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
|
@ -1249,7 +1249,7 @@ SkewBy* SkewBy::reverse() const
|
|||
// JumpBy
|
||||
//
|
||||
|
||||
JumpBy* JumpBy::create(float duration, const Point& position, float height, int jumps)
|
||||
JumpBy* JumpBy::create(float duration, const Vector2& position, float height, int jumps)
|
||||
{
|
||||
JumpBy *jumpBy = new JumpBy();
|
||||
jumpBy->initWithDuration(duration, position, height, jumps);
|
||||
|
@ -1258,7 +1258,7 @@ JumpBy* JumpBy::create(float duration, const Point& position, float height, int
|
|||
return jumpBy;
|
||||
}
|
||||
|
||||
bool JumpBy::initWithDuration(float duration, const Point& position, float height, int jumps)
|
||||
bool JumpBy::initWithDuration(float duration, const Vector2& position, float height, int jumps)
|
||||
{
|
||||
CCASSERT(jumps>=0, "Number of jumps must be >= 0");
|
||||
|
||||
|
@ -1300,24 +1300,24 @@ void JumpBy::update(float t)
|
|||
|
||||
float x = _delta.x * t;
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Point currentPos = _target->getPosition();
|
||||
Vector2 currentPos = _target->getPosition();
|
||||
|
||||
Point diff = currentPos - _previousPos;
|
||||
Vector2 diff = currentPos - _previousPos;
|
||||
_startPosition = diff + _startPosition;
|
||||
|
||||
Point newPos = _startPosition + Point(x,y);
|
||||
Vector2 newPos = _startPosition + Vector2(x,y);
|
||||
_target->setPosition(newPos);
|
||||
|
||||
_previousPos = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, Point(x,y)));
|
||||
_target->setPosition(ccpAdd( _startPosition, Vector2(x,y)));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
||||
JumpBy* JumpBy::reverse() const
|
||||
{
|
||||
return JumpBy::create(_duration, Point(-_delta.x, -_delta.y),
|
||||
return JumpBy::create(_duration, Vector2(-_delta.x, -_delta.y),
|
||||
_height, _jumps);
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ JumpBy* JumpBy::reverse() const
|
|||
// JumpTo
|
||||
//
|
||||
|
||||
JumpTo* JumpTo::create(float duration, const Point& position, float height, int jumps)
|
||||
JumpTo* JumpTo::create(float duration, const Vector2& position, float height, int jumps)
|
||||
{
|
||||
JumpTo *jumpTo = new JumpTo();
|
||||
jumpTo->initWithDuration(duration, position, height, jumps);
|
||||
|
@ -1352,7 +1352,7 @@ JumpTo* JumpTo::reverse() const
|
|||
void JumpTo::startWithTarget(Node *target)
|
||||
{
|
||||
JumpBy::startWithTarget(target);
|
||||
_delta = Point(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
_delta = Vector2(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
}
|
||||
|
||||
// Bezier cubic formula:
|
||||
|
@ -1424,16 +1424,16 @@ void BezierBy::update(float time)
|
|||
float y = bezierat(ya, yb, yc, yd, time);
|
||||
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Point currentPos = _target->getPosition();
|
||||
Point diff = currentPos - _previousPosition;
|
||||
Vector2 currentPos = _target->getPosition();
|
||||
Vector2 diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
|
||||
Point newPos = _startPosition + Point(x,y);
|
||||
Vector2 newPos = _startPosition + Vector2(x,y);
|
||||
_target->setPosition(newPos);
|
||||
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, Point(x,y)));
|
||||
_target->setPosition(ccpAdd( _startPosition, Vector2(x,y)));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ void PageTurn3D::update(float time)
|
|||
for (int j = 0; j <= _gridSize.height; ++j)
|
||||
{
|
||||
// Get original vertex
|
||||
Vector3 p = getOriginalVertex(Point(i ,j));
|
||||
Vector3 p = getOriginalVertex(Vector2(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(Point(i, j), p);
|
||||
setVertex(Vector2(i, j), p);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ NS_CC_BEGIN
|
|||
|
||||
struct Tile
|
||||
{
|
||||
Point position;
|
||||
Point startPosition;
|
||||
Vector2 position;
|
||||
Vector2 startPosition;
|
||||
Size delta;
|
||||
};
|
||||
|
||||
|
@ -91,7 +91,7 @@ void ShakyTiles3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Point(i, j));
|
||||
Quad3 coords = getOriginalTile(Vector2(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(Point(i, j), coords);
|
||||
setTile(Vector2(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ void ShatteredTiles3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Point(i ,j));
|
||||
Quad3 coords = getOriginalTile(Vector2(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(Point(i, j), coords);
|
||||
setTile(Vector2(i, j), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len)
|
|||
|
||||
Size ShuffleTiles::getDelta(const Size& pos) const
|
||||
{
|
||||
Point pos2;
|
||||
Vector2 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 Point& pos, Tile *t)
|
||||
void ShuffleTiles::placeTile(const Vector2& pos, Tile *t)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(pos);
|
||||
|
||||
Point step = _gridNodeTarget->getGrid()->getStep();
|
||||
Vector2 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 = Point((float)i, (float)j);
|
||||
tileArray->startPosition = Point((float)i, (float)j);
|
||||
tileArray->position = Vector2((float)i, (float)j);
|
||||
tileArray->startPosition = Vector2((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 = Point((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
|
||||
placeTile(Point(i, j), tileArray);
|
||||
tileArray->position = Vector2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
|
||||
placeTile(Vector2(i, j), tileArray);
|
||||
++tileArray;
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ FadeOutTRTiles* FadeOutTRTiles::clone() const
|
|||
|
||||
float FadeOutTRTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
Vector2 n = Vector2((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 Point& pos)
|
||||
void FadeOutTRTiles::turnOnTile(const Vector2& pos)
|
||||
{
|
||||
setTile(pos, getOriginalTile(pos));
|
||||
}
|
||||
|
||||
void FadeOutTRTiles::turnOffTile(const Point& pos)
|
||||
void FadeOutTRTiles::turnOffTile(const Vector2& pos)
|
||||
{
|
||||
Quad3 coords;
|
||||
memset(&coords, 0, sizeof(Quad3));
|
||||
setTile(pos, coords);
|
||||
}
|
||||
|
||||
void FadeOutTRTiles::transformTile(const Point& pos, float distance)
|
||||
void FadeOutTRTiles::transformTile(const Vector2& pos, float distance)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(pos);
|
||||
Point step = _gridNodeTarget->getGrid()->getStep();
|
||||
Vector2 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(Point(i, j));
|
||||
turnOffTile(Vector2(i, j));
|
||||
} else
|
||||
if (distance < 1)
|
||||
{
|
||||
transformTile(Point(i, j), distance);
|
||||
transformTile(Vector2(i, j), distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
turnOnTile(Point(i, j));
|
||||
turnOnTile(Vector2(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ FadeOutBLTiles* FadeOutBLTiles::clone() const
|
|||
|
||||
float FadeOutBLTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
Vector2 n = Vector2((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)
|
||||
{
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
Vector2 n = Vector2((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 Point& pos, float distance)
|
||||
void FadeOutUpTiles::transformTile(const Vector2& pos, float distance)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(pos);
|
||||
Point step = _gridNodeTarget->getGrid()->getStep();
|
||||
Vector2 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)
|
||||
{
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
Vector2 n = Vector2((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 Point& pos)
|
||||
void TurnOffTiles::turnOnTile(const Vector2& pos)
|
||||
{
|
||||
setTile(pos, getOriginalTile(pos));
|
||||
}
|
||||
|
||||
void TurnOffTiles::turnOffTile(const Point& pos)
|
||||
void TurnOffTiles::turnOffTile(const Vector2& pos)
|
||||
{
|
||||
Quad3 coords;
|
||||
|
||||
|
@ -706,7 +706,7 @@ void TurnOffTiles::update(float time)
|
|||
for( i = 0; i < _tilesCount; i++ )
|
||||
{
|
||||
t = _tilesOrder[i];
|
||||
Point tilePos = Point( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
Vector2 tilePos = Vector2( (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(Point(i, j));
|
||||
Quad3 coords = getOriginalTile(Vector2(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(Point(i, j), coords);
|
||||
setTile(Vector2(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ void JumpTiles3D::update(float time)
|
|||
{
|
||||
for( j = 0; j < _gridSize.height; j++ )
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Point(i, j));
|
||||
Quad3 coords = getOriginalTile(Vector2(i, j));
|
||||
|
||||
if ( ((i+j) % 2) == 0 )
|
||||
{
|
||||
|
@ -856,7 +856,7 @@ void JumpTiles3D::update(float time)
|
|||
coords.tr.z += sinz2;
|
||||
}
|
||||
|
||||
setTile(Point(i, j), coords);
|
||||
setTile(Vector2(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ void SplitRows::update(float time)
|
|||
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Point(0, j));
|
||||
Quad3 coords = getOriginalTile(Vector2(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(Point(0, j), coords);
|
||||
setTile(Vector2(0, j), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,7 +975,7 @@ void SplitCols::update(float time)
|
|||
|
||||
for (i = 0; i < _gridSize.width; ++i)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Point(i, 0));
|
||||
Quad3 coords = getOriginalTile(Vector2(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(Point(i, 0), coords);
|
||||
setTile(Vector2(i, 0), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ void ClippingNode::drawFullScreenQuadClearStencil()
|
|||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
|
||||
DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1));
|
||||
DrawPrimitives::drawSolidRect(Vector2(-1,-1), Vector2(1,1), Color4F(1, 1, 1, 1));
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
@ -383,7 +383,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(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||
//ccDrawSolidRect(Vector2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||
drawFullScreenQuadClearStencil();
|
||||
|
||||
///////////////////////////////////
|
||||
|
|
|
@ -1158,9 +1158,9 @@ void Director::createStatsLabel()
|
|||
Texture2D::setDefaultAlphaPixelFormat(currentFormat);
|
||||
|
||||
const int height_spacing = 22 / CC_CONTENT_SCALE_FACTOR();
|
||||
_drawnVerticesLabel->setPosition(Point(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION);
|
||||
_drawnBatchesLabel->setPosition(Point(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION);
|
||||
_FPSLabel->setPosition(Point(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION);
|
||||
_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);
|
||||
}
|
||||
|
||||
void Director::setContentScaleFactor(float scaleFactor)
|
||||
|
|
|
@ -81,11 +81,11 @@ static inline Vector2 v2fforangle(float _a_)
|
|||
|
||||
static inline Vector2 v2fnormalize(const Vector2 &p)
|
||||
{
|
||||
Point r = Point(p.x, p.y).normalize();
|
||||
Vector2 r = Vector2(p.x, p.y).normalize();
|
||||
return v2f(r.x, r.y);
|
||||
}
|
||||
|
||||
static inline Vector2 __v2f(const Point &v)
|
||||
static inline Vector2 __v2f(const Vector2 &v)
|
||||
{
|
||||
//#ifdef __LP64__
|
||||
return v2f(v.x, v.y);
|
||||
|
@ -251,7 +251,7 @@ void DrawNode::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
}
|
||||
|
||||
void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color)
|
||||
void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
@ -272,7 +272,7 @@ void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawSegment(const Point &from, const Point &to, float radius, const Color4F &color)
|
||||
void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 6*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
@ -345,7 +345,7 @@ void DrawNode::drawSegment(const Point &from, const Point &to, float radius, con
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
{
|
||||
CCASSERT(count >= 0, "invalid count value");
|
||||
|
||||
|
@ -453,7 +453,7 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
|
|||
free(extrude);
|
||||
}
|
||||
|
||||
void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color)
|
||||
void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
@ -471,7 +471,7 @@ void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, c
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color)
|
||||
void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = (segments + 1) * 3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
@ -502,7 +502,7 @@ void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const P
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color)
|
||||
void DrawNode::drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = (segments + 1) * 3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
|
|
@ -164,10 +164,10 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
|||
Vector2* newPoints = new Vector2[numberOfPoints];
|
||||
|
||||
// iPhone and 32-bit machines optimization
|
||||
if( sizeof(Point) == sizeof(Vector2) )
|
||||
if( sizeof(Vector2) == sizeof(Vector2) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData((void*) points, numberOfPoints * sizeof(Point));
|
||||
setGLBufferData((void*) points, numberOfPoints * sizeof(Vector2));
|
||||
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);
|
||||
|
@ -225,19 +225,19 @@ void drawLine( const Vector2& origin, const Vector2& destination )
|
|||
|
||||
void drawRect( Vector2 origin, Vector2 destination )
|
||||
{
|
||||
drawLine(Point(origin.x, origin.y), Point(destination.x, origin.y));
|
||||
drawLine(Point(destination.x, origin.y), Point(destination.x, destination.y));
|
||||
drawLine(Point(destination.x, destination.y), Point(origin.x, destination.y));
|
||||
drawLine(Point(origin.x, destination.y), Point(origin.x, origin.y));
|
||||
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));
|
||||
}
|
||||
|
||||
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color )
|
||||
{
|
||||
Vector2 vertices[] = {
|
||||
origin,
|
||||
Point(destination.x, origin.y),
|
||||
Vector2(destination.x, origin.y),
|
||||
destination,
|
||||
Point(origin.x, destination.y)
|
||||
Vector2(origin.x, destination.y)
|
||||
};
|
||||
|
||||
drawSolidPoly(vertices, 4, color );
|
||||
|
@ -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(Point) == sizeof(Vector2) )
|
||||
if( sizeof(Vector2) == sizeof(Vector2) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2));
|
||||
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);
|
||||
|
@ -309,10 +309,10 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
|
|||
Vector2* newPoli = new Vector2[numberOfPoints];
|
||||
|
||||
// iPhone and 32-bit machines optimization
|
||||
if( sizeof(Point) == sizeof(Vector2) )
|
||||
if( sizeof(Vector2) == sizeof(Vector2) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2));
|
||||
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);
|
||||
|
@ -497,12 +497,12 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
|
|||
}
|
||||
|
||||
// Interpolate
|
||||
Point pp0 = config->getControlPointAtIndex(p-1);
|
||||
Point pp1 = config->getControlPointAtIndex(p+0);
|
||||
Point pp2 = config->getControlPointAtIndex(p+1);
|
||||
Point pp3 = config->getControlPointAtIndex(p+2);
|
||||
Vector2 pp0 = config->getControlPointAtIndex(p-1);
|
||||
Vector2 pp1 = config->getControlPointAtIndex(p+0);
|
||||
Vector2 pp2 = config->getControlPointAtIndex(p+1);
|
||||
Vector2 pp3 = config->getControlPointAtIndex(p+2);
|
||||
|
||||
Point newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);
|
||||
Vector2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);
|
||||
vertices[i].x = newPos.x;
|
||||
vertices[i].y = newPos.y;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Point& imageOffset /* = Point::ZERO */)
|
||||
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false);
|
||||
auto it = _atlasMap.find(atlasName);
|
||||
|
|
|
@ -665,7 +665,7 @@ void BMFontConfiguration::parseKerningEntry(std::string line)
|
|||
HASH_ADD_INT(_kerningDictionary,key, element);
|
||||
}
|
||||
|
||||
FontFNT * FontFNT::create(const std::string& fntFilePath, const Point& imageOffset /* = Point::ZERO */)
|
||||
FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
BMFontConfiguration *newConf = FNTConfigLoadFile(fntFilePath);
|
||||
if (!newConf)
|
||||
|
@ -690,7 +690,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Point& imageOffs
|
|||
return tempFont;
|
||||
}
|
||||
|
||||
FontFNT::FontFNT(BMFontConfiguration *theContfig, const Point& imageOffset /* = Point::ZERO */)
|
||||
FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
:_configuration(theContfig)
|
||||
,_imageOffset(CC_POINT_PIXELS_TO_POINTS(imageOffset))
|
||||
{
|
||||
|
|
|
@ -219,7 +219,7 @@ void GridBase::afterDraw(cocos2d::Node *target)
|
|||
|
||||
// if (target->getCamera()->isDirty())
|
||||
// {
|
||||
// Point offset = target->getAnchorPointInPoints();
|
||||
// Vector2 offset = target->getAnchorPointInPoints();
|
||||
//
|
||||
// //
|
||||
// // XXX: Camera should be applied in the AnchorPoint
|
||||
|
@ -401,7 +401,7 @@ void Grid3D::calculateVertexPoints(void)
|
|||
Vector3 l2[4] = {e, f, g, h};
|
||||
|
||||
int tex1[4] = {a*2, b*2, c*2, d*2};
|
||||
Point Tex2F[4] = {Point(x1, y1), Point(x2, y1), Point(x2, y2), Point(x1, y2)};
|
||||
Vector2 Tex2F[4] = {Vector2(x1, y1), Vector2(x2, y1), Vector2(x2, y2), Vector2(x1, y2)};
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
|
@ -425,7 +425,7 @@ void Grid3D::calculateVertexPoints(void)
|
|||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3));
|
||||
}
|
||||
|
||||
Vector3 Grid3D::getVertex(const Point& pos) const
|
||||
Vector3 Grid3D::getVertex(const Vector2& pos) const
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
|
||||
|
@ -437,7 +437,7 @@ Vector3 Grid3D::getVertex(const Point& pos) const
|
|||
return vert;
|
||||
}
|
||||
|
||||
Vector3 Grid3D::getOriginalVertex(const Point& pos) const
|
||||
Vector3 Grid3D::getOriginalVertex(const Vector2& pos) const
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
|
||||
|
@ -449,7 +449,7 @@ Vector3 Grid3D::getOriginalVertex(const Point& pos) const
|
|||
return vert;
|
||||
}
|
||||
|
||||
void Grid3D::setVertex(const Point& pos, const Vector3& vertex)
|
||||
void Grid3D::setVertex(const Vector2& pos, const Vector3& 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;
|
||||
|
@ -645,7 +645,7 @@ void TiledGrid3D::calculateVertexPoints(void)
|
|||
memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat));
|
||||
}
|
||||
|
||||
void TiledGrid3D::setTile(const Point& pos, const Quad3& coords)
|
||||
void TiledGrid3D::setTile(const Vector2& 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;
|
||||
|
@ -653,7 +653,7 @@ void TiledGrid3D::setTile(const Point& pos, const Quad3& coords)
|
|||
memcpy(&vertArray[idx], &coords, sizeof(Quad3));
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3D::getOriginalTile(const Point& pos) const
|
||||
Quad3 TiledGrid3D::getOriginalTile(const Vector2& 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;
|
||||
|
@ -665,7 +665,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Point& pos) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3D::getTile(const Point& pos) const
|
||||
Quad3 TiledGrid3D::getTile(const Vector2& 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;
|
||||
|
|
|
@ -127,7 +127,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 Point& imageOffset /* = Point::ZERO */)
|
||||
Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
auto ret = new Label(nullptr,alignment);
|
||||
|
||||
|
@ -259,7 +259,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
|||
, _contentDirty(false)
|
||||
, _shadowDirty(false)
|
||||
{
|
||||
setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
reset();
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||
|
@ -394,7 +394,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
|
|||
_reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0));
|
||||
_reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||
_reusedLetter->retain();
|
||||
_reusedLetter->setAnchorPoint(Point::ANCHOR_TOP_LEFT);
|
||||
_reusedLetter->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT);
|
||||
_reusedLetter->setBatchNode(this);
|
||||
}
|
||||
else
|
||||
|
@ -452,7 +452,7 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& imageOffset /* = Point::ZERO */)
|
||||
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
|
||||
|
||||
|
@ -586,8 +586,8 @@ void Label::alignText()
|
|||
for (auto index = _batchNodes.size(); index < textures.size(); ++index)
|
||||
{
|
||||
auto batchNode = SpriteBatchNode::createWithTexture(textures[index]);
|
||||
batchNode->setAnchorPoint(Point::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Point::ZERO);
|
||||
batchNode->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Vector2::ZERO);
|
||||
Node::addChild(batchNode,0,Node::INVALID_TAG);
|
||||
_batchNodes.push_back(batchNode);
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ void Label::updateQuads()
|
|||
}
|
||||
}
|
||||
|
||||
bool Label::recordLetterInfo(const cocos2d::Point& point,const FontLetterDefinition& letterDef, int spriteIndex)
|
||||
bool Label::recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex)
|
||||
{
|
||||
if (static_cast<std::size_t>(spriteIndex) >= _lettersInfo.size())
|
||||
{
|
||||
|
@ -915,7 +915,7 @@ void Label::createSpriteWithFontDefinition()
|
|||
texture->initWithString(_originalUTF8String.c_str(),_fontDefinition);
|
||||
|
||||
_textSprite = Sprite::createWithTexture(texture);
|
||||
_textSprite->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||
_textSprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
this->setContentSize(_textSprite->getContentSize());
|
||||
texture->release();
|
||||
if (_blendFuncDirty)
|
||||
|
@ -1040,7 +1040,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
|
|||
{
|
||||
_shadowNode->setBlendFunc(_blendFunc);
|
||||
}
|
||||
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||
_shadowNode->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
_shadowNode->setColor(_shadowColor);
|
||||
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
|
||||
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
|
||||
|
@ -1167,7 +1167,7 @@ Sprite * Label::getLetter(int letterIndex)
|
|||
|
||||
sp = Sprite::createWithTexture(_fontAtlas->getTexture(letter.def.textureID),uvRect);
|
||||
sp->setBatchNode(_batchNodes[letter.def.textureID]);
|
||||
sp->setPosition(Point(letter.position.x + uvRect.size.width / 2,
|
||||
sp->setPosition(Vector2(letter.position.x + uvRect.size.width / 2,
|
||||
letter.position.y - uvRect.size.height / 2));
|
||||
sp->setOpacity(_realOpacity);
|
||||
|
||||
|
|
|
@ -251,9 +251,9 @@ void LabelAtlas::draw()
|
|||
AtlasNode::draw();
|
||||
|
||||
const Size& s = this->getContentSize();
|
||||
Point vertices[4]={
|
||||
Point(0,0),Point(s.width,0),
|
||||
Point(s.width,s.height),Point(0,s.height),
|
||||
Vector2 vertices[4]={
|
||||
Vector2(0,0),Vector2(s.width,0),
|
||||
Vector2(s.width,s.height),Vector2(0,s.height),
|
||||
};
|
||||
ccDrawPoly(vertices, 4, true);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,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 Point& imageOffset /* = Point::ZERO */)
|
||||
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
LabelBMFont *ret = new LabelBMFont();
|
||||
if(ret && ret->initWithString(str, fntFile, width, alignment,imageOffset))
|
||||
|
@ -72,7 +72,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 Point& imageOffset /* = Point::ZERO */)
|
||||
bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
if (_label->setBMFontFilePath(fntFile,imageOffset))
|
||||
{
|
||||
|
@ -90,9 +90,9 @@ bool LabelBMFont::initWithString(const std::string& str, const std::string& fntF
|
|||
LabelBMFont::LabelBMFont()
|
||||
{
|
||||
_label = Label::create();
|
||||
_label->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||
_label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
this->addChild(_label);
|
||||
this->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
this->setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
_cascadeOpacityEnabled = true;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ void LabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace )
|
|||
}
|
||||
|
||||
// LabelBMFont - FntFile
|
||||
void LabelBMFont::setFntFile(const std::string& fntFile, const Point& imageOffset /* = Point::ZERO */)
|
||||
void LabelBMFont::setFntFile(const std::string& fntFile, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
{
|
||||
if (_fntFile.compare(fntFile) != 0)
|
||||
{
|
||||
|
@ -207,9 +207,9 @@ Rect LabelBMFont::getBoundingBox() const
|
|||
void LabelBMFont::draw()
|
||||
{
|
||||
const Size& s = this->getContentSize();
|
||||
Point vertices[4]={
|
||||
Point(0,0),Point(s.width,0),
|
||||
Point(s.width,s.height),Point(0,s.height),
|
||||
Vector2 vertices[4]={
|
||||
Vector2(0,0),Vector2(s.width,0),
|
||||
Vector2(s.width,s.height),Vector2(0,s.height),
|
||||
};
|
||||
ccDrawPoly(vertices, 4, true);
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ NS_CC_BEGIN
|
|||
LabelTTF::LabelTTF()
|
||||
{
|
||||
_renderLabel = Label::create();
|
||||
_renderLabel->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||
_renderLabel->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
this->addChild(_renderLabel);
|
||||
this->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
this->setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
|
||||
_contentDirty = false;
|
||||
_cascadeColorEnabled = true;
|
||||
|
|
|
@ -319,7 +319,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
auto strWhole = theLabel->_currentUTF16String;
|
||||
auto fontAtlas = theLabel->_fontAtlas;
|
||||
FontLetterDefinition tempDefinition;
|
||||
Point letterPosition;
|
||||
Vector2 letterPosition;
|
||||
const auto& kernings = theLabel->_horizontalKernings;
|
||||
|
||||
float clipTop = 0;
|
||||
|
|
|
@ -62,7 +62,7 @@ Layer::Layer()
|
|||
, _swallowsTouches(true)
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Layer::~Layer()
|
||||
|
@ -637,7 +637,7 @@ LayerGradient::LayerGradient()
|
|||
, _endColor(Color4B::BLACK)
|
||||
, _startOpacity(255)
|
||||
, _endOpacity(255)
|
||||
, _alongVector(Point(0, -1))
|
||||
, _alongVector(Vector2(0, -1))
|
||||
, _compressedInterpolation(true)
|
||||
{
|
||||
|
||||
|
@ -659,7 +659,7 @@ LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Point& v)
|
||||
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vector2& v)
|
||||
{
|
||||
LayerGradient * layer = new LayerGradient();
|
||||
if( layer && layer->initWithColor(start, end, v))
|
||||
|
@ -692,10 +692,10 @@ bool LayerGradient::init()
|
|||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end)
|
||||
{
|
||||
return initWithColor(start, end, Point(0, -1));
|
||||
return initWithColor(start, end, Vector2(0, -1));
|
||||
}
|
||||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Point& v)
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vector2& v)
|
||||
{
|
||||
_endColor.r = end.r;
|
||||
_endColor.g = end.g;
|
||||
|
@ -719,7 +719,7 @@ void LayerGradient::updateColor()
|
|||
return;
|
||||
|
||||
float c = sqrtf(2.0f);
|
||||
Point u = Point(_alongVector.x / h, _alongVector.y / h);
|
||||
Vector2 u = Vector2(_alongVector.x / h, _alongVector.y / h);
|
||||
|
||||
// Compressed Interpolation mode
|
||||
if (_compressedInterpolation)
|
||||
|
@ -809,13 +809,13 @@ GLubyte LayerGradient::getEndOpacity() const
|
|||
return _endOpacity;
|
||||
}
|
||||
|
||||
void LayerGradient::setVector(const Point& var)
|
||||
void LayerGradient::setVector(const Vector2& var)
|
||||
{
|
||||
_alongVector = var;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
const Point& LayerGradient::getVector() const
|
||||
const Vector2& LayerGradient::getVector() const
|
||||
{
|
||||
return _alongVector;
|
||||
}
|
||||
|
|
|
@ -138,10 +138,10 @@ bool Menu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
|
|||
Size s = Director::getInstance()->getWinSize();
|
||||
|
||||
this->ignoreAnchorPointForPosition(true);
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
this->setContentSize(s);
|
||||
|
||||
setPosition(Point(s.width/2, s.height/2));
|
||||
setPosition(Vector2(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(Point(0, y - child->getContentSize().height * child->getScaleY() / 2.0f));
|
||||
child->setPosition(Vector2(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(Point(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0));
|
||||
child->setPosition(Vector2(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(Point(x - winSize.width / 2,
|
||||
child->setPosition(Vector2(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(Point(x + columnWidths[column] / 2,
|
||||
child->setPosition(Vector2(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)
|
||||
{
|
||||
Point touchLocation = touch->getLocation();
|
||||
Vector2 touchLocation = touch->getLocation();
|
||||
|
||||
if (!_children.empty())
|
||||
{
|
||||
|
@ -542,9 +542,9 @@ MenuItem* Menu::getItemForTouch(Touch *touch)
|
|||
MenuItem* child = dynamic_cast<MenuItem*>(*iter);
|
||||
if (child && child->isVisible() && child->isEnabled())
|
||||
{
|
||||
Point local = child->convertToNodeSpace(touchLocation);
|
||||
Vector2 local = child->convertToNodeSpace(touchLocation);
|
||||
Rect r = child->rect();
|
||||
r.origin = Point::ZERO;
|
||||
r.origin = Vector2::ZERO;
|
||||
|
||||
if (r.containsPoint(local))
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ bool MenuItem::initWithTarget(cocos2d::Ref *target, SEL_MenuHandler selector )
|
|||
|
||||
bool MenuItem::initWithCallback(const ccMenuCallback& callback)
|
||||
{
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
_callback = callback;
|
||||
_enabled = true;
|
||||
_selected = false;
|
||||
|
@ -179,7 +179,7 @@ void MenuItemLabel::setLabel(Node* var)
|
|||
{
|
||||
if (var)
|
||||
{
|
||||
var->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||
var->setAnchorPoint(Vector2::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(Point(0, 0));
|
||||
image->setAnchorPoint(Vector2(0, 0));
|
||||
}
|
||||
|
||||
if (_normalImage)
|
||||
|
@ -504,7 +504,7 @@ void MenuItemSprite::setSelectedImage(Node* image)
|
|||
if (image)
|
||||
{
|
||||
addChild(image, 0, kSelectedTag);
|
||||
image->setAnchorPoint(Point(0, 0));
|
||||
image->setAnchorPoint(Vector2(0, 0));
|
||||
}
|
||||
|
||||
if (_selectedImage)
|
||||
|
@ -524,7 +524,7 @@ void MenuItemSprite::setDisabledImage(Node* image)
|
|||
if (image)
|
||||
{
|
||||
addChild(image, 0, kDisableTag);
|
||||
image->setAnchorPoint(Point(0, 0));
|
||||
image->setAnchorPoint(Vector2(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( Point( s.width/2, s.height/2 ) );
|
||||
item->setPosition( Vector2( s.width/2, s.height/2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ MotionStreak::MotionStreak()
|
|||
, _startingPositionInitialized(false)
|
||||
, _texture(nullptr)
|
||||
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
, _positionR(Point::ZERO)
|
||||
, _positionR(Vector2::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(Point::ZERO);
|
||||
setAnchorPoint(Point::ZERO);
|
||||
Node::setPosition(Vector2::ZERO);
|
||||
setAnchorPoint(Vector2::ZERO);
|
||||
ignoreAnchorPointForPosition(true);
|
||||
_startingPositionInitialized = false;
|
||||
|
||||
_positionR = Point::ZERO;
|
||||
_positionR = Vector2::ZERO;
|
||||
_fastMode = true;
|
||||
_minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg;
|
||||
_minSeg *= _minSeg;
|
||||
|
@ -118,7 +118,7 @@ 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 = (Point*)malloc(sizeof(Point) * _maxPoints);
|
||||
_pointVertexes = (Vector2*)malloc(sizeof(Vector2) * _maxPoints);
|
||||
|
||||
_vertices = (Vector2*)malloc(sizeof(Vector2) * _maxPoints * 2);
|
||||
_texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2);
|
||||
|
|
|
@ -83,11 +83,11 @@ Node::Node(void)
|
|||
, _scaleY(1.0f)
|
||||
, _scaleZ(1.0f)
|
||||
, _positionZ(0.0f)
|
||||
, _position(Point::ZERO)
|
||||
, _position(Vector2::ZERO)
|
||||
, _skewX(0.0f)
|
||||
, _skewY(0.0f)
|
||||
, _anchorPointInPoints(Point::ZERO)
|
||||
, _anchorPoint(Point::ZERO)
|
||||
, _anchorPointInPoints(Vector2::ZERO)
|
||||
, _anchorPoint(Vector2::ZERO)
|
||||
, _contentSize(Size::ZERO)
|
||||
, _useAdditionalTransform(false)
|
||||
, _transformDirty(true)
|
||||
|
@ -442,13 +442,13 @@ void Node::getPosition(float* x, float* y) const
|
|||
|
||||
void Node::setPosition(float x, float y)
|
||||
{
|
||||
setPosition(Point(x, y));
|
||||
setPosition(Vector2(x, y));
|
||||
}
|
||||
|
||||
void Node::setPosition3D(const Vector3& position)
|
||||
{
|
||||
_positionZ = position.z;
|
||||
setPosition(Point(position.x, position.y));
|
||||
setPosition(Vector2(position.x, position.y));
|
||||
}
|
||||
|
||||
Vector3 Node::getPosition3D() const
|
||||
|
@ -467,7 +467,7 @@ float Node::getPositionX() const
|
|||
|
||||
void Node::setPositionX(float x)
|
||||
{
|
||||
setPosition(Point(x, _position.y));
|
||||
setPosition(Vector2(x, _position.y));
|
||||
}
|
||||
|
||||
float Node::getPositionY() const
|
||||
|
@ -477,7 +477,7 @@ float Node::getPositionY() const
|
|||
|
||||
void Node::setPositionY(float y)
|
||||
{
|
||||
setPosition(Point(_position.x, y));
|
||||
setPosition(Vector2(_position.x, y));
|
||||
}
|
||||
|
||||
float Node::getPositionZ() const
|
||||
|
@ -534,7 +534,7 @@ const Vector2& Node::getAnchorPoint() const
|
|||
void Node::setAnchorPoint(const Vector2& point)
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr && !point.equals(Point::ANCHOR_MIDDLE))
|
||||
if (_physicsBody != nullptr && !point.equals(Vector2::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;
|
||||
|
@ -544,7 +544,7 @@ void Node::setAnchorPoint(const Vector2& point)
|
|||
if( ! point.equals(_anchorPoint))
|
||||
{
|
||||
_anchorPoint = point;
|
||||
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ void Node::setContentSize(const Size & size)
|
|||
{
|
||||
_contentSize = size;
|
||||
|
||||
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -1354,7 +1354,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(Point::ZERO))
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vector2::ZERO))
|
||||
{
|
||||
x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY;
|
||||
y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY;
|
||||
|
@ -1397,7 +1397,7 @@ const Matrix& Node::getNodeToParentTransform() const
|
|||
_transform = _transform * skewMatrix;
|
||||
|
||||
// adjust anchor point
|
||||
if (!_anchorPointInPoints.equals(Point::ZERO))
|
||||
if (!_anchorPointInPoints.equals(Vector2::ZERO))
|
||||
{
|
||||
// XXX: Argh, Matrix needs a "translate" method.
|
||||
// XXX: Although this is faster than multiplying a vec4 * mat4
|
||||
|
@ -1535,16 +1535,16 @@ Vector2 Node::convertToWindowSpace(const Vector2& nodePoint) const
|
|||
return Director::getInstance()->convertToUI(worldPoint);
|
||||
}
|
||||
|
||||
// convenience methods which take a Touch instead of Point
|
||||
// convenience methods which take a Touch instead of Vector2
|
||||
Vector2 Node::convertTouchToNodeSpace(Touch *touch) const
|
||||
{
|
||||
Point point = touch->getLocation();
|
||||
Vector2 point = touch->getLocation();
|
||||
return this->convertToNodeSpace(point);
|
||||
}
|
||||
|
||||
Vector2 Node::convertTouchToNodeSpaceAR(Touch *touch) const
|
||||
{
|
||||
Point point = touch->getLocation();
|
||||
Vector2 point = touch->getLocation();
|
||||
return this->convertToNodeSpaceAR(point);
|
||||
}
|
||||
|
||||
|
@ -1593,10 +1593,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(Point::ANCHOR_MIDDLE))
|
||||
if (!getAnchorPoint().equals(Vector2::ANCHOR_MIDDLE))
|
||||
{
|
||||
CCLOG("Node warning: setPhysicsBody sets anchor point to Point::ANCHOR_MIDDLE.");
|
||||
setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
CCLOG("Node warning: setPhysicsBody sets anchor point to Vector2::ANCHOR_MIDDLE.");
|
||||
setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ NS_CC_BEGIN
|
|||
class PointObject : public Ref
|
||||
{
|
||||
public:
|
||||
static PointObject * create(Point ratio, Point offset)
|
||||
static PointObject * create(Vector2 ratio, Vector2 offset)
|
||||
{
|
||||
PointObject *ret = new PointObject();
|
||||
ret->initWithPoint(ratio, offset);
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool initWithPoint(Point ratio, Point offset)
|
||||
bool initWithPoint(Vector2 ratio, Vector2 offset)
|
||||
{
|
||||
_ratio = ratio;
|
||||
_offset = offset;
|
||||
|
@ -48,25 +48,25 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
inline const Point& getRatio() const { return _ratio; };
|
||||
inline void setRatio(const Point& ratio) { _ratio = ratio; };
|
||||
inline const Vector2& getRatio() const { return _ratio; };
|
||||
inline void setRatio(const Vector2& ratio) { _ratio = ratio; };
|
||||
|
||||
inline const Point& getOffset() const { return _offset; };
|
||||
inline void setOffset(const Point& offset) { _offset = offset; };
|
||||
inline const Vector2& getOffset() const { return _offset; };
|
||||
inline void setOffset(const Vector2& offset) { _offset = offset; };
|
||||
|
||||
inline Node* getChild() const { return _child; };
|
||||
inline void setChild(Node* child) { _child = child; };
|
||||
|
||||
private:
|
||||
Point _ratio;
|
||||
Point _offset;
|
||||
Vector2 _ratio;
|
||||
Vector2 _offset;
|
||||
Node *_child; // weak ref
|
||||
};
|
||||
|
||||
ParallaxNode::ParallaxNode()
|
||||
{
|
||||
_parallaxArray = ccArrayNew(5);
|
||||
_lastPosition = Point(-100,-100);
|
||||
_lastPosition = Vector2(-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 Point& ratio, const Point& offset)
|
||||
void ParallaxNode::addChild(Node *child, int z, const Vector2& ratio, const Vector2& offset)
|
||||
{
|
||||
CCASSERT( child != nullptr, "Argument must be non-nil");
|
||||
PointObject *obj = PointObject::create(ratio, offset);
|
||||
obj->setChild(child);
|
||||
ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj);
|
||||
|
||||
Point pos = this->absolutePosition();
|
||||
Vector2 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);
|
||||
}
|
||||
|
||||
Point ParallaxNode::absolutePosition()
|
||||
Vector2 ParallaxNode::absolutePosition()
|
||||
{
|
||||
Point ret = _position;
|
||||
Vector2 ret = _position;
|
||||
Node *cn = this;
|
||||
while (cn->getParent() != nullptr)
|
||||
{
|
||||
|
@ -147,9 +147,9 @@ The positions are updated at visit because:
|
|||
*/
|
||||
void ParallaxNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
// Point pos = position_;
|
||||
// Point pos = [self convertToWorldSpace:Point::ZERO];
|
||||
Point pos = this->absolutePosition();
|
||||
// Vector2 pos = position_;
|
||||
// Vector2 pos = [self convertToWorldSpace:Vector2::ZERO];
|
||||
Vector2 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(Point(x,y));
|
||||
point->getChild()->setPosition(Vector2(x,y));
|
||||
}
|
||||
_lastPosition = pos;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
|
|||
this->_emitterMode = Mode::GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Point(0,0);
|
||||
this->modeA.gravity = Vector2(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(Point(winSize.width/2, 60));
|
||||
this->_posVar = Point(40, 20);
|
||||
this->setPosition(Vector2(winSize.width/2, 60));
|
||||
this->_posVar = Vector2(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 = Point(0,-90);
|
||||
this->modeA.gravity = Vector2(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(Point(winSize.width/2, winSize.height/2));
|
||||
this->setPosition(Vector2(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(Point(0,0));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 1;
|
||||
|
@ -411,7 +411,7 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -520,7 +520,7 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -628,7 +628,7 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(-200,200));
|
||||
setGravity(Vector2(-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(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 2;
|
||||
|
@ -737,7 +737,7 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 12;
|
||||
|
@ -845,7 +845,7 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 5.0f;
|
||||
|
@ -954,7 +954,7 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, 0));
|
||||
setPosVar(Point(20, 0));
|
||||
this->setPosition(Vector2(winSize.width/2, 0));
|
||||
setPosVar(Vector2(20, 0));
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -1059,7 +1059,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,-1));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height + 10));
|
||||
setPosVar(Point(winSize.width/2, 0));
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height + 10));
|
||||
setPosVar(Vector2(winSize.width/2, 0));
|
||||
|
||||
// angle
|
||||
_angle = -90;
|
||||
|
@ -1166,7 +1166,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(10,-10));
|
||||
setGravity(Vector2(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(Point(winSize.width/2, winSize.height));
|
||||
setPosVar(Point(winSize.width/2, 0));
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height));
|
||||
setPosVar(Vector2(winSize.width/2, 0));
|
||||
|
||||
// life of particles
|
||||
_life = 4.5f;
|
||||
|
|
|
@ -97,8 +97,8 @@ ParticleSystem::ParticleSystem()
|
|||
, _isActive(true)
|
||||
, _particleCount(0)
|
||||
, _duration(0)
|
||||
, _sourcePosition(Point::ZERO)
|
||||
, _posVar(Point::ZERO)
|
||||
, _sourcePosition(Vector2::ZERO)
|
||||
, _posVar(Vector2::ZERO)
|
||||
, _life(0)
|
||||
, _lifeVar(0)
|
||||
, _angle(0)
|
||||
|
@ -120,7 +120,7 @@ ParticleSystem::ParticleSystem()
|
|||
, _yCoordFlipped(0)
|
||||
, _positionType(PositionType::FREE)
|
||||
{
|
||||
modeA.gravity = Point::ZERO;
|
||||
modeA.gravity = Vector2::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( Point(x,y) );
|
||||
this->setPosition( Vector2(x,y) );
|
||||
_posVar.x = dictionary["sourcePositionVariancex"].asFloat();
|
||||
_posVar.y = dictionary["sourcePositionVariancey"].asFloat();
|
||||
|
||||
|
@ -562,7 +562,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
// position
|
||||
if (_positionType == PositionType::FREE)
|
||||
{
|
||||
particle->startPos = this->convertToWorldSpace(Point::ZERO);
|
||||
particle->startPos = this->convertToWorldSpace(Vector2::ZERO);
|
||||
}
|
||||
else if (_positionType == PositionType::RELATIVE)
|
||||
{
|
||||
|
@ -575,7 +575,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
// Mode Gravity: A
|
||||
if (_emitterMode == Mode::GRAVITY)
|
||||
{
|
||||
Point v(cosf( a ), sinf( a ));
|
||||
Vector2 v(cosf( a ), sinf( a ));
|
||||
float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1();
|
||||
|
||||
// direction
|
||||
|
@ -681,10 +681,10 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
_particleIdx = 0;
|
||||
|
||||
Point currentPosition = Point::ZERO;
|
||||
Vector2 currentPosition = Vector2::ZERO;
|
||||
if (_positionType == PositionType::FREE)
|
||||
{
|
||||
currentPosition = this->convertToWorldSpace(Point::ZERO);
|
||||
currentPosition = this->convertToWorldSpace(Vector2::ZERO);
|
||||
}
|
||||
else if (_positionType == PositionType::RELATIVE)
|
||||
{
|
||||
|
@ -704,9 +704,9 @@ void ParticleSystem::update(float dt)
|
|||
// Mode A: gravity, direction, tangential accel & radial accel
|
||||
if (_emitterMode == Mode::GRAVITY)
|
||||
{
|
||||
Point tmp, radial, tangential;
|
||||
Vector2 tmp, radial, tangential;
|
||||
|
||||
radial = Point::ZERO;
|
||||
radial = Vector2::ZERO;
|
||||
// radial acceleration
|
||||
if (p->pos.x || p->pos.y)
|
||||
{
|
||||
|
@ -775,11 +775,11 @@ void ParticleSystem::update(float dt)
|
|||
// update values in quad
|
||||
//
|
||||
|
||||
Point newPos;
|
||||
Vector2 newPos;
|
||||
|
||||
if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE)
|
||||
{
|
||||
Point diff = currentPosition - p->startPos;
|
||||
Vector2 diff = currentPosition - p->startPos;
|
||||
newPos = p->pos - diff;
|
||||
}
|
||||
else
|
||||
|
@ -846,7 +846,7 @@ void ParticleSystem::updateWithNoTime(void)
|
|||
this->update(0.0f);
|
||||
}
|
||||
|
||||
void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Point& newPosition)
|
||||
void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition)
|
||||
{
|
||||
CC_UNUSED_PARAM(particle);
|
||||
CC_UNUSED_PARAM(newPosition);
|
||||
|
@ -981,13 +981,13 @@ bool ParticleSystem::getRotationIsDir() const
|
|||
return modeA.rotationIsDir;
|
||||
}
|
||||
|
||||
void ParticleSystem::setGravity(const Point& g)
|
||||
void ParticleSystem::setGravity(const Vector2& g)
|
||||
{
|
||||
CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity");
|
||||
modeA.gravity = g;
|
||||
}
|
||||
|
||||
const Point& ParticleSystem::getGravity()
|
||||
const Vector2& ParticleSystem::getGravity()
|
||||
{
|
||||
CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.gravity;
|
||||
|
|
|
@ -229,7 +229,7 @@ void ParticleSystemQuad::setTexture(Texture2D* texture)
|
|||
|
||||
void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame)
|
||||
{
|
||||
CCASSERT(spriteFrame->getOffsetInPixels().equals(Point::ZERO),
|
||||
CCASSERT(spriteFrame->getOffsetInPixels().equals(Vector2::ZERO),
|
||||
"QuadParticle only supports SpriteFrames with no offsets");
|
||||
|
||||
// update texture before updating texture rect
|
||||
|
@ -255,7 +255,7 @@ void ParticleSystemQuad::initIndices()
|
|||
}
|
||||
}
|
||||
|
||||
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point& newPosition)
|
||||
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition)
|
||||
{
|
||||
V3F_C4B_T2F_Quad *quad;
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
|
|||
_vertexData = nullptr;
|
||||
_vertexDataCount = 0;
|
||||
|
||||
setAnchorPoint(Point(0.5f,0.5f));
|
||||
setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
_type = Type::RADIAL;
|
||||
_reverseDirection = false;
|
||||
setMidpoint(Point(0.5f, 0.5f));
|
||||
setBarChangeRate(Point(1,1));
|
||||
setMidpoint(Vector2(0.5f, 0.5f));
|
||||
setBarChangeRate(Vector2(1,1));
|
||||
setSprite(sp);
|
||||
// shader program
|
||||
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
@ -157,15 +157,15 @@ void ProgressTimer::setReverseProgress(bool reverse)
|
|||
///
|
||||
// @returns the vertex position from the texture coordinate
|
||||
///
|
||||
Tex2F ProgressTimer::textureCoordFromAlphaPoint(Point alpha)
|
||||
Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha)
|
||||
{
|
||||
Tex2F ret(0.0f, 0.0f);
|
||||
if (!_sprite) {
|
||||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Point min = Point(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Point max = Point(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
Vector2 min = Vector2(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Vector2 max = Vector2(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);
|
||||
|
@ -173,15 +173,15 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Point 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(Point alpha)
|
||||
Vector2 ProgressTimer::vertexFromAlphaPoint(Vector2 alpha)
|
||||
{
|
||||
Vector2 ret(0.0f, 0.0f);
|
||||
if (!_sprite) {
|
||||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Point min = Point(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Point max = Point(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
Vector2 min = Vector2(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Vector2 max = Vector2(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;
|
||||
|
@ -223,7 +223,7 @@ void ProgressTimer::setAnchorPoint(const Vector2& anchorPoint)
|
|||
Node::setAnchorPoint(anchorPoint);
|
||||
}
|
||||
|
||||
Point ProgressTimer::getMidpoint() const
|
||||
Vector2 ProgressTimer::getMidpoint() const
|
||||
{
|
||||
return _midpoint;
|
||||
}
|
||||
|
@ -250,9 +250,9 @@ GLubyte ProgressTimer::getOpacity() const
|
|||
return _sprite->getOpacity();
|
||||
}
|
||||
|
||||
void ProgressTimer::setMidpoint(const Point& midPoint)
|
||||
void ProgressTimer::setMidpoint(const Vector2& midPoint)
|
||||
{
|
||||
_midpoint = midPoint.getClampPoint(Point::ZERO, Point(1, 1));
|
||||
_midpoint = midPoint.getClampPoint(Vector2::ZERO, Vector2(1, 1));
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -276,12 +276,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
|
||||
Point topMid = Point(_midpoint.x, 1.f);
|
||||
Point percentagePt = topMid.rotateByAngle(_midpoint, angle);
|
||||
Vector2 topMid = Vector2(_midpoint.x, 1.f);
|
||||
Vector2 percentagePt = topMid.rotateByAngle(_midpoint, angle);
|
||||
|
||||
|
||||
int index = 0;
|
||||
Point hit = Point::ZERO;
|
||||
Vector2 hit = Vector2::ZERO;
|
||||
|
||||
if (alpha == 0.f) {
|
||||
// More efficient since we don't always need to check intersection
|
||||
|
@ -303,8 +303,8 @@ void ProgressTimer::updateRadial(void)
|
|||
for (int i = 0; i <= kProgressTextureCoordsCount; ++i) {
|
||||
int pIndex = (i + (kProgressTextureCoordsCount - 1))%kProgressTextureCoordsCount;
|
||||
|
||||
Point edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount);
|
||||
Point edgePtB = boundaryTexCoord(pIndex);
|
||||
Vector2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount);
|
||||
Vector2 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
|
||||
|
@ -316,7 +316,7 @@ void ProgressTimer::updateRadial(void)
|
|||
|
||||
// s and t are returned by ccpLineIntersect
|
||||
float s = 0, t = 0;
|
||||
if(Point::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
|
||||
if(Vector2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
|
||||
{
|
||||
|
||||
// Since our hit test is on rays we have to deal with the top edge
|
||||
|
@ -375,7 +375,7 @@ void ProgressTimer::updateRadial(void)
|
|||
_vertexData[1].vertices = vertexFromAlphaPoint(topMid);
|
||||
|
||||
for(int i = 0; i < index; ++i){
|
||||
Point alphaPoint = boundaryTexCoord(i);
|
||||
Vector2 alphaPoint = boundaryTexCoord(i);
|
||||
_vertexData[i+2].texCoords = textureCoordFromAlphaPoint(alphaPoint);
|
||||
_vertexData[i+2].vertices = vertexFromAlphaPoint(alphaPoint);
|
||||
}
|
||||
|
@ -402,9 +402,9 @@ void ProgressTimer::updateBar(void)
|
|||
return;
|
||||
}
|
||||
float alpha = _percentage / 100.0f;
|
||||
Point alphaOffset = Point(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f;
|
||||
Point min = _midpoint - alphaOffset;
|
||||
Point max = _midpoint + alphaOffset;
|
||||
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;
|
||||
|
||||
if (min.x < 0.f) {
|
||||
max.x += -min.x;
|
||||
|
@ -434,71 +434,71 @@ void ProgressTimer::updateBar(void)
|
|||
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
|
||||
}
|
||||
// TOPLEFT
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Point(min.x,max.y));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y));
|
||||
|
||||
// BOTLEFT
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Point(min.x,min.y));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Point(min.x,min.y));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y));
|
||||
|
||||
// TOPRIGHT
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Point(max.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Point(max.x,max.y));
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y));
|
||||
|
||||
// BOTRIGHT
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Point(max.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Point(max.x,min.y));
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Vector2(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(Point(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Point(0,1));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vector2(0,1));
|
||||
|
||||
// BOTLEFT 1
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Point(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Point(0,0));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vector2(0,0));
|
||||
|
||||
// TOPRIGHT 2
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Point(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Point(1,1));
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Vector2(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Vector2(1,1));
|
||||
|
||||
// BOTRIGHT 2
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Point(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Point(1,0));
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Vector2(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Vector2(1,0));
|
||||
}
|
||||
|
||||
// TOPRIGHT 1
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Point(min.x,max.y));
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y));
|
||||
|
||||
// BOTRIGHT 1
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Point(min.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Point(min.x,min.y));
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y));
|
||||
|
||||
// TOPLEFT 2
|
||||
_vertexData[4].texCoords = textureCoordFromAlphaPoint(Point(max.x,max.y));
|
||||
_vertexData[4].vertices = vertexFromAlphaPoint(Point(max.x,max.y));
|
||||
_vertexData[4].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y));
|
||||
_vertexData[4].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y));
|
||||
|
||||
// BOTLEFT 2
|
||||
_vertexData[5].texCoords = textureCoordFromAlphaPoint(Point(max.x,min.y));
|
||||
_vertexData[5].vertices = vertexFromAlphaPoint(Point(max.x,min.y));
|
||||
_vertexData[5].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y));
|
||||
_vertexData[5].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y));
|
||||
}
|
||||
updateColor();
|
||||
}
|
||||
|
||||
Point ProgressTimer::boundaryTexCoord(char index)
|
||||
Vector2 ProgressTimer::boundaryTexCoord(char index)
|
||||
{
|
||||
if (index < kProgressTextureCoordsCount) {
|
||||
if (_reverseDirection) {
|
||||
return Point((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
|
||||
return Vector2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
|
||||
} else {
|
||||
return Point((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
|
||||
return Vector2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
|
||||
}
|
||||
}
|
||||
return Point::ZERO;
|
||||
return Vector2::ZERO;
|
||||
}
|
||||
|
||||
void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated)
|
||||
|
|
|
@ -306,7 +306,7 @@ void RenderTexture::setKeepMatrix(bool keepMatrix)
|
|||
_keepMatrix = keepMatrix;
|
||||
}
|
||||
|
||||
void RenderTexture::setVirtualViewport(const Point& rtBegin, const Rect& fullRect, const Rect& fullViewport)
|
||||
void RenderTexture::setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport)
|
||||
{
|
||||
_rtTextureRect.origin.x = rtBegin.x;
|
||||
_rtTextureRect.origin.y = rtBegin.y;
|
||||
|
|
|
@ -41,7 +41,7 @@ Scene::Scene()
|
|||
#endif
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
|
|
@ -236,10 +236,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
|||
_flippedX = _flippedY = false;
|
||||
|
||||
// default transform anchor: center
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
|
||||
// zwoptex default values
|
||||
_offsetPosition = Point::ZERO;
|
||||
_offsetPosition = Vector2::ZERO;
|
||||
|
||||
// clean the Quad
|
||||
memset(&_quad, 0, sizeof(_quad));
|
||||
|
@ -369,7 +369,7 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
|
|||
setVertexRect(rect);
|
||||
setTextureCoords(rect);
|
||||
|
||||
Point relativeOffset = _unflippedOffsetPositionFromCenter;
|
||||
Vector2 relativeOffset = _unflippedOffsetPositionFromCenter;
|
||||
|
||||
// issue #732
|
||||
if (_flippedX)
|
||||
|
@ -610,11 +610,11 @@ void Sprite::drawDebugData()
|
|||
oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
// draw bounding box
|
||||
Point vertices[4] = {
|
||||
Point( _quad.bl.vertices.x, _quad.bl.vertices.y ),
|
||||
Point( _quad.br.vertices.x, _quad.br.vertices.y ),
|
||||
Point( _quad.tr.vertices.x, _quad.tr.vertices.y ),
|
||||
Point( _quad.tl.vertices.x, _quad.tl.vertices.y ),
|
||||
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 ),
|
||||
};
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
|
|
|
@ -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 Point& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& 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 Point& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& 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, Point::ZERO, rectInPixels.size);
|
||||
return initWithTexture(texture, rectInPixels, false, Vector2::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, Point::ZERO, rectInPixels.size);
|
||||
return initWithTextureFilename(filename, rectInPixels, false, Vector2::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& 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 Point& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vector2& 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 Point& SpriteFrame::getOffset() const
|
||||
const Vector2& SpriteFrame::getOffset() const
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
void SpriteFrame::setOffset(const Point& offsets)
|
||||
void SpriteFrame::setOffset(const Vector2& offsets)
|
||||
{
|
||||
_offset = offsets;
|
||||
_offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset );
|
||||
}
|
||||
|
||||
const Point& SpriteFrame::getOffsetInPixels() const
|
||||
const Vector2& SpriteFrame::getOffsetInPixels() const
|
||||
{
|
||||
return _offsetInPixels;
|
||||
}
|
||||
|
||||
void SpriteFrame::setOffsetInPixels(const Point& offsetInPixels)
|
||||
void SpriteFrame::setOffsetInPixels(const Vector2& offsetInPixels)
|
||||
{
|
||||
_offsetInPixels = offsetInPixels;
|
||||
_offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );
|
||||
|
|
|
@ -132,7 +132,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
spriteFrame->initWithTexture(texture,
|
||||
Rect(x, y, w, h),
|
||||
false,
|
||||
Point(ox, oy),
|
||||
Vector2(ox, oy),
|
||||
Size((float)ow, (float)oh)
|
||||
);
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
rotated = frameDict["rotated"].asBool();
|
||||
}
|
||||
|
||||
Point offset = PointFromString(frameDict["offset"].asString());
|
||||
Vector2 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());
|
||||
Point spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
|
||||
Vector2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
|
||||
Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString());
|
||||
Rect textureRect = RectFromString(frameDict["textureRect"].asString());
|
||||
bool textureRotated = frameDict["textureRotated"].asBool();
|
||||
|
|
|
@ -83,7 +83,7 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la
|
|||
_layerOrientation = mapInfo->getOrientation();
|
||||
|
||||
// offset (after layer orientation is set);
|
||||
Point offset = this->calculateLayerOffset(layerInfo->_offset);
|
||||
Vector2 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, Point(x, y));
|
||||
this->appendTileForGID(gid, Vector2(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,25 +223,25 @@ void TMXLayer::parseInternalProperties()
|
|||
}
|
||||
}
|
||||
|
||||
void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, int gid)
|
||||
void TMXLayer::setupTileSprite(Sprite* sprite, Vector2 pos, int gid)
|
||||
{
|
||||
sprite->setPosition(getPositionAt(pos));
|
||||
sprite->setPositionZ((float)getVertexZForPos(pos));
|
||||
sprite->setAnchorPoint(Point::ZERO);
|
||||
sprite->setAnchorPoint(Vector2::ZERO);
|
||||
sprite->setOpacity(_opacity);
|
||||
|
||||
//issue 1264, flip can be undone as well
|
||||
sprite->setFlippedX(false);
|
||||
sprite->setFlippedY(false);
|
||||
sprite->setRotation(0.0f);
|
||||
sprite->setAnchorPoint(Point(0,0));
|
||||
sprite->setAnchorPoint(Vector2(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(Point(0.5f,0.5f));
|
||||
sprite->setPosition(Point(getPositionAt(pos).x + sprite->getContentSize().height/2,
|
||||
sprite->setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
sprite->setPosition(Vector2(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 Point& pos)
|
||||
Sprite * TMXLayer::getTileAt(const Vector2& 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 Point& pos)
|
|||
tile->setBatchNode(this);
|
||||
tile->setPosition(getPositionAt(pos));
|
||||
tile->setPositionZ((float)getVertexZForPos(pos));
|
||||
tile->setAnchorPoint(Point::ZERO);
|
||||
tile->setAnchorPoint(Vector2::ZERO);
|
||||
tile->setOpacity(_opacity);
|
||||
|
||||
ssize_t indexForZ = atlasIndexForExistantZ(z);
|
||||
|
@ -340,7 +340,7 @@ Sprite * TMXLayer::getTileAt(const Point& pos)
|
|||
return tile;
|
||||
}
|
||||
|
||||
uint32_t TMXLayer::getTileGIDAt(const Point& pos, TMXTileFlags* flags/* = nullptr*/)
|
||||
uint32_t TMXLayer::getTileGIDAt(const Vector2& 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 Point& pos, TMXTileFlags* flags/* = nullpt
|
|||
}
|
||||
|
||||
// TMXLayer - adding helper methods
|
||||
Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Point& pos)
|
||||
Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos)
|
||||
{
|
||||
if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0)
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Point& pos)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Point& pos)
|
||||
Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& 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 Point& 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 Point& pos)
|
||||
Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vector2& pos)
|
||||
{
|
||||
if (gid != 0 && (static_cast<int>((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 Point& pos)
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos)
|
||||
{
|
||||
setTileGID(gid, pos, (TMXTileFlags)0);
|
||||
}
|
||||
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Point& pos, TMXTileFlags flags)
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Vector2& 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 Point& pos)
|
||||
void TMXLayer::removeTileAt(const Vector2& 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 Point& pos)
|
|||
}
|
||||
|
||||
//CCTMXLayer - obtaining positions, offset
|
||||
Point TMXLayer::calculateLayerOffset(const Point& pos)
|
||||
Vector2 TMXLayer::calculateLayerOffset(const Vector2& pos)
|
||||
{
|
||||
Point ret = Point::ZERO;
|
||||
Vector2 ret = Vector2::ZERO;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case TMXOrientationOrtho:
|
||||
ret = Point( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
ret = Vector2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
break;
|
||||
case TMXOrientationIso:
|
||||
ret = Point((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
ret = Vector2((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
(_mapTileSize.height /2 ) * (-pos.x - pos.y));
|
||||
break;
|
||||
case TMXOrientationHex:
|
||||
CCASSERT(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet");
|
||||
CCASSERT(pos.equals(Vector2::ZERO), "offset for hexagonal map not implemented yet");
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point TMXLayer::getPositionAt(const Point& pos)
|
||||
Vector2 TMXLayer::getPositionAt(const Vector2& pos)
|
||||
{
|
||||
Point ret = Point::ZERO;
|
||||
Vector2 ret = Vector2::ZERO;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case TMXOrientationOrtho:
|
||||
|
@ -644,19 +644,19 @@ Point TMXLayer::getPositionAt(const Point& pos)
|
|||
return ret;
|
||||
}
|
||||
|
||||
Point TMXLayer::getPositionForOrthoAt(const Point& pos)
|
||||
Vector2 TMXLayer::getPositionForOrthoAt(const Vector2& pos)
|
||||
{
|
||||
return Point(pos.x * _mapTileSize.width,
|
||||
return Vector2(pos.x * _mapTileSize.width,
|
||||
(_layerSize.height - pos.y - 1) * _mapTileSize.height);
|
||||
}
|
||||
|
||||
Point TMXLayer::getPositionForIsoAt(const Point& pos)
|
||||
Vector2 TMXLayer::getPositionForIsoAt(const Vector2& pos)
|
||||
{
|
||||
return Point(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1),
|
||||
return Vector2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1),
|
||||
_mapTileSize.height /2 * ((_layerSize.height * 2 - pos.x - pos.y) - 2));
|
||||
}
|
||||
|
||||
Point TMXLayer::getPositionForHexAt(const Point& pos)
|
||||
Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos)
|
||||
{
|
||||
float diffY = 0;
|
||||
if ((int)pos.x % 2 == 1)
|
||||
|
@ -664,12 +664,12 @@ Point TMXLayer::getPositionForHexAt(const Point& pos)
|
|||
diffY = -_mapTileSize.height/2 ;
|
||||
}
|
||||
|
||||
Point xy = Point(pos.x * _mapTileSize.width*3/4,
|
||||
Vector2 xy = Vector2(pos.x * _mapTileSize.width*3/4,
|
||||
(_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY);
|
||||
return xy;
|
||||
}
|
||||
|
||||
int TMXLayer::getVertexZForPos(const Point& pos)
|
||||
int TMXLayer::getVertexZForPos(const Vector2& pos)
|
||||
{
|
||||
int ret = 0;
|
||||
int maxVal = 0;
|
||||
|
|
|
@ -34,7 +34,7 @@ NS_CC_BEGIN
|
|||
|
||||
TMXObjectGroup::TMXObjectGroup()
|
||||
: _groupName("")
|
||||
, _positionOffset(Point::ZERO)
|
||||
, _positionOffset(Vector2::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ TMXLayerInfo::TMXLayerInfo()
|
|||
: _name("")
|
||||
, _tiles(nullptr)
|
||||
, _ownTiles(true)
|
||||
, _offset(Point::ZERO)
|
||||
, _offset(Vector2::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
|
||||
float x = attributeDict["x"].asFloat();
|
||||
float y = attributeDict["y"].asFloat();
|
||||
layer->_offset = Point(x,y);
|
||||
layer->_offset = Vector2(x,y);
|
||||
|
||||
tmxMapInfo->getLayers().pushBack(layer);
|
||||
layer->release();
|
||||
|
@ -368,7 +368,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
{
|
||||
TMXObjectGroup *objectGroup = new TMXObjectGroup();
|
||||
objectGroup->setGroupName(attributeDict["name"].asString());
|
||||
Point positionOffset;
|
||||
Vector2 positionOffset;
|
||||
positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width;
|
||||
positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height;
|
||||
objectGroup->setPositionOffset(positionOffset);
|
||||
|
@ -459,7 +459,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
// Y
|
||||
int y = attributeDict["y"].asInt();
|
||||
|
||||
Point p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt());
|
||||
Vector2 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);
|
||||
|
|
|
@ -1151,7 +1151,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
|||
|
||||
// implementation Texture2D (Drawing)
|
||||
|
||||
void Texture2D::drawAtPoint(const Point& point)
|
||||
void Texture2D::drawAtPoint(const Vector2& point)
|
||||
{
|
||||
GLfloat coordinates[] = {
|
||||
0.0f, _maxT,
|
||||
|
|
|
@ -125,7 +125,7 @@ void TileMapAtlas::loadTGAfile(const std::string& file)
|
|||
}
|
||||
|
||||
// TileMapAtlas - Atlas generation / updates
|
||||
void TileMapAtlas::setTile(const Color3B& tile, const Point& position)
|
||||
void TileMapAtlas::setTile(const Color3B& tile, const Vector2& 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 Point& position)
|
|||
}
|
||||
}
|
||||
|
||||
Color3B TileMapAtlas::getTileAt(const Point& position) const
|
||||
Color3B TileMapAtlas::getTileAt(const Vector2& 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 Point& position) const
|
|||
return value;
|
||||
}
|
||||
|
||||
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, int index)
|
||||
void TileMapAtlas::updateAtlasValueAt(const Vector2& 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(Point(x,y), value, total);
|
||||
this->updateAtlasValueAt(Vector2(x,y), value, total);
|
||||
|
||||
std::string key = StringUtils::toString(x) + "," + StringUtils::toString(y);
|
||||
_posToAtlasIndex[key] = total;
|
||||
|
|
|
@ -29,43 +29,43 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
// returns the current touch location in screen coordinates
|
||||
Point Touch::getLocationInView() const
|
||||
Vector2 Touch::getLocationInView() const
|
||||
{
|
||||
return _point;
|
||||
}
|
||||
|
||||
// returns the previous touch location in screen coordinates
|
||||
Point Touch::getPreviousLocationInView() const
|
||||
Vector2 Touch::getPreviousLocationInView() const
|
||||
{
|
||||
return _prevPoint;
|
||||
}
|
||||
|
||||
// returns the start touch location in screen coordinates
|
||||
Point Touch::getStartLocationInView() const
|
||||
Vector2 Touch::getStartLocationInView() const
|
||||
{
|
||||
return _startPoint;
|
||||
}
|
||||
|
||||
// returns the current touch location in OpenGL coordinates
|
||||
Point Touch::getLocation() const
|
||||
Vector2 Touch::getLocation() const
|
||||
{
|
||||
return Director::getInstance()->convertToGL(_point);
|
||||
}
|
||||
|
||||
// returns the previous touch location in OpenGL coordinates
|
||||
Point Touch::getPreviousLocation() const
|
||||
Vector2 Touch::getPreviousLocation() const
|
||||
{
|
||||
return Director::getInstance()->convertToGL(_prevPoint);
|
||||
}
|
||||
|
||||
// returns the start touch location in OpenGL coordinates
|
||||
Point Touch::getStartLocation() const
|
||||
Vector2 Touch::getStartLocation() const
|
||||
{
|
||||
return Director::getInstance()->convertToGL(_startPoint);
|
||||
}
|
||||
|
||||
// returns the delta position between the current location and the previous location in OpenGL coordinates
|
||||
Point Touch::getDelta() const
|
||||
Vector2 Touch::getDelta() const
|
||||
{
|
||||
return getLocation() - getPreviousLocation();
|
||||
}
|
||||
|
|
|
@ -120,13 +120,13 @@ void TransitionScene::finish()
|
|||
{
|
||||
// clean up
|
||||
_inScene->setVisible(true);
|
||||
_inScene->setPosition(Point(0,0));
|
||||
_inScene->setPosition(Vector2(0,0));
|
||||
_inScene->setScale(1.0f);
|
||||
_inScene->setRotation(0.0f);
|
||||
_inScene->setAdditionalTransform(nullptr);
|
||||
|
||||
_outScene->setVisible(false);
|
||||
_outScene->setPosition(Point(0,0));
|
||||
_outScene->setPosition(Vector2(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(Point(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_inScene->setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Vector2(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(Point(s.width, 0));
|
||||
_inScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_inScene->setPosition(Vector2(s.width, 0));
|
||||
_inScene->setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
|
||||
ActionInterval *jump = JumpBy::create(_duration/4, Point(-s.width,0), s.width/4, 2);
|
||||
ActionInterval *jump = JumpBy::create(_duration/4, Vector2(-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, Point(0,0));
|
||||
return MoveTo::create(_duration, Vector2(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(Point(-s.width,0));
|
||||
_inScene->setPosition(Vector2(-s.width,0));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -419,7 +419,7 @@ TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene)
|
|||
void TransitionMoveInR::initScenes()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(s.width,0) );
|
||||
_inScene->setPosition( Vector2(s.width,0) );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -447,7 +447,7 @@ TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene)
|
|||
void TransitionMoveInT::initScenes()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,s.height) );
|
||||
_inScene->setPosition( Vector2(0,s.height) );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -475,7 +475,7 @@ TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene)
|
|||
void TransitionMoveInB::initScenes()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,-s.height) );
|
||||
_inScene->setPosition( Vector2(0,-s.height) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -523,13 +523,13 @@ void TransitionSlideInL::sceneOrder()
|
|||
void TransitionSlideInL:: initScenes()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(-(s.width-ADJUST_FACTOR),0) );
|
||||
_inScene->setPosition( Vector2(-(s.width-ADJUST_FACTOR),0) );
|
||||
}
|
||||
|
||||
ActionInterval* TransitionSlideInL::action()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(s.width-ADJUST_FACTOR,0));
|
||||
return MoveBy::create(_duration, Vector2(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( Point(s.width-ADJUST_FACTOR,0) );
|
||||
_inScene->setPosition( Vector2(s.width-ADJUST_FACTOR,0) );
|
||||
}
|
||||
|
||||
|
||||
ActionInterval* TransitionSlideInR:: action()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(-(s.width-ADJUST_FACTOR),0));
|
||||
return MoveBy::create(_duration, Vector2(-(s.width-ADJUST_FACTOR),0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -620,14 +620,14 @@ void TransitionSlideInT::sceneOrder()
|
|||
void TransitionSlideInT::initScenes()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,s.height-ADJUST_FACTOR) );
|
||||
_inScene->setPosition( Vector2(0,s.height-ADJUST_FACTOR) );
|
||||
}
|
||||
|
||||
|
||||
ActionInterval* TransitionSlideInT::action()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(0,-(s.height-ADJUST_FACTOR)));
|
||||
return MoveBy::create(_duration, Vector2(0,-(s.height-ADJUST_FACTOR)));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -660,14 +660,14 @@ void TransitionSlideInB::sceneOrder()
|
|||
void TransitionSlideInB:: initScenes()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,-(s.height-ADJUST_FACTOR)) );
|
||||
_inScene->setPosition( Vector2(0,-(s.height-ADJUST_FACTOR)) );
|
||||
}
|
||||
|
||||
|
||||
ActionInterval* TransitionSlideInB:: action()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(0,s.height-ADJUST_FACTOR));
|
||||
return MoveBy::create(_duration, Vector2(0,s.height-ADJUST_FACTOR));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -699,8 +699,8 @@ void TransitionShrinkGrow::onEnter()
|
|||
_inScene->setScale(0.001f);
|
||||
_outScene->setScale(1.0f);
|
||||
|
||||
_inScene->setAnchorPoint(Point(2/3.0f,0.5f));
|
||||
_outScene->setAnchorPoint(Point(1/3.0f,0.5f));
|
||||
_inScene->setAnchorPoint(Vector2(2/3.0f,0.5f));
|
||||
_outScene->setAnchorPoint(Vector2(1/3.0f,0.5f));
|
||||
|
||||
ActionInterval* scaleOut = ScaleTo::create(_duration, 0.01f);
|
||||
ActionInterval* scaleIn = ScaleTo::create(_duration, 1.0f);
|
||||
|
@ -1284,9 +1284,9 @@ void TransitionCrossFade::onEnter()
|
|||
return;
|
||||
}
|
||||
|
||||
inTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
inTexture->setPosition( Point(size.width/2, size.height/2) );
|
||||
inTexture->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
inTexture->getSprite()->setAnchorPoint( Vector2(0.5f,0.5f) );
|
||||
inTexture->setPosition( Vector2(size.width/2, size.height/2) );
|
||||
inTexture->setAnchorPoint( Vector2(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( Point(0.5f,0.5f) );
|
||||
outTexture->setPosition( Point(size.width/2, size.height/2) );
|
||||
outTexture->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
outTexture->getSprite()->setAnchorPoint( Vector2(0.5f,0.5f) );
|
||||
outTexture->setPosition( Vector2(size.width/2, size.height/2) );
|
||||
outTexture->setAnchorPoint( Vector2(0.5f,0.5f) );
|
||||
|
||||
// render outScene to its texturebuffer
|
||||
outTexture->begin();
|
||||
|
|
|
@ -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(Point(0.5f,0.5f));
|
||||
texture->setPosition(Point(size.width/2, size.height/2));
|
||||
texture->setAnchorPoint(Point(0.5f,0.5f));
|
||||
texture->getSprite()->setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
texture->setPosition(Vector2(size.width/2, size.height/2));
|
||||
texture->setAnchorPoint(Vector2(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(Point(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Point(0.5f,0.5f));
|
||||
node->setPosition(Vector2(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Vector2(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(Point(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Point(0.5f,0.5f));
|
||||
node->setPosition(Vector2(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
@ -218,12 +218,12 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
|
|||
node->getSprite()->setFlippedY(true);
|
||||
node->setType( ProgressTimer::Type::BAR);
|
||||
|
||||
node->setMidpoint(Point(1, 0));
|
||||
node->setBarChangeRate(Point(1,0));
|
||||
node->setMidpoint(Vector2(1, 0));
|
||||
node->setBarChangeRate(Vector2(1,0));
|
||||
|
||||
node->setPercentage(100);
|
||||
node->setPosition(Point(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Point(0.5f,0.5f));
|
||||
node->setPosition(Vector2(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Vector2(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(Point(0, 0));
|
||||
node->setBarChangeRate(Point(0,1));
|
||||
node->setMidpoint(Vector2(0, 0));
|
||||
node->setBarChangeRate(Vector2(0,1));
|
||||
|
||||
node->setPercentage(100);
|
||||
node->setPosition(Point(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Point(0.5f,0.5f));
|
||||
node->setPosition(Vector2(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Vector2(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(Point(0.5f, 0.5f));
|
||||
node->setBarChangeRate(Point(1, 1));
|
||||
node->setMidpoint(Vector2(0.5f, 0.5f));
|
||||
node->setBarChangeRate(Vector2(1, 1));
|
||||
|
||||
node->setPercentage(0);
|
||||
node->setPosition(Point(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Point(0.5f,0.5f));
|
||||
node->setPosition(Vector2(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Vector2(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(Point(0.5f, 0.5f));
|
||||
node->setBarChangeRate(Point(1, 1));
|
||||
node->setMidpoint(Vector2(0.5f, 0.5f));
|
||||
node->setBarChangeRate(Vector2(1, 1));
|
||||
|
||||
node->setPercentage(100);
|
||||
node->setPosition(Point(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Point(0.5f,0.5f));
|
||||
node->setPosition(Vector2(size.width/2, size.height/2));
|
||||
node->setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
void ccVertexLineToPolygon(Point *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints)
|
||||
void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints)
|
||||
{
|
||||
nuPoints += offset;
|
||||
if(nuPoints<=1) return;
|
||||
|
@ -42,8 +42,8 @@ void ccVertexLineToPolygon(Point *points, float stroke, Vector2 *vertices, unsig
|
|||
for(unsigned int i = offset; i<nuPoints; i++)
|
||||
{
|
||||
idx = i*2;
|
||||
Point p1 = points[i];
|
||||
Point perpVector;
|
||||
Vector2 p1 = points[i];
|
||||
Vector2 perpVector;
|
||||
|
||||
if(i == 0)
|
||||
perpVector = (p1 - points[i+1]).normalize().getPerp();
|
||||
|
@ -51,11 +51,11 @@ void ccVertexLineToPolygon(Point *points, float stroke, Vector2 *vertices, unsig
|
|||
perpVector = (points[i-1] - p1).normalize().getPerp();
|
||||
else
|
||||
{
|
||||
Point p2 = points[i+1];
|
||||
Point p0 = points[i-1];
|
||||
Vector2 p2 = points[i+1];
|
||||
Vector2 p0 = points[i-1];
|
||||
|
||||
Point p2p1 = (p2 - p1).normalize();
|
||||
Point p0p1 = (p0 - p1).normalize();
|
||||
Vector2 p2p1 = (p2 - p1).normalize();
|
||||
Vector2 p0p1 = (p0 - p1).normalize();
|
||||
|
||||
// Calculate angle between vectors
|
||||
float angle = acosf(p2p1.dot(p0p1));
|
||||
|
@ -87,7 +87,7 @@ void ccVertexLineToPolygon(Point *points, float stroke, Vector2 *vertices, unsig
|
|||
Vector2 p4 = vertices[idx1+1];
|
||||
|
||||
float s;
|
||||
//BOOL fixVertex = !ccpLineIntersect(Point(p1.x, p1.y), Point(p4.x, p4.y), Point(p2.x, p2.y), Point(p3.x, p3.y), &s, &t);
|
||||
//BOOL fixVertex = !ccpLineIntersect(Vector2(p1.x, p1.y), Vector2(p4.x, p4.y), Vector2(p2.x, p2.y), Vector2(p3.x, p3.y), &s, &t);
|
||||
bool fixVertex = !ccVertexLineIntersect(p1.x, p1.y, p4.x, p4.y, p2.x, p2.y, p3.x, p3.y, &s);
|
||||
if(!fixVertex)
|
||||
if (s<0.0f || s>1.0f)
|
||||
|
|
|
@ -178,16 +178,16 @@ Size GLViewProtocol::getVisibleSize() const
|
|||
}
|
||||
}
|
||||
|
||||
Point GLViewProtocol::getVisibleOrigin() const
|
||||
Vector2 GLViewProtocol::getVisibleOrigin() const
|
||||
{
|
||||
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
|
||||
{
|
||||
return Point((_designResolutionSize.width - _screenSize.width/_scaleX)/2,
|
||||
return Vector2((_designResolutionSize.width - _screenSize.width/_scaleX)/2,
|
||||
(_designResolutionSize.height - _screenSize.height/_scaleY)/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Point::ZERO;
|
||||
return Vector2::ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(Point(_mouseX,_mouseY)))
|
||||
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Vector2(_mouseX,_mouseY)))
|
||||
{
|
||||
intptr_t id = 0;
|
||||
this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY);
|
||||
|
|
|
@ -166,11 +166,11 @@ void WinRTWindow::ResizeWindow()
|
|||
GLView::sharedOpenGLView()->UpdateForWindowSizeChange();
|
||||
}
|
||||
|
||||
cocos2d::Point WinRTWindow::GetCCPoint(PointerEventArgs^ args) {
|
||||
cocos2d::Vector2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) {
|
||||
auto p = args->CurrentPoint;
|
||||
float x = getScaledDPIValue(p->Position.X);
|
||||
float y = getScaledDPIValue(p->Position.Y);
|
||||
Point pt(x, y);
|
||||
Vector2 pt(x, y);
|
||||
|
||||
float zoomFactor = GLView::sharedOpenGLView()->getFrameZoomFactor();
|
||||
|
||||
|
@ -265,7 +265,7 @@ void WinRTWindow::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ ar
|
|||
{
|
||||
float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta;
|
||||
int id = 0;
|
||||
Point p(0.0f,0.0f);
|
||||
Vector2 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);
|
||||
|
@ -276,7 +276,7 @@ void WinRTWindow::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ ar
|
|||
void WinRTWindow::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
int id = args->CurrentPoint->PointerId;
|
||||
Point pt = GetCCPoint(args);
|
||||
Vector2 pt = GetCCPoint(args);
|
||||
GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &pt.x, &pt.y);
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
|
|||
if (m_lastPointValid)
|
||||
{
|
||||
int id = args->CurrentPoint->PointerId;
|
||||
Point p = GetCCPoint(args);
|
||||
Vector2 p = GetCCPoint(args);
|
||||
GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y);
|
||||
}
|
||||
m_lastPoint = currentPoint->Position;
|
||||
|
@ -303,7 +303,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
|
|||
void WinRTWindow::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
int id = args->CurrentPoint->PointerId;
|
||||
Point pt = GetCCPoint(args);
|
||||
Vector2 pt = GetCCPoint(args);
|
||||
GLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &pt.x, &pt.y);
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ void GLView::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
|
|||
void GLView::OnPointerPressed(PointerEventArgs^ args)
|
||||
{
|
||||
int id = args->CurrentPoint->PointerId;
|
||||
Point pt = GetPoint(args);
|
||||
Vector2 pt = GetPoint(args);
|
||||
handleTouchesBegin(1, &id, &pt.x, &pt.y);
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ void GLView::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
|
|||
{
|
||||
float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta;
|
||||
int id = 0;
|
||||
Point p(0.0f,0.0f);
|
||||
Vector2 p(0.0f,0.0f);
|
||||
handleTouchesBegin(1, &id, &p.x, &p.y);
|
||||
p.y += direction;
|
||||
handleTouchesMove(1, &id, &p.x, &p.y);
|
||||
|
@ -221,7 +221,7 @@ void GLView::OnPointerMoved( PointerEventArgs^ args)
|
|||
if (m_lastPointValid)
|
||||
{
|
||||
int id = args->CurrentPoint->PointerId;
|
||||
Point p = GetPoint(args);
|
||||
Vector2 p = GetPoint(args);
|
||||
handleTouchesMove(1, &id, &p.x, &p.y);
|
||||
}
|
||||
m_lastPoint = currentPoint->Position;
|
||||
|
@ -241,7 +241,7 @@ void GLView::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
|
|||
void GLView::OnPointerReleased(PointerEventArgs^ args)
|
||||
{
|
||||
int id = args->CurrentPoint->PointerId;
|
||||
Point pt = GetPoint(args);
|
||||
Vector2 pt = GetPoint(args);
|
||||
handleTouchesEnd(1, &id, &pt.x, &pt.y);
|
||||
}
|
||||
|
||||
|
@ -422,9 +422,9 @@ void GLView::UpdateOrientationMatrix()
|
|||
}
|
||||
}
|
||||
|
||||
cocos2d::Point GLView::TransformToOrientation(Windows::Foundation::Point p)
|
||||
cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Vector2 p)
|
||||
{
|
||||
cocos2d::Point returnValue;
|
||||
cocos2d::Vector2 returnValue;
|
||||
|
||||
float x = p.X;
|
||||
float y = p.Y;
|
||||
|
@ -433,16 +433,16 @@ cocos2d::Point GLView::TransformToOrientation(Windows::Foundation::Point p)
|
|||
{
|
||||
case DisplayOrientations::Portrait:
|
||||
default:
|
||||
returnValue = Point(x, y);
|
||||
returnValue = Vector2(x, y);
|
||||
break;
|
||||
case DisplayOrientations::Landscape:
|
||||
returnValue = Point(y, m_width - x);
|
||||
returnValue = Vector2(y, m_width - x);
|
||||
break;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
returnValue = Point(m_width - x, m_height - y);
|
||||
returnValue = Vector2(m_width - x, m_height - y);
|
||||
break;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
returnValue = Point(m_height - y, x);
|
||||
returnValue = Vector2(m_height - y, x);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ cocos2d::Point GLView::TransformToOrientation(Windows::Foundation::Point p)
|
|||
return returnValue;
|
||||
}
|
||||
|
||||
Point GLView::GetPoint(PointerEventArgs^ args) {
|
||||
Vector2 GLView::GetPoint(PointerEventArgs^ args) {
|
||||
|
||||
return TransformToOrientation(args->CurrentPoint->Position);
|
||||
|
||||
|
|
|
@ -330,9 +330,9 @@ void Direct3DBase::ComputeOrientationMatrices()
|
|||
}
|
||||
}
|
||||
|
||||
Point Direct3DBase::TransformToOrientation(Point point, bool dipsToPixels)
|
||||
Vector2 Direct3DBase::TransformToOrientation(Vector2 point, bool dipsToPixels)
|
||||
{
|
||||
Point returnValue;
|
||||
Vector2 returnValue;
|
||||
|
||||
switch (m_orientation)
|
||||
{
|
||||
|
@ -340,20 +340,20 @@ Point Direct3DBase::TransformToOrientation(Point point, bool dipsToPixels)
|
|||
returnValue = point;
|
||||
break;
|
||||
case DisplayOrientations::Landscape:
|
||||
returnValue = Point(point.Y, m_windowBounds.Width - point.X);
|
||||
returnValue = Vector2(point.Y, m_windowBounds.Width - point.X);
|
||||
break;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
returnValue = Point(m_windowBounds.Width - point.X, m_windowBounds.Height - point.Y);
|
||||
returnValue = Vector2(m_windowBounds.Width - point.X, m_windowBounds.Height - point.Y);
|
||||
break;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
returnValue = Point(m_windowBounds.Height -point.Y, point.X);
|
||||
returnValue = Vector2(m_windowBounds.Height -point.Y, point.X);
|
||||
break;
|
||||
default:
|
||||
throw ref new Platform::FailureException();
|
||||
break;
|
||||
}
|
||||
|
||||
return dipsToPixels ? Point(ConvertDipsToPixels(returnValue.X),
|
||||
return dipsToPixels ? Vector2(ConvertDipsToPixels(returnValue.X),
|
||||
ConvertDipsToPixels(returnValue.Y))
|
||||
: returnValue;
|
||||
}
|
||||
|
|
|
@ -38,19 +38,19 @@ AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, floa
|
|||
return t;
|
||||
}
|
||||
|
||||
Point __CCPointApplyAffineTransform(const Point& point, const AffineTransform& t)
|
||||
Vector2 __CCPointApplyAffineTransform(const Vector2& point, const AffineTransform& t)
|
||||
{
|
||||
Point p;
|
||||
Vector2 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;
|
||||
}
|
||||
|
||||
Point PointApplyTransform(const Point& point, const Matrix& transform)
|
||||
Vector2 PointApplyTransform(const Vector2& point, const Matrix& transform)
|
||||
{
|
||||
Vector3 vec(point.x, point.y, 0);
|
||||
transform.transformPoint(&vec);
|
||||
return Point(vec.x, vec.y);
|
||||
return Vector2(vec.x, vec.y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,10 +78,10 @@ Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineT
|
|||
float right = rect.getMaxX();
|
||||
float bottom = rect.getMaxY();
|
||||
|
||||
Point topLeft = PointApplyAffineTransform(Point(left, top), anAffineTransform);
|
||||
Point topRight = PointApplyAffineTransform(Point(right, top), anAffineTransform);
|
||||
Point bottomLeft = PointApplyAffineTransform(Point(left, bottom), anAffineTransform);
|
||||
Point bottomRight = PointApplyAffineTransform(Point(right, bottom), anAffineTransform);
|
||||
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);
|
||||
|
||||
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));
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#include "ccMacros.h"
|
||||
#include <algorithm>
|
||||
|
||||
// implementation of Point
|
||||
// implementation of Vector2
|
||||
NS_CC_BEGIN
|
||||
|
||||
// implementation of Size
|
||||
|
@ -44,7 +44,7 @@ Size::Size(const Size& other) : width(other.width), height(other.height)
|
|||
{
|
||||
}
|
||||
|
||||
Size::Size(const Point& point) : width(point.x), height(point.y)
|
||||
Size::Size(const Vector2& point) : width(point.x), height(point.y)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ Size& Size::operator= (const Size& other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Size& Size::operator= (const Point& point)
|
||||
Size& Size::operator= (const Vector2& point)
|
||||
{
|
||||
setSize(point.x, point.y);
|
||||
return *this;
|
||||
|
@ -166,7 +166,7 @@ float Rect::getMinY() const
|
|||
return origin.y;
|
||||
}
|
||||
|
||||
bool Rect::containsPoint(const Point& point) const
|
||||
bool Rect::containsPoint(const Vector2& point) const
|
||||
{
|
||||
bool bRet = false;
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ Rect RectFromString(const std::string& str)
|
|||
return result;
|
||||
}
|
||||
|
||||
Point PointFromString(const std::string& str)
|
||||
Vector2 PointFromString(const std::string& str)
|
||||
{
|
||||
Point ret = Point::ZERO;
|
||||
Vector2 ret = Vector2::ZERO;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ Point PointFromString(const std::string& str)
|
|||
float x = (float) atof(strs[0].c_str());
|
||||
float y = (float) atof(strs[1].c_str());
|
||||
|
||||
ret = Point(x, y);
|
||||
ret = Vector2(x, y);
|
||||
} while (0);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
const Point CCPointZero = Point::ZERO;
|
||||
const Vector2 CCPointZero = Vector2::ZERO;
|
||||
|
||||
/* The "zero" size -- equivalent to Size(0, 0). */
|
||||
const Size CCSizeZero = Size::ZERO;
|
||||
|
@ -83,7 +83,7 @@ void ccDrawFree()
|
|||
DrawPrimitives::free();
|
||||
}
|
||||
|
||||
void ccDrawPoint( const Point& point )
|
||||
void ccDrawPoint( const Vector2& point )
|
||||
{
|
||||
DrawPrimitives::drawPoint(point);
|
||||
}
|
||||
|
@ -93,17 +93,17 @@ void ccDrawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
|||
DrawPrimitives::drawPoints(points, numberOfPoints);
|
||||
}
|
||||
|
||||
void ccDrawLine( const Point& origin, const Point& destination )
|
||||
void ccDrawLine( const Vector2& origin, const Vector2& destination )
|
||||
{
|
||||
DrawPrimitives::drawLine(origin, destination);
|
||||
}
|
||||
|
||||
void ccDrawRect( Point origin, Point destination )
|
||||
void ccDrawRect( Vector2 origin, Vector2 destination )
|
||||
{
|
||||
DrawPrimitives::drawRect(origin, destination);
|
||||
}
|
||||
|
||||
void ccDrawSolidRect( Point origin, Point destination, Color4F color )
|
||||
void ccDrawSolidRect( Vector2 origin, Vector2 destination, Color4F color )
|
||||
{
|
||||
DrawPrimitives::drawSolidRect(origin, destination, color);
|
||||
}
|
||||
|
@ -118,32 +118,32 @@ void ccDrawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F
|
|||
DrawPrimitives::drawSolidPoly(poli, numberOfPoints, color);
|
||||
}
|
||||
|
||||
void ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
|
||||
void ccDrawCircle( const Vector2& 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 Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
|
||||
void ccDrawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
|
||||
{
|
||||
DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter);
|
||||
}
|
||||
|
||||
void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
|
||||
void ccDrawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
|
||||
{
|
||||
DrawPrimitives::drawSolidCircle(center, radius, angle, segments, scaleX, scaleY);
|
||||
}
|
||||
|
||||
void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments)
|
||||
void ccDrawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments)
|
||||
{
|
||||
DrawPrimitives::drawSolidCircle(center, radius, angle, segments);
|
||||
}
|
||||
|
||||
void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments)
|
||||
void ccDrawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments)
|
||||
{
|
||||
DrawPrimitives::drawQuadBezier(origin, control, destination, segments);
|
||||
}
|
||||
|
||||
void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments)
|
||||
void ccDrawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments)
|
||||
{
|
||||
DrawPrimitives::drawCubicBezier(origin, control1, control2, destination, segments);
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
|
||||
Size containerSize = getContainerSize(pNode->getParent());
|
||||
|
||||
Point absPos = getAbsolutePosition(Point(x,y), type, containerSize, propName);
|
||||
Vector2 absPos = getAbsolutePosition(Vector2(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(Point(x,y), type, getContainerSize(pNode->getParent()), propName));
|
||||
pNode->setPosition(getAbsolutePosition(Vector2(x,y), type, getContainerSize(pNode->getParent()), propName));
|
||||
}
|
||||
else if (propName == "scale")
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParen
|
|||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) {
|
||||
void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vector2 pPoint, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) {
|
||||
((ControlButton *)pNode)->setLabelAnchorPoint(pPoint);
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,7 @@ void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent
|
|||
}
|
||||
|
||||
|
||||
void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) {
|
||||
void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vector2 pPoint, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) {
|
||||
((LayerGradient *)pNode)->setVector(pPoint);
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ using namespace cocos2d;
|
|||
|
||||
namespace cocosbuilder {
|
||||
|
||||
Point getAbsolutePosition(const Point &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName)
|
||||
Vector2 getAbsolutePosition(const Vector2 &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName)
|
||||
{
|
||||
Point absPt = Point(0,0);
|
||||
Vector2 absPt = Vector2(0,0);
|
||||
if (type == CCBReader::PositionType::RELATIVE_BOTTOM_LEFT)
|
||||
{
|
||||
absPt = pt;
|
||||
|
|
|
@ -110,7 +110,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
|
|||
{
|
||||
case CCBReader::PropertyType::POSITION:
|
||||
{
|
||||
Point position = this->parsePropTypePosition(pNode, pParent, ccbReader, propertyName.c_str());
|
||||
Vector2 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:
|
||||
{
|
||||
Point point = this->parsePropTypePoint(pNode, pParent, ccbReader);
|
||||
Vector2 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:
|
||||
{
|
||||
Point pointLock = this->parsePropTypePointLock(pNode, pParent, ccbReader);
|
||||
Vector2 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
|
|||
}
|
||||
}
|
||||
|
||||
Point NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName)
|
||||
Vector2 NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName)
|
||||
{
|
||||
float x = ccbReader->readFloat();
|
||||
float y = ccbReader->readFloat();
|
||||
|
@ -376,7 +376,7 @@ Point NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader
|
|||
|
||||
Size containerSize = ccbReader->getAnimationManager()->getContainerSize(pParent);
|
||||
|
||||
Point pt = getAbsolutePosition(Point(x,y), type, containerSize, pPropertyName);
|
||||
Vector2 pt = getAbsolutePosition(Vector2(x,y), type, containerSize, pPropertyName);
|
||||
pNode->setPosition(pt);
|
||||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
|
@ -392,19 +392,19 @@ Point NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader
|
|||
return pt;
|
||||
}
|
||||
|
||||
Point NodeLoader::parsePropTypePoint(Node * pNode, Node * pParent, CCBReader * ccbReader)
|
||||
Vector2 NodeLoader::parsePropTypePoint(Node * pNode, Node * pParent, CCBReader * ccbReader)
|
||||
{
|
||||
float x = ccbReader->readFloat();
|
||||
float y = ccbReader->readFloat();
|
||||
|
||||
return Point(x, y);
|
||||
return Vector2(x, y);
|
||||
}
|
||||
|
||||
Point NodeLoader::parsePropTypePointLock(Node * pNode, Node * pParent, CCBReader * ccbReader) {
|
||||
Vector2 NodeLoader::parsePropTypePointLock(Node * pNode, Node * pParent, CCBReader * ccbReader) {
|
||||
float x = ccbReader->readFloat();
|
||||
float y = ccbReader->readFloat();
|
||||
|
||||
return Point(x, y);
|
||||
return Vector2(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, Point pPosition, CCBReader * ccbReader) {
|
||||
void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const char* pPropertyName, Vector2 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, Point pPoint, CCBReader * ccbReader) {
|
||||
void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* pPropertyName, Vector2 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, Point pPointLock, CCBReader * ccbReader) {
|
||||
void NodeLoader::onHandlePropTypePointLock(Node * pNode, Node * pParent, const char* pPropertyName, Vector2 pPointLock, CCBReader * ccbReader) {
|
||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void ParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node
|
|||
}
|
||||
}
|
||||
|
||||
void ParticleSystemQuadLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) {
|
||||
void ParticleSystemQuadLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vector2 pPoint, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) {
|
||||
((ParticleSystemQuad *)pNode)->setPosVar(pPoint);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) {
|
||||
|
|
|
@ -221,7 +221,7 @@ ActionInterval* ActionFrame::getEasingAction(ActionInterval* action)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ActionMoveFrame::ActionMoveFrame()
|
||||
: _position(Point(0.0f,0.0f))
|
||||
: _position(Vector2(0.0f,0.0f))
|
||||
{
|
||||
_frameType = (int)kKeyframeMove;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
|||
actionFrame->setFrameIndex(frameInex);
|
||||
actionFrame->setEasingType(frameTweenType);
|
||||
actionFrame->setEasingParameter(frameTweenParameter);
|
||||
actionFrame->setPosition(Point(positionX, positionY));
|
||||
actionFrame->setPosition(Vector2(positionX, positionY));
|
||||
auto cActionArray = _frameArray.at((int)kKeyframeMove);
|
||||
cActionArray->pushBack(actionFrame);
|
||||
actionFrame->release();
|
||||
|
|
|
@ -329,10 +329,10 @@ void Armature::updateOffsetPoint()
|
|||
// Set contentsize and Calculate anchor point.
|
||||
Rect rect = getBoundingBox();
|
||||
setContentSize(rect.size);
|
||||
_offsetPoint = Point(-rect.origin.x, -rect.origin.y);
|
||||
_offsetPoint = Vector2(-rect.origin.x, -rect.origin.y);
|
||||
if (rect.size.width != 0 && rect.size.height != 0)
|
||||
{
|
||||
setAnchorPoint(Point(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height));
|
||||
setAnchorPoint(Vector2(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,8 +341,8 @@ void Armature::setAnchorPoint(const Vector2& point)
|
|||
if( ! point.equals(_anchorPoint))
|
||||
{
|
||||
_anchorPoint = point;
|
||||
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y);
|
||||
_realAnchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y);
|
||||
_realAnchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -573,13 +573,13 @@ void CCArmature::drawContour()
|
|||
for (auto& object : bodyList)
|
||||
{
|
||||
ColliderBody *body = static_cast<ColliderBody*>(object);
|
||||
const std::vector<Point> &vertexList = body->getCalculatedVertexList();
|
||||
const std::vector<Vector2> &vertexList = body->getCalculatedVertexList();
|
||||
|
||||
unsigned long length = vertexList.size();
|
||||
Vector2 *points = new Vector2[length];
|
||||
for (unsigned long i = 0; i<length; i++)
|
||||
{
|
||||
Point p = vertexList.at(i);
|
||||
Vector2 p = vertexList.at(i);
|
||||
points[i].x = p.x;
|
||||
points[i].y = p.y;
|
||||
}
|
||||
|
|
|
@ -190,12 +190,12 @@ void ColliderDetector::addContourData(ContourData *contourData)
|
|||
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
std::vector<Point> &calculatedVertexList = colliderBody->_calculatedVertexList;
|
||||
std::vector<Vector2> &calculatedVertexList = colliderBody->_calculatedVertexList;
|
||||
|
||||
unsigned long num = contourData->vertexList.size();
|
||||
for (unsigned long i = 0; i < num; i++)
|
||||
{
|
||||
calculatedVertexList.push_back(Point());
|
||||
calculatedVertexList.push_back(Vector2());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ ColliderFilter *ColliderDetector::getColliderFilter()
|
|||
#endif
|
||||
|
||||
|
||||
Point helpPoint;
|
||||
Vector2 helpPoint;
|
||||
|
||||
void ColliderDetector::updateTransform(Matrix &t)
|
||||
{
|
||||
|
@ -361,10 +361,10 @@ void ColliderDetector::updateTransform(Matrix &t)
|
|||
#endif
|
||||
|
||||
unsigned long num = contourData->vertexList.size();
|
||||
std::vector<cocos2d::Point> &vs = contourData->vertexList;
|
||||
std::vector<cocos2d::Vector2> &vs = contourData->vertexList;
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
std::vector<cocos2d::Point> &cvs = colliderBody->_calculatedVertexList;
|
||||
std::vector<cocos2d::Vector2> &cvs = colliderBody->_calculatedVertexList;
|
||||
#endif
|
||||
|
||||
for (unsigned long i = 0; i < num; i++)
|
||||
|
|
|
@ -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(Point(0.0f, 0.0f));
|
||||
_render->setPosition(Vector2(0.0f, 0.0f));
|
||||
_render->retain();
|
||||
}
|
||||
else if(strcmp(className, "CCArmature") == 0)
|
||||
|
|
|
@ -1166,7 +1166,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D
|
|||
|
||||
while (vertexDataXML)
|
||||
{
|
||||
Point vertex;
|
||||
Vector2 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);
|
||||
|
||||
Point vertex;
|
||||
Vector2 vertex;
|
||||
|
||||
vertex.x = DICTOOL->getFloatValue_json(dic, A_X);
|
||||
vertex.y = DICTOOL->getFloatValue_json(dic, A_Y);
|
||||
|
|
|
@ -389,7 +389,7 @@ bool ContourData::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void ContourData::addVertex(Point &vertex)
|
||||
void ContourData::addVertex(Vector2 &vertex)
|
||||
{
|
||||
vertexList.push_back(vertex);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty)
|
|||
#endif
|
||||
|
||||
Matrix displayTransform = display->getNodeToParentTransform();
|
||||
Point anchorPoint = display->getAnchorPointInPoints();
|
||||
Vector2 anchorPoint = display->getAnchorPointInPoints();
|
||||
anchorPoint = PointApplyTransform(anchorPoint, displayTransform);
|
||||
displayTransform.m[12] = anchorPoint.x;
|
||||
displayTransform.m[13] = anchorPoint.y;
|
||||
|
@ -202,7 +202,7 @@ void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDispla
|
|||
if(textureData)
|
||||
{
|
||||
//! Init display anchorPoint, every Texture have a anchor point
|
||||
skin->setAnchorPoint(Point( textureData->pivotX, textureData->pivotY));
|
||||
skin->setAnchorPoint(Vector2( textureData->pivotX, textureData->pivotY));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ void DisplayManager::initDisplayList(BoneData *boneData)
|
|||
}
|
||||
|
||||
|
||||
bool DisplayManager::containPoint(Point &point)
|
||||
bool DisplayManager::containPoint(Vector2 &point)
|
||||
{
|
||||
if(!_visible || _displayIndex < 0)
|
||||
{
|
||||
|
@ -380,7 +380,7 @@ bool DisplayManager::containPoint(Point &point)
|
|||
*
|
||||
*/
|
||||
|
||||
Point outPoint = Point(0, 0);
|
||||
Vector2 outPoint = Vector2(0, 0);
|
||||
|
||||
Sprite *sprite = (Sprite *)_currentDecoDisplay->getDisplay();
|
||||
sprite = (Sprite *)sprite->getChildByTag(0);
|
||||
|
@ -398,7 +398,7 @@ bool DisplayManager::containPoint(Point &point)
|
|||
|
||||
bool DisplayManager::containPoint(float x, float y)
|
||||
{
|
||||
Point p = Point(x, y);
|
||||
Vector2 p = Vector2(x, y);
|
||||
return containPoint(p);
|
||||
}
|
||||
|
||||
|
@ -433,13 +433,13 @@ Rect DisplayManager::getBoundingBox() const
|
|||
|
||||
Vector2 DisplayManager::getAnchorPoint() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Point(0, 0);
|
||||
CS_RETURN_IF(!_displayRenderNode) Vector2(0, 0);
|
||||
return _displayRenderNode->getAnchorPoint();
|
||||
}
|
||||
|
||||
Vector2 DisplayManager::getAnchorPointInPoints() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Point(0, 0);
|
||||
CS_RETURN_IF(!_displayRenderNode) Vector2(0, 0);
|
||||
return _displayRenderNode->getAnchorPointInPoints();
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,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(Point(x,y));
|
||||
widget->setPosition(Vector2(x,y));
|
||||
bool sx = DICTOOL->checkObjectExist_json(options, "scaleX");
|
||||
if (sx)
|
||||
{
|
||||
|
@ -415,7 +415,7 @@ void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget
|
|||
float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f);
|
||||
bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f);
|
||||
widget->setAnchorPoint(Point(apxf, apyf));
|
||||
widget->setAnchorPoint(Vector2(apxf, apyf));
|
||||
bool flipX = DICTOOL->getBooleanValue_json(options, "flipX");
|
||||
bool flipY = DICTOOL->getBooleanValue_json(options, "flipY");
|
||||
widget->setFlippedX(flipX);
|
||||
|
@ -689,7 +689,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(Widget*widg
|
|||
|
||||
float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX");
|
||||
float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY");
|
||||
panel->setBackGroundColorVector(Point(bgcv1, bgcv2));
|
||||
panel->setBackGroundColorVector(Vector2(bgcv1, bgcv2));
|
||||
|
||||
int co = DICTOOL->getIntValue_json(options, "bgColorOpacity");
|
||||
|
||||
|
@ -1128,8 +1128,8 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg
|
|||
widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType"));
|
||||
widget->setPositionType((PositionType)DICTOOL->getIntValue_json(options, "positionType"));
|
||||
|
||||
widget->setSizePercent(Point(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY")));
|
||||
widget->setPositionPercent(Point(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY")));
|
||||
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")));
|
||||
|
||||
float w = DICTOOL->getFloatValue_json(options, "width");
|
||||
float h = DICTOOL->getFloatValue_json(options, "height");
|
||||
|
@ -1143,7 +1143,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(Point(x,y));
|
||||
widget->setPosition(Vector2(x,y));
|
||||
bool sx = DICTOOL->checkObjectExist_json(options, "scaleX");
|
||||
if (sx)
|
||||
{
|
||||
|
@ -1229,7 +1229,7 @@ void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(Widget
|
|||
float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f);
|
||||
bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f);
|
||||
widget->setAnchorPoint(Point(apxf, apyf));
|
||||
widget->setAnchorPoint(Vector2(apxf, apyf));
|
||||
bool flipX = DICTOOL->getBooleanValue_json(options, "flipX");
|
||||
bool flipY = DICTOOL->getBooleanValue_json(options, "flipY");
|
||||
widget->setFlippedX(flipX);
|
||||
|
@ -1645,7 +1645,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widg
|
|||
|
||||
float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX");
|
||||
float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY");
|
||||
panel->setBackGroundColorVector(Point(bgcv1, bgcv2));
|
||||
panel->setBackGroundColorVector(Vector2(bgcv1, bgcv2));
|
||||
|
||||
int co = DICTOOL->getIntValue_json(options, "bgColorOpacity");
|
||||
|
||||
|
|
|
@ -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(Point(x, y));
|
||||
node->setPosition(Vector2(x, y));
|
||||
|
||||
const bool bVisible = (DICTOOL->getIntValue_json(root, "visible", 1) != 0);
|
||||
node->setVisible(bVisible);
|
||||
|
|
|
@ -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(Point(_skinData.x, _skinData.y));
|
||||
setPosition(Vector2(_skinData.x, _skinData.y));
|
||||
|
||||
_skinTransform = getNodeToParentTransform();
|
||||
updateArmatureTransform();
|
||||
|
@ -209,7 +209,7 @@ Matrix Skin::getNodeToWorldTransform() const
|
|||
Matrix Skin::getNodeToWorldTransformAR() const
|
||||
{
|
||||
Matrix displayTransform = _transform;
|
||||
Point anchorPoint = _anchorPointInPoints;
|
||||
Vector2 anchorPoint = _anchorPointInPoints;
|
||||
|
||||
anchorPoint = PointApplyTransform(anchorPoint, displayTransform);
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ namespace cocostudio {
|
|||
AffineTransform TransformHelp::helpMatrix1;
|
||||
AffineTransform TransformHelp::helpMatrix2;
|
||||
|
||||
Point TransformHelp::helpPoint1;
|
||||
Point TransformHelp::helpPoint2;
|
||||
Vector2 TransformHelp::helpPoint1;
|
||||
Vector2 TransformHelp::helpPoint2;
|
||||
|
||||
BaseData helpParentNode;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace cocos2d;
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
bool isSpriteContainPoint(Sprite *sprite, Point point, Point &outPoint)
|
||||
bool isSpriteContainPoint(Sprite *sprite, Vector2 point, Vector2 &outPoint)
|
||||
{
|
||||
outPoint = sprite->convertToNodeSpace(point);
|
||||
|
||||
|
@ -39,17 +39,17 @@ bool isSpriteContainPoint(Sprite *sprite, Point point, Point &outPoint)
|
|||
return r.containsPoint(outPoint);
|
||||
}
|
||||
|
||||
bool isSpriteContainPoint(Sprite *sprite, Point point)
|
||||
bool isSpriteContainPoint(Sprite *sprite, Vector2 point)
|
||||
{
|
||||
Point p = Point(0, 0);
|
||||
Vector2 p = Vector2(0, 0);
|
||||
return isSpriteContainPoint(sprite, point, p);
|
||||
}
|
||||
|
||||
|
||||
Point bezierTo(float t, Point &point1, Point &point2, Point &point3)
|
||||
Vector2 bezierTo(float t, Vector2 &point1, Vector2 &point2, Vector2 &point3)
|
||||
{
|
||||
|
||||
Point p;
|
||||
Vector2 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 @@ Point bezierTo(float t, Point &point1, Point &point2, Point &point3)
|
|||
return p;
|
||||
}
|
||||
|
||||
Point bezierTo(float t, Point &point1, Point &point2, Point &point3, Point &point4)
|
||||
Vector2 bezierTo(float t, Vector2 &point1, Vector2 &point2, Vector2 &point3, Vector2 &point4)
|
||||
{
|
||||
Point p;
|
||||
Vector2 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 @@ Point bezierTo(float t, Point &point1, Point &point2, Point &point3, Point &poin
|
|||
return p;
|
||||
}
|
||||
|
||||
Point circleTo(float t, Point ¢er, float radius, float fromRadian, float radianDif)
|
||||
Vector2 circleTo(float t, Vector2 ¢er, float radius, float fromRadian, float radianDif)
|
||||
{
|
||||
Point p;
|
||||
Vector2 p;
|
||||
|
||||
p.x = center.x + radius * cos(fromRadian + radianDif * t);
|
||||
p.y = center.y + radius * sin(fromRadian + radianDif * t);
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace cocostudio
|
|||
|
||||
float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX");
|
||||
float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY");
|
||||
panel->setBackGroundColorVector(Point(bgcv1, bgcv2));
|
||||
panel->setBackGroundColorVector(Vector2(bgcv1, bgcv2));
|
||||
|
||||
int co = DICTOOL->getIntValue_json(options, "bgColorOpacity");
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace cocostudio
|
|||
widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType"));
|
||||
widget->setPositionType((PositionType)DICTOOL->getIntValue_json(options, "positionType"));
|
||||
|
||||
widget->setSizePercent(Point(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY")));
|
||||
widget->setPositionPercent(Point(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY")));
|
||||
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")));
|
||||
|
||||
/* 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(Point(x,y));
|
||||
widget->setPosition(Vector2(x,y));
|
||||
bool sx = DICTOOL->checkObjectExist_json(options, "scaleX");
|
||||
if (sx)
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ namespace cocostudio
|
|||
float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f);
|
||||
bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f);
|
||||
widget->setAnchorPoint(Point(apxf, apyf));
|
||||
widget->setAnchorPoint(Vector2(apxf, apyf));
|
||||
bool flipX = DICTOOL->getBooleanValue_json(options, "flipX");
|
||||
bool flipY = DICTOOL->getBooleanValue_json(options, "flipY");
|
||||
widget->setFlippedX(flipX);
|
||||
|
|
|
@ -209,10 +209,10 @@ void Skeleton::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||
spRegionAttachment_updateQuad(attachment, slot, &tmpQuad);
|
||||
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
|
||||
points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y);
|
||||
points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y);
|
||||
points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y);
|
||||
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);
|
||||
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(Point(bone->worldX, bone->worldY), Point(x, y));
|
||||
DrawPrimitives::drawLine(Vector2(bone->worldX, bone->worldY), Vector2(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(Point(bone->worldX, bone->worldY));
|
||||
DrawPrimitives::drawPoint(Vector2(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);
|
||||
}
|
||||
Point position = getPosition();
|
||||
Vector2 position = getPosition();
|
||||
return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
|
||||
}
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ Vector2 Vector2::getIntersectPoint(const Vector2& A, const Vector2& B, const Vec
|
|||
|
||||
if (isLineIntersect(A, B, C, D, &S, &T))
|
||||
{
|
||||
// Point of intersection
|
||||
// Vector2 of intersection
|
||||
Vector2 P;
|
||||
P.x = A.x + S * (B.x - A.x);
|
||||
P.y = A.y + S * (B.y - A.y);
|
||||
|
|
|
@ -145,7 +145,7 @@ PhysicsBody* PhysicsBody::create(float mass, float moment)
|
|||
|
||||
}
|
||||
|
||||
PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& material, const Point& offset)
|
||||
PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& material, const Vector2& 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 Point& offset)
|
||||
PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& material, const Vector2& 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 Point* points, int count, const PhysicsMaterial& material, const Point& offset)
|
||||
PhysicsBody* PhysicsBody::createPolygon(const Vector2* points, int count, const PhysicsMaterial& material, const Vector2& offset)
|
||||
{
|
||||
PhysicsBody* body = new PhysicsBody();
|
||||
if (body && body->init())
|
||||
|
@ -187,7 +187,7 @@ PhysicsBody* PhysicsBody::createPolygon(const Point* points, int count, const Ph
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
PhysicsBody* PhysicsBody::createEdgeSegment(const Point& a, const Point& b, const PhysicsMaterial& material, float border/* = 1*/)
|
||||
PhysicsBody* PhysicsBody::createEdgeSegment(const Vector2& a, const Vector2& b, const PhysicsMaterial& material, float border/* = 1*/)
|
||||
{
|
||||
PhysicsBody* body = new PhysicsBody();
|
||||
if (body && body->init())
|
||||
|
@ -202,7 +202,7 @@ PhysicsBody* PhysicsBody::createEdgeSegment(const Point& a, const Point& b, cons
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Point& offset)
|
||||
PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Vector2& 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 Point* points, int count, const PhysicsMaterial& material, float border/* = 1*/)
|
||||
PhysicsBody* PhysicsBody::createEdgePolygon(const Vector2* 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 Point* points, int count, cons
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
PhysicsBody* PhysicsBody::createEdgeChain(const Point* points, int count, const PhysicsMaterial& material, float border/* = 1*/)
|
||||
PhysicsBody* PhysicsBody::createEdgeChain(const Vector2* points, int count, const PhysicsMaterial& material, float border/* = 1*/)
|
||||
{
|
||||
PhysicsBody* body = new PhysicsBody();
|
||||
if (body && body->init())
|
||||
|
@ -408,10 +408,10 @@ PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/*
|
|||
|
||||
void PhysicsBody::applyForce(const Vect& force)
|
||||
{
|
||||
applyForce(force, Point::ZERO);
|
||||
applyForce(force, Vector2::ZERO);
|
||||
}
|
||||
|
||||
void PhysicsBody::applyForce(const Vect& force, const Point& offset)
|
||||
void PhysicsBody::applyForce(const Vect& force, const Vector2& offset)
|
||||
{
|
||||
if (_dynamic && _mass != PHYSICS_INFINITY)
|
||||
{
|
||||
|
@ -432,10 +432,10 @@ void PhysicsBody::resetForces()
|
|||
|
||||
void PhysicsBody::applyImpulse(const Vect& impulse)
|
||||
{
|
||||
applyImpulse(impulse, Point());
|
||||
applyImpulse(impulse, Vector2());
|
||||
}
|
||||
|
||||
void PhysicsBody::applyImpulse(const Vect& impulse, const Point& offset)
|
||||
void PhysicsBody::applyImpulse(const Vect& impulse, const Vector2& offset)
|
||||
{
|
||||
cpBodyApplyImpulse(_info->getBody(), PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset));
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ void PhysicsBody::addMoment(float moment)
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::setVelocity(const Point& velocity)
|
||||
void PhysicsBody::setVelocity(const Vector2& velocity)
|
||||
{
|
||||
if (!_dynamic)
|
||||
{
|
||||
|
@ -580,17 +580,17 @@ void PhysicsBody::setVelocity(const Point& velocity)
|
|||
cpBodySetVel(_info->getBody(), PhysicsHelper::point2cpv(velocity));
|
||||
}
|
||||
|
||||
Point PhysicsBody::getVelocity()
|
||||
Vector2 PhysicsBody::getVelocity()
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVel(_info->getBody()));
|
||||
}
|
||||
|
||||
Point PhysicsBody::getVelocityAtLocalPoint(const Point& point)
|
||||
Vector2 PhysicsBody::getVelocityAtLocalPoint(const Vector2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
||||
Point PhysicsBody::getVelocityAtWorldPoint(const Point& point)
|
||||
Vector2 PhysicsBody::getVelocityAtWorldPoint(const Vector2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
@ -826,17 +826,17 @@ void PhysicsBody::setGroup(int group)
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::setPositionOffset(const Point& position)
|
||||
void PhysicsBody::setPositionOffset(const Vector2& position)
|
||||
{
|
||||
if (!_positionOffset.equals(position))
|
||||
{
|
||||
Point pos = getPosition();
|
||||
Vector2 pos = getPosition();
|
||||
_positionOffset = position;
|
||||
setPosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
Point PhysicsBody::getPositionOffset() const
|
||||
Vector2 PhysicsBody::getPositionOffset() const
|
||||
{
|
||||
return _positionOffset;
|
||||
}
|
||||
|
@ -856,12 +856,12 @@ float PhysicsBody::getRotationOffset() const
|
|||
return _rotationOffset;
|
||||
}
|
||||
|
||||
Point PhysicsBody::world2Local(const Point& point)
|
||||
Vector2 PhysicsBody::world2Local(const Vector2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyWorld2Local(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
||||
Point PhysicsBody::local2World(const Point& point)
|
||||
Vector2 PhysicsBody::local2World(const Vector2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyLocal2World(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
|
|
@ -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)) : Point::ZERO;
|
||||
_contactData->normal = _contactData->count > 0 ? PhysicsHelper::cpv2point(cpArbiterGetNormal(arb, 0)) : Vector2::ZERO;
|
||||
}
|
||||
|
||||
// PhysicsContactPreSolve implementation
|
||||
|
@ -129,7 +129,7 @@ float PhysicsContactPreSolve::getFriction() const
|
|||
return static_cast<cpArbiter*>(_contactInfo)->u;
|
||||
}
|
||||
|
||||
Point PhysicsContactPreSolve::getSurfaceVelocity() const
|
||||
Vector2 PhysicsContactPreSolve::getSurfaceVelocity() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(static_cast<cpArbiter*>(_contactInfo)->surface_vr);
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ float PhysicsContactPostSolve::getFriction() const
|
|||
return static_cast<cpArbiter*>(_contactInfo)->u;
|
||||
}
|
||||
|
||||
Point PhysicsContactPostSolve::getSurfaceVelocity() const
|
||||
Vector2 PhysicsContactPostSolve::getSurfaceVelocity() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(static_cast<cpArbiter*>(_contactInfo)->surface_vr);
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ float PhysicsJoint::getMaxForce() const
|
|||
return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce);
|
||||
}
|
||||
|
||||
PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
|
||||
PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& 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 Point& anchr)
|
||||
bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
|
|||
return false;
|
||||
}
|
||||
|
||||
PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
|
||||
PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& 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 Point& anchr)
|
||||
bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Vector2& anchr)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr)
|
|||
return false;
|
||||
}
|
||||
|
||||
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max)
|
||||
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& 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 Point& anchr1, const Point& anchr2)
|
||||
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2)
|
||||
{
|
||||
return construct(a, b, anchr1, anchr2, 0, b->local2World(anchr1).getDistance(a->local2World(anchr2)));
|
||||
}
|
||||
|
||||
bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max)
|
||||
bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& anchr2, float min, float max)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -294,27 +294,27 @@ void PhysicsJointLimit::setMax(float max)
|
|||
cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max));
|
||||
}
|
||||
|
||||
Point PhysicsJointLimit::getAnchr1() const
|
||||
Vector2 PhysicsJointLimit::getAnchr1() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointLimit::setAnchr1(const Point& anchr)
|
||||
void PhysicsJointLimit::setAnchr1(const Vector2& anchr)
|
||||
{
|
||||
cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
Point PhysicsJointLimit::getAnchr2() const
|
||||
Vector2 PhysicsJointLimit::getAnchr2() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointLimit::setAnchr2(const Point& anchr)
|
||||
void PhysicsJointLimit::setAnchr2(const Vector2& anchr)
|
||||
{
|
||||
cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
|
||||
PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& 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 Point& anchr1, const Point& anchr2)
|
||||
bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& 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 Point& anchr1, const Point& anchr2, float stiffness, float damping)
|
||||
PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& 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 Point& anchr1, const Point& anchr2, float stiffness, float damping)
|
||||
bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Vector2& anchr1, const Vector2& 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 Point& anchr
|
|||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsJointSpring::getAnchr1() const
|
||||
Vector2 PhysicsJointSpring::getAnchr1() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setAnchr1(const Point& anchr)
|
||||
void PhysicsJointSpring::setAnchr1(const Vector2& anchr)
|
||||
{
|
||||
cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
Point PhysicsJointSpring::getAnchr2() const
|
||||
Vector2 PhysicsJointSpring::getAnchr2() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setAnchr2(const Point& anchr)
|
||||
void PhysicsJointSpring::setAnchr2(const Vector2& 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 Point& grooveA, const Point& grooveB, const Point& anchr2)
|
||||
PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Vector2& grooveA, const Vector2& grooveB, const Vector2& 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 Point& grooveA, const Point& grooveB, const Point& anchr2)
|
||||
bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Vector2& grooveA, const Vector2& grooveB, const Vector2& anchr2)
|
||||
{
|
||||
do {
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
@ -478,32 +478,32 @@ bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Point& groov
|
|||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsJointGroove::getGrooveA() const
|
||||
Vector2 PhysicsJointGroove::getGrooveA() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGroove::setGrooveA(const Point& grooveA)
|
||||
void PhysicsJointGroove::setGrooveA(const Vector2& grooveA)
|
||||
{
|
||||
cpGrooveJointSetGrooveA(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveA));
|
||||
}
|
||||
|
||||
Point PhysicsJointGroove::getGrooveB() const
|
||||
Vector2 PhysicsJointGroove::getGrooveB() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGroove::setGrooveB(const Point& grooveB)
|
||||
void PhysicsJointGroove::setGrooveB(const Vector2& grooveB)
|
||||
{
|
||||
cpGrooveJointSetGrooveB(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveB));
|
||||
}
|
||||
|
||||
Point PhysicsJointGroove::getAnchr2() const
|
||||
Vector2 PhysicsJointGroove::getAnchr2() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGroove::setAnchr2(const Point& anchr2)
|
||||
void PhysicsJointGroove::setAnchr2(const Vector2& anchr2)
|
||||
{
|
||||
cpGrooveJointSetAnchr2(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr2));
|
||||
}
|
||||
|
|
|
@ -229,14 +229,14 @@ void PhysicsShape::setFriction(float friction)
|
|||
}
|
||||
|
||||
|
||||
void PhysicsShape::recenterPoints(Point* points, int count, const Point& center)
|
||||
void PhysicsShape::recenterPoints(Vector2* points, int count, const Vector2& center)
|
||||
{
|
||||
cpVect* cpvs = new cpVect[count];
|
||||
cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count));
|
||||
PhysicsHelper::cpvs2points(cpvs, points, count);
|
||||
delete[] cpvs;
|
||||
|
||||
if (center != Point::ZERO)
|
||||
if (center != Vector2::ZERO)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ void PhysicsShape::recenterPoints(Point* points, int count, const Point& center)
|
|||
}
|
||||
}
|
||||
|
||||
Point PhysicsShape::getPolyonCenter(const Point* points, int count)
|
||||
Vector2 PhysicsShape::getPolyonCenter(const Vector2* 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 Point& offset/* = Point(0, 0)*/)
|
||||
PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(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 Point& offset /*= Point(0, 0)*/)
|
||||
bool PhysicsShapeCircle::init(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset /*= Vector2(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 Point& offset)
|
||||
float PhysicsShapeCircle::calculateMoment(float mass, float radius, const Vector2& 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()));
|
||||
}
|
||||
|
||||
Point PhysicsShapeCircle::getOffset()
|
||||
Vector2 PhysicsShapeCircle::getOffset()
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_info->getShapes().front()));
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeSegment
|
||||
PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(const Point& a, const Point& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(const Vector2& a, const Vector2& 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 Point& a, const P
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsShapeEdgeSegment::init(const Point& a, const Point& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
bool PhysicsShapeEdgeSegment::init(const Vector2& a, const Vector2& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -397,23 +397,23 @@ bool PhysicsShapeEdgeSegment::init(const Point& a, const Point& b, const Physics
|
|||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsShapeEdgeSegment::getPointA() const
|
||||
Vector2 PhysicsShapeEdgeSegment::getPointA() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->ta);
|
||||
}
|
||||
|
||||
Point PhysicsShapeEdgeSegment::getPointB() const
|
||||
Vector2 PhysicsShapeEdgeSegment::getPointB() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->tb);
|
||||
}
|
||||
|
||||
Point PhysicsShapeEdgeSegment::getCenter()
|
||||
Vector2 PhysicsShapeEdgeSegment::getCenter()
|
||||
{
|
||||
return _center;
|
||||
}
|
||||
|
||||
// PhysicsShapeBox
|
||||
PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/)
|
||||
PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(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 Point& offset /*= Point(0, 0)*/)
|
||||
bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset /*= Vector2(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 Point& offset)
|
||||
float PhysicsShapeBox::calculateMoment(float mass, const Size& size, const Vector2& 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(Point* points) const
|
||||
void PhysicsShapeBox::getPoints(Vector2* 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 Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/)
|
||||
PhysicsShapePolygon* PhysicsShapePolygon::create(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(0, 0)*/)
|
||||
{
|
||||
PhysicsShapePolygon* shape = new PhysicsShapePolygon();
|
||||
if (shape && shape->init(points, count, material, offset))
|
||||
|
@ -522,7 +522,7 @@ PhysicsShapePolygon* PhysicsShapePolygon::create(const Point* points, int count,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/)
|
||||
bool PhysicsShapePolygon::init(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Vector2& offset/* = Vector2(0, 0)*/)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -550,7 +550,7 @@ bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMate
|
|||
return false;
|
||||
}
|
||||
|
||||
float PhysicsShapePolygon::calculateArea(const Point* points, int count)
|
||||
float PhysicsShapePolygon::calculateArea(const Vector2* points, int count)
|
||||
{
|
||||
cpVect* vecs = new cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vecs, count);
|
||||
|
@ -560,7 +560,7 @@ float PhysicsShapePolygon::calculateArea(const Point* points, int count)
|
|||
return area;
|
||||
}
|
||||
|
||||
float PhysicsShapePolygon::calculateMoment(float mass, const Point* points, int count, const Point& offset)
|
||||
float PhysicsShapePolygon::calculateMoment(float mass, const Vector2* points, int count, const Vector2& 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));
|
||||
}
|
||||
|
||||
Point PhysicsShapePolygon::getPoint(int i) const
|
||||
Vector2 PhysicsShapePolygon::getPoint(int i) const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_info->getShapes().front(), i));
|
||||
}
|
||||
|
||||
void PhysicsShapePolygon::getPoints(Point* outPoints) const
|
||||
void PhysicsShapePolygon::getPoints(Vector2* 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;
|
||||
}
|
||||
|
||||
Point PhysicsShapePolygon::getCenter()
|
||||
Vector2 PhysicsShapePolygon::getCenter()
|
||||
{
|
||||
return _center;
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeBox
|
||||
PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Point& offset/* = Point(0, 0)*/)
|
||||
PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vector2& offset/* = Vector2(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 Point& offset/*= Point(0, 0)*/)
|
||||
bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vector2& offset/*= Vector2(0, 0)*/)
|
||||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX));
|
||||
|
||||
cpVect vec[4] = {};
|
||||
vec[0] = PhysicsHelper::point2cpv(Point(-size.width/2+offset.x, -size.height/2+offset.y));
|
||||
vec[1] = PhysicsHelper::point2cpv(Point(+size.width/2+offset.x, -size.height/2+offset.y));
|
||||
vec[2] = PhysicsHelper::point2cpv(Point(+size.width/2+offset.x, +size.height/2+offset.y));
|
||||
vec[3] = PhysicsHelper::point2cpv(Point(-size.width/2+offset.x, +size.height/2+offset.y));
|
||||
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));
|
||||
|
||||
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::Point *outPoints) const
|
||||
void PhysicsShapeEdgeBox::getPoints(cocos2d::Vector2 *outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
|
@ -663,7 +663,7 @@ void PhysicsShapeEdgeBox::getPoints(cocos2d::Point *outPoints) const
|
|||
}
|
||||
|
||||
// PhysicsShapeEdgeBox
|
||||
PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Vector2* 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 Point* points, in
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsShapeEdgePolygon::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
bool PhysicsShapeEdgePolygon::init(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
{
|
||||
cpVect* vec = nullptr;
|
||||
do
|
||||
|
@ -714,12 +714,12 @@ bool PhysicsShapeEdgePolygon::init(const Point* points, int count, const Physics
|
|||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsShapeEdgePolygon::getCenter()
|
||||
Vector2 PhysicsShapeEdgePolygon::getCenter()
|
||||
{
|
||||
return _center;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgePolygon::getPoints(cocos2d::Point *outPoints) const
|
||||
void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vector2 *outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
|
@ -734,7 +734,7 @@ int PhysicsShapeEdgePolygon::getPointsCount() const
|
|||
}
|
||||
|
||||
// PhysicsShapeEdgeChain
|
||||
PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Vector2* 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 Point* points, int co
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsShapeEdgeChain::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
bool PhysicsShapeEdgeChain::init(const Vector2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
{
|
||||
cpVect* vec = nullptr;
|
||||
do
|
||||
|
@ -784,12 +784,12 @@ bool PhysicsShapeEdgeChain::init(const Point* points, int count, const PhysicsMa
|
|||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsShapeEdgeChain::getCenter()
|
||||
Vector2 PhysicsShapeEdgeChain::getCenter()
|
||||
{
|
||||
return _center;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgeChain::getPoints(Point* outPoints) const
|
||||
void PhysicsShapeEdgeChain::getPoints(Vector2* 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 Point& point) const
|
||||
bool PhysicsShape::containsPoint(const Vector2& point) const
|
||||
{
|
||||
for (auto shape : _info->getShapes())
|
||||
{
|
||||
|
|
|
@ -66,8 +66,8 @@ namespace
|
|||
{
|
||||
PhysicsWorld* world;
|
||||
PhysicsRayCastCallbackFunc func;
|
||||
Point p1;
|
||||
Point p2;
|
||||
Vector2 p1;
|
||||
Vector2 p2;
|
||||
void* data;
|
||||
}RayCastCallbackInfo;
|
||||
|
||||
|
@ -153,8 +153,8 @@ void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect
|
|||
it->second->getShape(),
|
||||
info->p1,
|
||||
info->p2,
|
||||
Point(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t),
|
||||
Point(n.x, n.y),
|
||||
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),
|
||||
(float)t,
|
||||
};
|
||||
|
||||
|
@ -334,7 +334,7 @@ void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
|
|||
_scene->getEventDispatcher()->dispatchEvent(&contact);
|
||||
}
|
||||
|
||||
void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Point& point1, const Point& point2, void* data)
|
||||
void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vector2& point1, const Vector2& 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 Point& point, void* data)
|
||||
void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vector2& point, void* data)
|
||||
{
|
||||
CCASSERT(func != nullptr, "func shouldn't be nullptr");
|
||||
|
||||
|
@ -390,7 +390,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Point& p
|
|||
}
|
||||
}
|
||||
|
||||
Vector<PhysicsShape*> PhysicsWorld::getShapes(const Point& point) const
|
||||
Vector<PhysicsShape*> PhysicsWorld::getShapes(const Vector2& point) const
|
||||
{
|
||||
Vector<PhysicsShape*> arr;
|
||||
cpSpaceNearestPointQuery(this->_info->getSpace(),
|
||||
|
@ -404,7 +404,7 @@ Vector<PhysicsShape*> PhysicsWorld::getShapes(const Point& point) const
|
|||
return arr;
|
||||
}
|
||||
|
||||
PhysicsShape* PhysicsWorld::getShape(const Point& point) const
|
||||
PhysicsShape* PhysicsWorld::getShape(const Vector2& point) const
|
||||
{
|
||||
cpShape* shape = cpSpaceNearestPointQueryNearest(this->_info->getSpace(),
|
||||
PhysicsHelper::point2cpv(point),
|
||||
|
@ -906,7 +906,7 @@ void PhysicsWorld::update(float delta)
|
|||
}
|
||||
|
||||
PhysicsWorld::PhysicsWorld()
|
||||
: _gravity(Point(0.0f, -98.0f))
|
||||
: _gravity(Vector2(0.0f, -98.0f))
|
||||
, _speed(1.0f)
|
||||
, _updateRate(1)
|
||||
, _updateRateCount(0)
|
||||
|
@ -966,16 +966,16 @@ void PhysicsDebugDraw::drawShape(PhysicsShape& shape)
|
|||
case CP_CIRCLE_SHAPE:
|
||||
{
|
||||
float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(subShape));
|
||||
Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape)))
|
||||
Vector2 centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape)))
|
||||
+ PhysicsHelper::cpv2point(cpCircleShapeGetOffset(subShape));
|
||||
|
||||
static const int CIRCLE_SEG_NUM = 12;
|
||||
Point seg[CIRCLE_SEG_NUM] = {};
|
||||
Vector2 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;
|
||||
Point d(radius * cosf(angle), radius * sinf(angle));
|
||||
Vector2 d(radius * cosf(angle), radius * sinf(angle));
|
||||
seg[i] = centre + d;
|
||||
}
|
||||
_drawNode->drawPolygon(seg, CIRCLE_SEG_NUM, fillColor, 1, outlineColor);
|
||||
|
@ -993,7 +993,7 @@ void PhysicsDebugDraw::drawShape(PhysicsShape& shape)
|
|||
{
|
||||
cpPolyShape* poly = (cpPolyShape*)subShape;
|
||||
int num = poly->numVerts;
|
||||
Point* seg = new Point[num];
|
||||
Vector2* seg = new Vector2[num];
|
||||
|
||||
PhysicsHelper::cpvs2points(poly->tVerts, seg, num);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ void Button::initRenderer()
|
|||
_buttonClickedRenderer = Sprite::create();
|
||||
_buttonDisableRenderer = Sprite::create();
|
||||
_titleRenderer = Label::create();
|
||||
_titleRenderer->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
_titleRenderer->setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
|
||||
addProtectedChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
|
||||
addProtectedChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
|
||||
|
@ -523,7 +523,7 @@ void Button::setAnchorPoint(const Vector2 &pt)
|
|||
_buttonNormalRenderer->setAnchorPoint(pt);
|
||||
_buttonClickedRenderer->setAnchorPoint(pt);
|
||||
_buttonDisableRenderer->setAnchorPoint(pt);
|
||||
_titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y)));
|
||||
_titleRenderer->setPosition(Vector2(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y)));
|
||||
}
|
||||
|
||||
void Button::onSizeChanged()
|
||||
|
|
|
@ -136,7 +136,7 @@ void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Ve
|
|||
if (layoutParameter)
|
||||
{
|
||||
LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Point ap = child->getAnchorPoint();
|
||||
Vector2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
float finalPosX = ap.x * cs.width;
|
||||
float finalPosY = topBoundary - ((1.0f-ap.y) * cs.height);
|
||||
|
@ -157,7 +157,7 @@ void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Ve
|
|||
Margin mg = layoutParameter->getMargin();
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
child->setPosition(Point(finalPosX, finalPosY));
|
||||
child->setPosition(Vector2(finalPosX, finalPosY));
|
||||
topBoundary = child->getBottomInParent() - mg.bottom;
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize,
|
|||
if (layoutParameter)
|
||||
{
|
||||
LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Point ap = child->getAnchorPoint();
|
||||
Vector2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
float finalPosX = leftBoundary + (ap.x * cs.width);
|
||||
float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height;
|
||||
|
@ -197,7 +197,7 @@ void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize,
|
|||
Margin mg = layoutParameter->getMargin();
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
child->setPosition(Point(finalPosX, finalPosY));
|
||||
child->setPosition(Vector2(finalPosX, finalPosY));
|
||||
leftBoundary = child->getRightInParent() + mg.right;
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector<c
|
|||
{
|
||||
continue;
|
||||
}
|
||||
Point ap = child->getAnchorPoint();
|
||||
Vector2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
RelativeAlign align = layoutParameter->getAlign();
|
||||
const char* relativeName = layoutParameter->getRelativeToWidgetName();
|
||||
|
@ -550,7 +550,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector<c
|
|||
default:
|
||||
break;
|
||||
}
|
||||
child->setPosition(Point(finalPosX, finalPosY));
|
||||
child->setPosition(Vector2(finalPosX, finalPosY));
|
||||
layoutParameter->_put = true;
|
||||
unlayoutChildCount--;
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ _gradientRender(nullptr),
|
|||
_cColor(Color3B::WHITE),
|
||||
_gStartColor(Color3B::WHITE),
|
||||
_gEndColor(Color3B::WHITE),
|
||||
_alongVector(Point(0.0f, -1.0f)),
|
||||
_alongVector(Vector2(0.0f, -1.0f)),
|
||||
_cOpacity(255),
|
||||
_backGroundImageTextureSize(Size::ZERO),
|
||||
_layoutType(LAYOUT_ABSOLUTE),
|
||||
|
@ -656,7 +656,7 @@ bool Layout::init()
|
|||
setBright(true);
|
||||
ignoreContentAdaptWithSize(false);
|
||||
setSize(Size::ZERO);
|
||||
setAnchorPoint(Point::ZERO);
|
||||
setAnchorPoint(Vector2::ZERO);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -701,9 +701,9 @@ bool Layout::isClippingEnabled()
|
|||
return _clippingEnabled;
|
||||
}
|
||||
|
||||
bool Layout::hitTest(const Point &pt)
|
||||
bool Layout::hitTest(const Vector2 &pt)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(pt);
|
||||
Vector2 nsp = convertToNodeSpace(pt);
|
||||
Rect bb = Rect(0.0f, 0.0f, _size.width, _size.height);
|
||||
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)
|
||||
{
|
||||
|
@ -861,7 +861,7 @@ void Layout::onBeforeVisitStencil()
|
|||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1));
|
||||
DrawPrimitives::drawSolidRect(Vector2(-1,-1), Vector2(1,1), Color4F(1, 1, 1, 1));
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
@ -981,11 +981,11 @@ void Layout::setStencilClippingSize(const Size &size)
|
|||
{
|
||||
if (_clippingEnabled && _clippingType == LAYOUT_CLIPPING_STENCIL)
|
||||
{
|
||||
Point rect[4];
|
||||
rect[0] = Point::ZERO;
|
||||
rect[1] = Point(_size.width, 0);
|
||||
rect[2] = Point(_size.width, _size.height);
|
||||
rect[3] = Point(0, _size.height);
|
||||
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);
|
||||
Color4F green(0, 1, 0, 1);
|
||||
_clippingStencil->clear();
|
||||
_clippingStencil->drawPolygon(rect, 4, green, 0, green);
|
||||
|
@ -996,7 +996,7 @@ const Rect& Layout::getClippingRect()
|
|||
{
|
||||
if (_clippingRectDirty)
|
||||
{
|
||||
Point worldPos = convertToWorldSpace(Point::ZERO);
|
||||
Vector2 worldPos = convertToWorldSpace(Vector2::ZERO);
|
||||
AffineTransform t = getNodeToWorldAffineTransform();
|
||||
float scissorWidth = _size.width*t.a;
|
||||
float scissorHeight = _size.height*t.d;
|
||||
|
@ -1080,7 +1080,7 @@ void Layout::onSizeChanged()
|
|||
_clippingRectDirty = true;
|
||||
if (_backGroundImage)
|
||||
{
|
||||
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
||||
_backGroundImage->setPosition(Vector2(_size.width/2.0f, _size.height/2.0f));
|
||||
if (_backGroundScale9Enabled && _backGroundImage)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size);
|
||||
|
@ -1158,7 +1158,7 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
|
|||
}
|
||||
}
|
||||
_backGroundImageTextureSize = _backGroundImage->getContentSize();
|
||||
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
||||
_backGroundImage->setPosition(Vector2(_size.width/2.0f, _size.height/2.0f));
|
||||
updateBackGroundImageRGBA();
|
||||
}
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ void Layout::addBackGroundImage()
|
|||
_backGroundImage = Sprite::create();
|
||||
addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
}
|
||||
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
||||
_backGroundImage->setPosition(Vector2(_size.width/2.0f, _size.height/2.0f));
|
||||
}
|
||||
|
||||
void Layout::removeBackGroundImage()
|
||||
|
@ -1367,7 +1367,7 @@ GLubyte Layout::getBackGroundColorOpacity()
|
|||
return _cOpacity;
|
||||
}
|
||||
|
||||
void Layout::setBackGroundColorVector(const Point &vector)
|
||||
void Layout::setBackGroundColorVector(const Vector2 &vector)
|
||||
{
|
||||
_alongVector = vector;
|
||||
if (_gradientRender)
|
||||
|
@ -1376,7 +1376,7 @@ void Layout::setBackGroundColorVector(const Point &vector)
|
|||
}
|
||||
}
|
||||
|
||||
const Point& Layout::getBackGroundColorVector()
|
||||
const Vector2& Layout::getBackGroundColorVector()
|
||||
{
|
||||
return _alongVector;
|
||||
}
|
||||
|
|
|
@ -428,7 +428,7 @@ void ListView::selectedItemEvent(int state)
|
|||
|
||||
}
|
||||
|
||||
void ListView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint)
|
||||
void ListView::interceptTouchEvent(int handleState, Widget *sender, const Vector2 &touchPoint)
|
||||
{
|
||||
ScrollView::interceptTouchEvent(handleState, sender, touchPoint);
|
||||
if (handleState != 1)
|
||||
|
|
|
@ -81,7 +81,7 @@ void LoadingBar::initRenderer()
|
|||
{
|
||||
_barRenderer = Sprite::create();
|
||||
addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1);
|
||||
_barRenderer->setAnchorPoint(Point(0.0,0.5));
|
||||
_barRenderer->setAnchorPoint(Vector2(0.0,0.5));
|
||||
}
|
||||
|
||||
void LoadingBar::setDirection(LoadingBarType dir)
|
||||
|
@ -95,16 +95,16 @@ void LoadingBar::setDirection(LoadingBarType dir)
|
|||
switch (_barType)
|
||||
{
|
||||
case LoadingBarTypeLeft:
|
||||
_barRenderer->setAnchorPoint(Point(0.0f,0.5f));
|
||||
_barRenderer->setPosition(Point(-_totalLength*0.5f,0.0f));
|
||||
_barRenderer->setAnchorPoint(Vector2(0.0f,0.5f));
|
||||
_barRenderer->setPosition(Vector2(-_totalLength*0.5f,0.0f));
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
static_cast<Sprite*>(_barRenderer)->setFlippedX(false);
|
||||
}
|
||||
break;
|
||||
case LoadingBarTypeRight:
|
||||
_barRenderer->setAnchorPoint(Point(1.0f,0.5f));
|
||||
_barRenderer->setPosition(Point(_totalLength*0.5f,0.0f));
|
||||
_barRenderer->setAnchorPoint(Vector2(1.0f,0.5f));
|
||||
_barRenderer->setPosition(Vector2(_totalLength*0.5f,0.0f));
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
static_cast<Sprite*>(_barRenderer)->setFlippedX(true);
|
||||
|
@ -161,14 +161,14 @@ int LoadingBar::getDirection()
|
|||
switch (_barType)
|
||||
{
|
||||
case LoadingBarTypeLeft:
|
||||
_barRenderer->setAnchorPoint(Point(0.0f,0.5f));
|
||||
_barRenderer->setAnchorPoint(Vector2(0.0f,0.5f));
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
static_cast<Sprite*>(_barRenderer)->setFlippedX(false);
|
||||
}
|
||||
break;
|
||||
case LoadingBarTypeRight:
|
||||
_barRenderer->setAnchorPoint(Point(1.0f,0.5f));
|
||||
_barRenderer->setAnchorPoint(Vector2(1.0f,0.5f));
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
static_cast<Sprite*>(_barRenderer)->setFlippedX(true);
|
||||
|
@ -323,10 +323,10 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
switch (_barType)
|
||||
{
|
||||
case LoadingBarTypeLeft:
|
||||
_barRenderer->setPosition(Point(-_totalLength * 0.5f, 0.0f));
|
||||
_barRenderer->setPosition(Vector2(-_totalLength * 0.5f, 0.0f));
|
||||
break;
|
||||
case LoadingBarTypeRight:
|
||||
_barRenderer->setPosition(Point(_totalLength * 0.5f, 0.0f));
|
||||
_barRenderer->setPosition(Vector2(_totalLength * 0.5f, 0.0f));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -35,7 +35,7 @@ _curPageIdx(0),
|
|||
_touchMoveDir(PAGEVIEW_TOUCHLEFT),
|
||||
_touchStartLocation(0.0f),
|
||||
_touchMoveStartLocation(0.0f),
|
||||
_movePagePoint(Point::ZERO),
|
||||
_movePagePoint(Vector2::ZERO),
|
||||
_leftChild(nullptr),
|
||||
_rightChild(nullptr),
|
||||
_leftBoundary(0.0f),
|
||||
|
@ -145,7 +145,7 @@ void PageView::addPage(Layout* page)
|
|||
CCLOG("page size does not match pageview size, it will be force sized!");
|
||||
page->setSize(pvSize);
|
||||
}
|
||||
page->setPosition(Point(getPositionXByIndex(_pages.size()), 0));
|
||||
page->setPosition(Vector2(getPositionXByIndex(_pages.size()), 0));
|
||||
_pages.pushBack(page);
|
||||
addChild(page);
|
||||
updateBoundaryPages();
|
||||
|
@ -178,7 +178,7 @@ void PageView::insertPage(Layout* page, int idx)
|
|||
else
|
||||
{
|
||||
_pages.insert(idx, page);
|
||||
page->setPosition(Point(getPositionXByIndex(idx), 0));
|
||||
page->setPosition(Vector2(getPositionXByIndex(idx), 0));
|
||||
addChild(page);
|
||||
Size pSize = page->getSize();
|
||||
Size pvSize = getSize();
|
||||
|
@ -190,8 +190,8 @@ void PageView::insertPage(Layout* page, int idx)
|
|||
ssize_t length = _pages.size();
|
||||
for (ssize_t i=(idx+1); i<length; i++){
|
||||
Widget* behindPage = _pages.at(i);
|
||||
Point formerPos = behindPage->getPosition();
|
||||
behindPage->setPosition(Point(formerPos.x+getSize().width, 0));
|
||||
Vector2 formerPos = behindPage->getPosition();
|
||||
behindPage->setPosition(Vector2(formerPos.x+getSize().width, 0));
|
||||
}
|
||||
updateBoundaryPages();
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ void PageView::updateChildrenPosition()
|
|||
for (int i=0; i<pageCount; i++)
|
||||
{
|
||||
Layout* page = _pages.at(i);
|
||||
page->setPosition(Point((i-_curPageIdx)*pageWidth, 0));
|
||||
page->setPosition(Vector2((i-_curPageIdx)*pageWidth, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,16 +464,16 @@ bool PageView::scrollPages(float touchOffset)
|
|||
return true;
|
||||
}
|
||||
|
||||
void PageView::handlePressLogic(const Point &touchPoint)
|
||||
void PageView::handlePressLogic(const Vector2 &touchPoint)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(touchPoint);
|
||||
Vector2 nsp = convertToNodeSpace(touchPoint);
|
||||
_touchMoveStartLocation = nsp.x;
|
||||
_touchStartLocation = nsp.x;
|
||||
}
|
||||
|
||||
void PageView::handleMoveLogic(const Point &touchPoint)
|
||||
void PageView::handleMoveLogic(const Vector2 &touchPoint)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(touchPoint);
|
||||
Vector2 nsp = convertToNodeSpace(touchPoint);
|
||||
float offset = 0.0;
|
||||
float moveX = nsp.x;
|
||||
offset = moveX - _touchMoveStartLocation;
|
||||
|
@ -489,7 +489,7 @@ void PageView::handleMoveLogic(const Point &touchPoint)
|
|||
scrollPages(offset);
|
||||
}
|
||||
|
||||
void PageView::handleReleaseLogic(const Point &touchPoint)
|
||||
void PageView::handleReleaseLogic(const Vector2 &touchPoint)
|
||||
{
|
||||
if (_pages.size() <= 0)
|
||||
{
|
||||
|
@ -498,7 +498,7 @@ void PageView::handleReleaseLogic(const Point &touchPoint)
|
|||
Widget* curPage = _pages.at(_curPageIdx);
|
||||
if (curPage)
|
||||
{
|
||||
Point curPagePos = curPage->getPosition();
|
||||
Vector2 curPagePos = curPage->getPosition();
|
||||
ssize_t pageCount = _pages.size();
|
||||
float curPageLocation = curPagePos.x;
|
||||
float pageWidth = getSize().width;
|
||||
|
@ -532,12 +532,12 @@ void PageView::handleReleaseLogic(const Point &touchPoint)
|
|||
}
|
||||
}
|
||||
|
||||
void PageView::checkChildInfo(int handleState,Widget* sender, const Point &touchPoint)
|
||||
void PageView::checkChildInfo(int handleState,Widget* sender, const Vector2 &touchPoint)
|
||||
{
|
||||
interceptTouchEvent(handleState, sender, touchPoint);
|
||||
}
|
||||
|
||||
void PageView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint)
|
||||
void PageView::interceptTouchEvent(int handleState, Widget *sender, const Vector2 &touchPoint)
|
||||
{
|
||||
switch (handleState)
|
||||
{
|
||||
|
|
|
@ -162,7 +162,7 @@ bool RichText::init()
|
|||
void RichText::initRenderer()
|
||||
{
|
||||
_elementRenderersContainer = Node::create();
|
||||
_elementRenderersContainer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_elementRenderersContainer->setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
addProtectedChild(_elementRenderersContainer, 0, -1);
|
||||
}
|
||||
|
||||
|
@ -368,8 +368,8 @@ void RichText::formarRenderers()
|
|||
for (ssize_t j=0; j<row->size(); j++)
|
||||
{
|
||||
Node* l = row->at(j);
|
||||
l->setAnchorPoint(Point::ZERO);
|
||||
l->setPosition(Point(nextPosX, 0.0f));
|
||||
l->setAnchorPoint(Vector2::ZERO);
|
||||
l->setPosition(Vector2(nextPosX, 0.0f));
|
||||
_elementRenderersContainer->addChild(l, 1, (int)j);
|
||||
Size iSize = l->getContentSize();
|
||||
newContentSizeWidth += iSize.width;
|
||||
|
@ -407,8 +407,8 @@ void RichText::formarRenderers()
|
|||
for (ssize_t j=0; j<row->size(); j++)
|
||||
{
|
||||
Node* l = row->at(j);
|
||||
l->setAnchorPoint(Point::ZERO);
|
||||
l->setPosition(Point(nextPosX, nextPosY));
|
||||
l->setAnchorPoint(Vector2::ZERO);
|
||||
l->setPosition(Vector2(nextPosX, nextPosY));
|
||||
_elementRenderersContainer->addChild(l, 1, (int)(i*10 + j));
|
||||
nextPosX += l->getContentSize().width;
|
||||
}
|
||||
|
|
|
@ -65,21 +65,21 @@ const Size& ScrollInnerContainer::getLayoutSize()
|
|||
|
||||
static const float AUTOSCROLLMAXSPEED = 1000.0f;
|
||||
|
||||
const Point SCROLLDIR_UP = Point(0.0f, 1.0f);
|
||||
const Point SCROLLDIR_DOWN = Point(0.0f, -1.0f);
|
||||
const Point SCROLLDIR_LEFT = Point(-1.0f, 0.0f);
|
||||
const Point SCROLLDIR_RIGHT = Point(1.0f, 0.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);
|
||||
|
||||
IMPLEMENT_CLASS_GUI_INFO(ScrollView)
|
||||
|
||||
ScrollView::ScrollView():
|
||||
_innerContainer(nullptr),
|
||||
_direction(SCROLLVIEW_DIR_VERTICAL),
|
||||
_touchBeganPoint(Point::ZERO),
|
||||
_touchMovedPoint(Point::ZERO),
|
||||
_touchEndedPoint(Point::ZERO),
|
||||
_touchMovingPoint(Point::ZERO),
|
||||
_autoScrollDir(Point::ZERO),
|
||||
_touchBeganPoint(Vector2::ZERO),
|
||||
_touchMovedPoint(Vector2::ZERO),
|
||||
_touchEndedPoint(Vector2::ZERO),
|
||||
_touchMovingPoint(Vector2::ZERO),
|
||||
_autoScrollDir(Vector2::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(Point::ZERO),
|
||||
_autoScrollDestination(Vector2::ZERO),
|
||||
_bePressed(false),
|
||||
_slidTime(0.0f),
|
||||
_moveChildPoint(Point::ZERO),
|
||||
_moveChildPoint(Vector2::ZERO),
|
||||
_childFocusCancelOffset(5.0f),
|
||||
_leftBounceNeeded(false),
|
||||
_topBounceNeeded(false),
|
||||
|
@ -105,7 +105,7 @@ _rightBounceNeeded(false),
|
|||
_bottomBounceNeeded(false),
|
||||
_bounceEnabled(false),
|
||||
_bouncing(false),
|
||||
_bounceDir(Point::ZERO),
|
||||
_bounceDir(Vector2::ZERO),
|
||||
_bounceOriginalSpeed(0.0f),
|
||||
_inertiaScrollEnabled(true),
|
||||
_scrollViewEventListener(nullptr),
|
||||
|
@ -173,7 +173,7 @@ void ScrollView::onSizeChanged()
|
|||
float innerSizeWidth = MAX(orginInnerSizeWidth, _size.width);
|
||||
float innerSizeHeight = MAX(orginInnerSizeHeight, _size.height);
|
||||
_innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight));
|
||||
_innerContainer->setPosition(Point(0, _size.height - _innerContainer->getSize().height));
|
||||
_innerContainer->setPosition(Vector2(0, _size.height - _innerContainer->getSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::setInnerContainerSize(const Size &size)
|
||||
|
@ -235,19 +235,19 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
}
|
||||
if (_innerContainer->getLeftInParent() > 0.0f)
|
||||
{
|
||||
_innerContainer->setPosition(Point(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
_innerContainer->setPosition(Vector2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
}
|
||||
if (_innerContainer->getRightInParent() < _size.width)
|
||||
{
|
||||
_innerContainer->setPosition(Point(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y));
|
||||
_innerContainer->setPosition(Vector2(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y));
|
||||
}
|
||||
if (_innerContainer->getPosition().y > 0.0f)
|
||||
{
|
||||
_innerContainer->setPosition(Point(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height));
|
||||
_innerContainer->setPosition(Vector2(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height));
|
||||
}
|
||||
if (_innerContainer->getTopInParent() < _size.height)
|
||||
{
|
||||
_innerContainer->setPosition(Point(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height));
|
||||
_innerContainer->setPosition(Vector2(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ Widget* ScrollView::getChildByName(const char *name)
|
|||
|
||||
void ScrollView::moveChildren(float offsetX, float offsetY)
|
||||
{
|
||||
_moveChildPoint = _innerContainer->getPosition() + Point(offsetX, offsetY);
|
||||
_moveChildPoint = _innerContainer->getPosition() + Vector2(offsetX, offsetY);
|
||||
_innerContainer->setPosition(_moveChildPoint);
|
||||
}
|
||||
|
||||
|
@ -390,56 +390,56 @@ bool ScrollView::checkNeedBounce()
|
|||
{
|
||||
if (_topBounceNeeded && _leftBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point(0.0f, _size.height) - Point(_innerContainer->getLeftInParent(), _innerContainer->getTopInParent());
|
||||
Vector2 scrollVector = Vector2(0.0f, _size.height) - Vector2(_innerContainer->getLeftInParent(), _innerContainer->getTopInParent());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_topBounceNeeded && _rightBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point(_size.width, _size.height) - Point(_innerContainer->getRightInParent(), _innerContainer->getTopInParent());
|
||||
Vector2 scrollVector = Vector2(_size.width, _size.height) - Vector2(_innerContainer->getRightInParent(), _innerContainer->getTopInParent());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_bottomBounceNeeded && _leftBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point::ZERO - Point(_innerContainer->getLeftInParent(), _innerContainer->getBottomInParent());
|
||||
Vector2 scrollVector = Vector2::ZERO - Vector2(_innerContainer->getLeftInParent(), _innerContainer->getBottomInParent());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_bottomBounceNeeded && _rightBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point(_size.width, 0.0f) - Point(_innerContainer->getRightInParent(), _innerContainer->getBottomInParent());
|
||||
Vector2 scrollVector = Vector2(_size.width, 0.0f) - Vector2(_innerContainer->getRightInParent(), _innerContainer->getBottomInParent());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_topBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point(0.0f, _size.height) - Point(0.0f, _innerContainer->getTopInParent());
|
||||
Vector2 scrollVector = Vector2(0.0f, _size.height) - Vector2(0.0f, _innerContainer->getTopInParent());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_bottomBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point::ZERO - Point(0.0f, _innerContainer->getBottomInParent());
|
||||
Vector2 scrollVector = Vector2::ZERO - Vector2(0.0f, _innerContainer->getBottomInParent());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_leftBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point::ZERO - Point(_innerContainer->getLeftInParent(), 0.0f);
|
||||
Vector2 scrollVector = Vector2::ZERO - Vector2(_innerContainer->getLeftInParent(), 0.0f);
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_rightBounceNeeded)
|
||||
{
|
||||
Point scrollVector = Point(_size.width, 0.0f) - Point(_innerContainer->getRightInParent(), 0.0f);
|
||||
Vector2 scrollVector = Vector2(_size.width, 0.0f) - Vector2(_innerContainer->getRightInParent(), 0.0f);
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.normalize();
|
||||
startBounceChildren(orSpeed);
|
||||
|
@ -509,7 +509,7 @@ void ScrollView::stopBounceChildren()
|
|||
_bottomBounceNeeded = false;
|
||||
}
|
||||
|
||||
void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Point& dir, float v, bool attenuated, float acceleration)
|
||||
void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Vector2& dir, float v, bool attenuated, float acceleration)
|
||||
{
|
||||
stopAutoScrollChildren();
|
||||
_autoScrollDir = dir;
|
||||
|
@ -519,12 +519,12 @@ void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Point& dir, floa
|
|||
_autoScrollAcceleration = acceleration;
|
||||
}
|
||||
|
||||
void ScrollView::startAutoScrollChildrenWithDestination(const Point& des, float time, bool attenuated)
|
||||
void ScrollView::startAutoScrollChildrenWithDestination(const Vector2& des, float time, bool attenuated)
|
||||
{
|
||||
_needCheckAutoScrollDestination = false;
|
||||
_autoScrollDestination = des;
|
||||
Point dis = des - _innerContainer->getPosition();
|
||||
Point dir = dis.normalize();
|
||||
Vector2 dis = des - _innerContainer->getPosition();
|
||||
Vector2 dir = dis.normalize();
|
||||
float orSpeed = 0.0f;
|
||||
float acceleration = -1000.0f;
|
||||
if (attenuated)
|
||||
|
@ -540,7 +540,7 @@ void ScrollView::startAutoScrollChildrenWithDestination(const Point& des, float
|
|||
startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration);
|
||||
}
|
||||
|
||||
void ScrollView::jumpToDestination(const Point &des)
|
||||
void ScrollView::jumpToDestination(const Vector2 &des)
|
||||
{
|
||||
float finalOffsetX = des.x;
|
||||
float finalOffsetY = des.y;
|
||||
|
@ -571,7 +571,7 @@ void ScrollView::jumpToDestination(const Point &des)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
_innerContainer->setPosition(Point(finalOffsetX, finalOffsetY));
|
||||
_innerContainer->setPosition(Vector2(finalOffsetX, finalOffsetY));
|
||||
}
|
||||
|
||||
void ScrollView::stopAutoScrollChildren()
|
||||
|
@ -1193,22 +1193,22 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
|
||||
void ScrollView::scrollToBottom(float time, bool attenuated)
|
||||
{
|
||||
startAutoScrollChildrenWithDestination(Point(_innerContainer->getPosition().x, 0.0f), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(_innerContainer->getPosition().x, 0.0f), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToTop(float time, bool attenuated)
|
||||
{
|
||||
startAutoScrollChildrenWithDestination(Point(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToLeft(float time, bool attenuated)
|
||||
{
|
||||
startAutoScrollChildrenWithDestination(Point(0.0f, _innerContainer->getPosition().y), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(0.0f, _innerContainer->getPosition().y), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToRight(float time, bool attenuated)
|
||||
{
|
||||
startAutoScrollChildrenWithDestination(Point(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToTopLeft(float time, bool attenuated)
|
||||
|
@ -1218,7 +1218,7 @@ void ScrollView::scrollToTopLeft(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Point(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToTopRight(float time, bool attenuated)
|
||||
|
@ -1228,7 +1228,7 @@ void ScrollView::scrollToTopRight(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Point(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToBottomLeft(float time, bool attenuated)
|
||||
|
@ -1238,7 +1238,7 @@ void ScrollView::scrollToBottomLeft(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Point::ZERO, time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2::ZERO, time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToBottomRight(float time, bool attenuated)
|
||||
|
@ -1248,23 +1248,23 @@ void ScrollView::scrollToBottomRight(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Point(_size.width - _innerContainer->getSize().width, 0.0f), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(_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(Point(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(_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(Point(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToPercentBothDirection(const Point& percent, float time, bool attenuated)
|
||||
void ScrollView::scrollToPercentBothDirection(const Vector2& percent, float time, bool attenuated)
|
||||
{
|
||||
if (_direction != SCROLLVIEW_DIR_BOTH)
|
||||
{
|
||||
|
@ -1273,27 +1273,27 @@ void ScrollView::scrollToPercentBothDirection(const Point& percent, float time,
|
|||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float h = - minY;
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
startAutoScrollChildrenWithDestination(Point(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vector2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::jumpToBottom()
|
||||
{
|
||||
jumpToDestination(Point(_innerContainer->getPosition().x, 0.0f));
|
||||
jumpToDestination(Vector2(_innerContainer->getPosition().x, 0.0f));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToTop()
|
||||
{
|
||||
jumpToDestination(Point(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height));
|
||||
jumpToDestination(Vector2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToLeft()
|
||||
{
|
||||
jumpToDestination(Point(0.0f, _innerContainer->getPosition().y));
|
||||
jumpToDestination(Vector2(0.0f, _innerContainer->getPosition().y));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToRight()
|
||||
{
|
||||
jumpToDestination(Point(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
jumpToDestination(Vector2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToTopLeft()
|
||||
|
@ -1303,7 +1303,7 @@ void ScrollView::jumpToTopLeft()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Point(0.0f, _size.height - _innerContainer->getSize().height));
|
||||
jumpToDestination(Vector2(0.0f, _size.height - _innerContainer->getSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToTopRight()
|
||||
|
@ -1313,7 +1313,7 @@ void ScrollView::jumpToTopRight()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Point(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height));
|
||||
jumpToDestination(Vector2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToBottomLeft()
|
||||
|
@ -1323,7 +1323,7 @@ void ScrollView::jumpToBottomLeft()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Point::ZERO);
|
||||
jumpToDestination(Vector2::ZERO);
|
||||
}
|
||||
|
||||
void ScrollView::jumpToBottomRight()
|
||||
|
@ -1333,23 +1333,23 @@ void ScrollView::jumpToBottomRight()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Point(_size.width - _innerContainer->getSize().width, 0.0f));
|
||||
jumpToDestination(Vector2(_size.width - _innerContainer->getSize().width, 0.0f));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToPercentVertical(float percent)
|
||||
{
|
||||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float h = - minY;
|
||||
jumpToDestination(Point(_innerContainer->getPosition().x, minY + percent * h / 100.0f));
|
||||
jumpToDestination(Vector2(_innerContainer->getPosition().x, minY + percent * h / 100.0f));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToPercentHorizontal(float percent)
|
||||
{
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
jumpToDestination(Point(-(percent * w / 100.0f), _innerContainer->getPosition().y));
|
||||
jumpToDestination(Vector2(-(percent * w / 100.0f), _innerContainer->getPosition().y));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToPercentBothDirection(const Point& percent)
|
||||
void ScrollView::jumpToPercentBothDirection(const Vector2& percent)
|
||||
{
|
||||
if (_direction != SCROLLVIEW_DIR_BOTH)
|
||||
{
|
||||
|
@ -1358,7 +1358,7 @@ void ScrollView::jumpToPercentBothDirection(const Point& percent)
|
|||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float h = - minY;
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
jumpToDestination(Point(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f));
|
||||
jumpToDestination(Vector2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f));
|
||||
}
|
||||
|
||||
void ScrollView::startRecordSlidAction()
|
||||
|
@ -1383,7 +1383,7 @@ void ScrollView::endRecordSlidAction()
|
|||
return;
|
||||
}
|
||||
float totalDis = 0.0f;
|
||||
Point dir;
|
||||
Vector2 dir;
|
||||
switch (_direction)
|
||||
{
|
||||
case SCROLLVIEW_DIR_VERTICAL:
|
||||
|
@ -1410,7 +1410,7 @@ void ScrollView::endRecordSlidAction()
|
|||
break;
|
||||
case SCROLLVIEW_DIR_BOTH:
|
||||
{
|
||||
Point subVector = _touchEndedPoint - _touchBeganPoint;
|
||||
Vector2 subVector = _touchEndedPoint - _touchBeganPoint;
|
||||
totalDis = subVector.getLength();
|
||||
dir = subVector.normalize();
|
||||
break;
|
||||
|
@ -1424,7 +1424,7 @@ void ScrollView::endRecordSlidAction()
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollView::handlePressLogic(const Point &touchPoint)
|
||||
void ScrollView::handlePressLogic(const Vector2 &touchPoint)
|
||||
{
|
||||
_touchBeganPoint = convertToNodeSpace(touchPoint);
|
||||
_touchMovingPoint = _touchBeganPoint;
|
||||
|
@ -1432,10 +1432,10 @@ void ScrollView::handlePressLogic(const Point &touchPoint)
|
|||
_bePressed = true;
|
||||
}
|
||||
|
||||
void ScrollView::handleMoveLogic(const Point &touchPoint)
|
||||
void ScrollView::handleMoveLogic(const Vector2 &touchPoint)
|
||||
{
|
||||
_touchMovedPoint = convertToNodeSpace(touchPoint);
|
||||
Point delta = _touchMovedPoint - _touchMovingPoint;
|
||||
Vector2 delta = _touchMovedPoint - _touchMovingPoint;
|
||||
_touchMovingPoint = _touchMovedPoint;
|
||||
switch (_direction)
|
||||
{
|
||||
|
@ -1459,7 +1459,7 @@ void ScrollView::handleMoveLogic(const Point &touchPoint)
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollView::handleReleaseLogic(const Point &touchPoint)
|
||||
void ScrollView::handleReleaseLogic(const Vector2 &touchPoint)
|
||||
{
|
||||
_touchEndedPoint = convertToNodeSpace(touchPoint);
|
||||
endRecordSlidAction();
|
||||
|
@ -1515,7 +1515,7 @@ void ScrollView::recordSlidTime(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint)
|
||||
void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Vector2 &touchPoint)
|
||||
{
|
||||
switch (handleState)
|
||||
{
|
||||
|
@ -1544,7 +1544,7 @@ void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Poin
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollView::checkChildInfo(int handleState,Widget* sender,const Point &touchPoint)
|
||||
void ScrollView::checkChildInfo(int handleState,Widget* sender,const Vector2 &touchPoint)
|
||||
{
|
||||
interceptTouchEvent(handleState, sender, touchPoint);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ void Slider::initRenderer()
|
|||
{
|
||||
_barRenderer = Sprite::create();
|
||||
_progressBarRenderer = Sprite::create();
|
||||
_progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f));
|
||||
_progressBarRenderer->setAnchorPoint(Vector2(0.0f, 0.5f));
|
||||
addProtectedChild(_barRenderer, BASEBAR_RENDERER_Z, -1);
|
||||
addProtectedChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1);
|
||||
_slidBallNormalRenderer = Sprite::create();
|
||||
|
@ -183,7 +183,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType
|
|||
break;
|
||||
}
|
||||
updateRGBAToRenderer(_progressBarRenderer);
|
||||
_progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f));
|
||||
_progressBarRenderer->setAnchorPoint(Vector2(0.0f, 0.5f));
|
||||
_progressBarTextureSize = _progressBarRenderer->getContentSize();
|
||||
progressBarRendererScaleChangedWithSize();
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ void Slider::setPercent(int percent)
|
|||
_percent = percent;
|
||||
float res = percent / 100.0f;
|
||||
float dis = _barLength * res;
|
||||
_slidBallRenderer->setPosition(Point(-_barLength/2.0f + dis, 0.0f));
|
||||
_slidBallRenderer->setPosition(Vector2(-_barLength/2.0f + dis, 0.0f));
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setPreferredSize(Size(dis,_progressBarTextureSize.height));
|
||||
|
@ -378,9 +378,9 @@ void Slider::setPercent(int percent)
|
|||
}
|
||||
}
|
||||
|
||||
bool Slider::hitTest(const cocos2d::Point &pt)
|
||||
bool Slider::hitTest(const cocos2d::Vector2 &pt)
|
||||
{
|
||||
Point nsp = this->_slidBallNormalRenderer->convertToNodeSpace(pt);
|
||||
Vector2 nsp = this->_slidBallNormalRenderer->convertToNodeSpace(pt);
|
||||
Rect ballRect = this->_slidBallNormalRenderer->getTextureRect();
|
||||
if (ballRect.containsPoint(nsp)) {
|
||||
return true;
|
||||
|
@ -393,7 +393,7 @@ bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent)
|
|||
bool pass = Widget::onTouchBegan(touch, unusedEvent);
|
||||
if (_hitted)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(_touchStartPos);
|
||||
Vector2 nsp = convertToNodeSpace(_touchStartPos);
|
||||
setPercent(getPercentWithBallPos(nsp.x));
|
||||
percentChangedEvent();
|
||||
}
|
||||
|
@ -403,8 +403,8 @@ bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent)
|
|||
void Slider::onTouchMoved(Touch *touch, Event *unusedEvent)
|
||||
{
|
||||
_touchMovePos = touch->getLocation();
|
||||
Point nsp = convertToNodeSpace(_touchMovePos);
|
||||
_slidBallRenderer->setPosition(Point(nsp.x,0));
|
||||
Vector2 nsp = convertToNodeSpace(_touchMovePos);
|
||||
_slidBallRenderer->setPosition(Vector2(nsp.x,0));
|
||||
setPercent(getPercentWithBallPos(nsp.x));
|
||||
percentChangedEvent();
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ void Slider::progressBarRendererScaleChangedWithSize()
|
|||
_progressBarRenderer->setScaleY(pscaleY);
|
||||
}
|
||||
}
|
||||
_progressBarRenderer->setPosition(Point(-_barLength * 0.5f, 0.0f));
|
||||
_progressBarRenderer->setPosition(Vector2(-_barLength * 0.5f, 0.0f));
|
||||
setPercent(_percent);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ const std::string& TextAtlas::getStringValue() const
|
|||
void TextAtlas::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_labelAtlasRenderer->setAnchorPoint(Point(pt.x, pt.y));
|
||||
_labelAtlasRenderer->setAnchorPoint(Vector2(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void TextAtlas::onSizeChanged()
|
||||
|
|
|
@ -435,11 +435,11 @@ void TextField::setTouchAreaEnabled(bool enable)
|
|||
_useTouchArea = enable;
|
||||
}
|
||||
|
||||
bool TextField::hitTest(const Point &pt)
|
||||
bool TextField::hitTest(const Vector2 &pt)
|
||||
{
|
||||
if (_useTouchArea)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(pt);
|
||||
Vector2 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)
|
||||
{
|
||||
|
|
|
@ -37,9 +37,9 @@ _touchEnabled(false),
|
|||
_touchPassedEnabled(false),
|
||||
_focus(false),
|
||||
_brightStyle(BRIGHT_NONE),
|
||||
_touchStartPos(Point::ZERO),
|
||||
_touchMovePos(Point::ZERO),
|
||||
_touchEndPos(Point::ZERO),
|
||||
_touchStartPos(Vector2::ZERO),
|
||||
_touchMovePos(Vector2::ZERO),
|
||||
_touchEndPos(Vector2::ZERO),
|
||||
_touchEventListener(nullptr),
|
||||
_touchEventSelector(nullptr),
|
||||
_name("default"),
|
||||
|
@ -50,9 +50,9 @@ _customSize(Size::ZERO),
|
|||
_ignoreSize(false),
|
||||
_affectByClipping(false),
|
||||
_sizeType(SIZE_ABSOLUTE),
|
||||
_sizePercent(Point::ZERO),
|
||||
_sizePercent(Vector2::ZERO),
|
||||
_positionType(POSITION_ABSOLUTE),
|
||||
_positionPercent(Point::ZERO),
|
||||
_positionPercent(Vector2::ZERO),
|
||||
_reorderWidgetChildDirty(true),
|
||||
_hitted(false),
|
||||
_touchListener(nullptr),
|
||||
|
@ -90,7 +90,7 @@ bool Widget::init()
|
|||
initRenderer();
|
||||
setBright(true);
|
||||
ignoreContentAdaptWithSize(true);
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -205,12 +205,12 @@ void Widget::setSize(const Size &size)
|
|||
{
|
||||
spy = _customSize.height / pSize.height;
|
||||
}
|
||||
_sizePercent = Point(spx, spy);
|
||||
_sizePercent = Vector2(spx, spy);
|
||||
}
|
||||
onSizeChanged();
|
||||
}
|
||||
|
||||
void Widget::setSizePercent(const Point &percent)
|
||||
void Widget::setSizePercent(const Vector2 &percent)
|
||||
{
|
||||
_sizePercent = percent;
|
||||
Size cSize = _customSize;
|
||||
|
@ -277,7 +277,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
{
|
||||
spy = _customSize.height / parentSize.height;
|
||||
}
|
||||
_sizePercent = Point(spx, spy);
|
||||
_sizePercent = Vector2(spx, spy);
|
||||
break;
|
||||
}
|
||||
case SIZE_PERCENT:
|
||||
|
@ -298,24 +298,24 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
break;
|
||||
}
|
||||
onSizeChanged();
|
||||
Point absPos = getPosition();
|
||||
Vector2 absPos = getPosition();
|
||||
switch (_positionType)
|
||||
{
|
||||
case POSITION_ABSOLUTE:
|
||||
{
|
||||
if (parentSize.width <= 0.0f || parentSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = Point::ZERO;
|
||||
_positionPercent = Vector2::ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = Point(absPos.x / parentSize.width, absPos.y / parentSize.height);
|
||||
_positionPercent = Vector2(absPos.x / parentSize.width, absPos.y / parentSize.height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case POSITION_PERCENT:
|
||||
{
|
||||
absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
absPos = Vector2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -368,14 +368,14 @@ const Size& Widget::getCustomSize() const
|
|||
return _customSize;
|
||||
}
|
||||
|
||||
const Point& Widget::getSizePercent() const
|
||||
const Vector2& Widget::getSizePercent() const
|
||||
{
|
||||
return _sizePercent;
|
||||
}
|
||||
|
||||
Point Widget::getWorldPosition()
|
||||
Vector2 Widget::getWorldPosition()
|
||||
{
|
||||
return convertToWorldSpace(Point::ZERO);
|
||||
return convertToWorldSpace(Vector2::ZERO);
|
||||
}
|
||||
|
||||
Node* Widget::getVirtualRenderer()
|
||||
|
@ -614,9 +614,9 @@ void Widget::addTouchEventListener(Ref *target, SEL_TouchEvent selector)
|
|||
_touchEventSelector = selector;
|
||||
}
|
||||
|
||||
bool Widget::hitTest(const Point &pt)
|
||||
bool Widget::hitTest(const Vector2 &pt)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(pt);
|
||||
Vector2 nsp = convertToNodeSpace(pt);
|
||||
Rect bb = Rect(-_size.width * _anchorPoint.x, -_size.height * _anchorPoint.y, _size.width, _size.height);
|
||||
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)
|
||||
{
|
||||
|
@ -625,7 +625,7 @@ bool Widget::hitTest(const Point &pt)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Widget::clippingParentAreaContainPoint(const Point &pt)
|
||||
bool Widget::clippingParentAreaContainPoint(const Vector2 &pt)
|
||||
{
|
||||
_affectByClipping = false;
|
||||
Widget* parent = getWidgetParent();
|
||||
|
@ -667,7 +667,7 @@ bool Widget::clippingParentAreaContainPoint(const Point &pt)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Widget::checkChildInfo(int handleState, Widget *sender, const Point &touchPoint)
|
||||
void Widget::checkChildInfo(int handleState, Widget *sender, const Vector2 &touchPoint)
|
||||
{
|
||||
Widget* widgetParent = getWidgetParent();
|
||||
if (widgetParent)
|
||||
|
@ -686,18 +686,18 @@ void Widget::setPosition(const Vector2 &pos)
|
|||
Size pSize = widgetParent->getSize();
|
||||
if (pSize.width <= 0.0f || pSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = Point::ZERO;
|
||||
_positionPercent = Vector2::ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = Point(pos.x / pSize.width, pos.y / pSize.height);
|
||||
_positionPercent = Vector2(pos.x / pSize.width, pos.y / pSize.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
ProtectedNode::setPosition(pos);
|
||||
}
|
||||
|
||||
void Widget::setPositionPercent(const Point &percent)
|
||||
void Widget::setPositionPercent(const Vector2 &percent)
|
||||
{
|
||||
_positionPercent = percent;
|
||||
if (_running)
|
||||
|
@ -706,7 +706,7 @@ void Widget::setPositionPercent(const Point &percent)
|
|||
if (widgetParent)
|
||||
{
|
||||
Size parentSize = widgetParent->getSize();
|
||||
Point absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
Vector2 absPos = Vector2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
setPosition(absPos);
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ void Widget::updateAnchorPoint()
|
|||
setAnchorPoint(getAnchorPoint());
|
||||
}
|
||||
|
||||
const Point& Widget::getPositionPercent()
|
||||
const Vector2& Widget::getPositionPercent()
|
||||
{
|
||||
return _positionPercent;
|
||||
}
|
||||
|
@ -762,17 +762,17 @@ float Widget::getTopInParent()
|
|||
return getBottomInParent() + _size.height;
|
||||
}
|
||||
|
||||
const Point& Widget::getTouchStartPos()
|
||||
const Vector2& Widget::getTouchStartPos()
|
||||
{
|
||||
return _touchStartPos;
|
||||
}
|
||||
|
||||
const Point& Widget::getTouchMovePos()
|
||||
const Vector2& Widget::getTouchMovePos()
|
||||
{
|
||||
return _touchMovePos;
|
||||
}
|
||||
|
||||
const Point& Widget::getTouchEndPos()
|
||||
const Vector2& Widget::getTouchEndPos()
|
||||
{
|
||||
return _touchEndPos;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue