Vector更名为Vector2
This commit is contained in:
parent
372bc09773
commit
95e77d6f0d
|
|
@ -1,7 +1,7 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
#include "..\e2dnode.h"
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::JumpBy::JumpBy(double duration, const Vector & vec, double height, int jumps)
|
e2d::JumpBy::JumpBy(double duration, const Vector2 & vec, double height, int jumps)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
, _deltaPos(vec)
|
, _deltaPos(vec)
|
||||||
, _height(height)
|
, _height(height)
|
||||||
|
|
@ -42,10 +42,10 @@ void e2d::JumpBy::_update()
|
||||||
|
|
||||||
Point currentPos = _target->getPos();
|
Point currentPos = _target->getPos();
|
||||||
|
|
||||||
Vector diff = currentPos - _prevPos;
|
Vector2 diff = currentPos - _prevPos;
|
||||||
_startPos = diff + _startPos;
|
_startPos = diff + _startPos;
|
||||||
|
|
||||||
Point newPos = _startPos + Vector(x, y);
|
Point newPos = _startPos + Vector2(x, y);
|
||||||
_target->setPos(newPos);
|
_target->setPos(newPos);
|
||||||
|
|
||||||
_prevPos = newPos;
|
_prevPos = newPos;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include "..\e2dnode.h"
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::MoveBy::MoveBy(double duration, Vector vector)
|
e2d::MoveBy::MoveBy(double duration, Vector2 vector)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
{
|
{
|
||||||
_deltaPos = vector;
|
_deltaPos = vector;
|
||||||
|
|
@ -25,7 +25,7 @@ void e2d::MoveBy::_update()
|
||||||
if (_target)
|
if (_target)
|
||||||
{
|
{
|
||||||
Point currentPos = _target->getPos();
|
Point currentPos = _target->getPos();
|
||||||
Vector diff = currentPos - _prevPos;
|
Vector2 diff = currentPos - _prevPos;
|
||||||
_startPos = _startPos + diff;
|
_startPos = _startPos + diff;
|
||||||
|
|
||||||
Point newPos = _startPos + (_deltaPos * _delta);
|
Point newPos = _startPos + (_deltaPos * _delta);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include "..\e2dnode.h"
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::MoveTo::MoveTo(double duration, Point pos)
|
e2d::MoveTo::MoveTo(double duration, Point pos)
|
||||||
: MoveBy(duration, Vector())
|
: MoveBy(duration, Vector2())
|
||||||
{
|
{
|
||||||
_endPos = pos;
|
_endPos = pos;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,7 @@ void e2d::Node::movePos(double x, double y)
|
||||||
this->setPos(_posX + x, _posY + y);
|
this->setPos(_posX + x, _posY + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::movePos(const Vector & v)
|
void e2d::Node::movePos(const Vector2 & v)
|
||||||
{
|
{
|
||||||
this->movePos(v.x, v.y);
|
this->movePos(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,22 @@ void e2d::MoveTransition::_init(Scene * prev, Scene * next)
|
||||||
double height = _windowSize.height;
|
double height = _windowSize.height;
|
||||||
if (_direction == Direction::Up)
|
if (_direction == Direction::Up)
|
||||||
{
|
{
|
||||||
_posDelta = Vector(0, -height);
|
_posDelta = Vector2(0, -height);
|
||||||
_startPos = Point(0, height);
|
_startPos = Point(0, height);
|
||||||
}
|
}
|
||||||
else if (_direction == Direction::Down)
|
else if (_direction == Direction::Down)
|
||||||
{
|
{
|
||||||
_posDelta = Vector(0, height);
|
_posDelta = Vector2(0, height);
|
||||||
_startPos = Point(0, -height);
|
_startPos = Point(0, -height);
|
||||||
}
|
}
|
||||||
else if (_direction == Direction::Left)
|
else if (_direction == Direction::Left)
|
||||||
{
|
{
|
||||||
_posDelta = Vector(-width, 0);
|
_posDelta = Vector2(-width, 0);
|
||||||
_startPos = Point(width, 0);
|
_startPos = Point(width, 0);
|
||||||
}
|
}
|
||||||
else if (_direction == Direction::Right)
|
else if (_direction == Direction::Right)
|
||||||
{
|
{
|
||||||
_posDelta = Vector(width, 0);
|
_posDelta = Vector2(width, 0);
|
||||||
_startPos = Point(-width, 0);
|
_startPos = Point(-width, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ class MoveBy :
|
||||||
public:
|
public:
|
||||||
explicit MoveBy(
|
explicit MoveBy(
|
||||||
double duration, /* 持续时长 */
|
double duration, /* 持续时长 */
|
||||||
Vector vector /* 移动距离 */
|
Vector2 vector /* 移动距离 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -145,7 +145,7 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
Point _startPos;
|
Point _startPos;
|
||||||
Point _prevPos;
|
Point _prevPos;
|
||||||
Vector _deltaPos;
|
Vector2 _deltaPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -185,7 +185,7 @@ class JumpBy :
|
||||||
public:
|
public:
|
||||||
explicit JumpBy(
|
explicit JumpBy(
|
||||||
double duration, /* 持续时长 */
|
double duration, /* 持续时长 */
|
||||||
const Vector& vec, /* 跳跃距离 */
|
const Vector2& vec, /* 跳跃距离 */
|
||||||
double height, /* 跳跃高度 */
|
double height, /* 跳跃高度 */
|
||||||
int jumps = 1 /* 跳跃次数 */
|
int jumps = 1 /* 跳跃次数 */
|
||||||
);
|
);
|
||||||
|
|
@ -205,7 +205,7 @@ protected:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Point _startPos;
|
Point _startPos;
|
||||||
Vector _deltaPos;
|
Vector2 _deltaPos;
|
||||||
double _height;
|
double _height;
|
||||||
int _jumps;
|
int _jumps;
|
||||||
Point _prevPos;
|
Point _prevPos;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// 二维向量
|
// 二维向量
|
||||||
typedef Point Vector;
|
typedef Point Vector2;
|
||||||
|
|
||||||
|
|
||||||
// 大小
|
// 大小
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ public:
|
||||||
|
|
||||||
// 移动节点
|
// 移动节点
|
||||||
virtual void movePos(
|
virtual void movePos(
|
||||||
const Vector & v
|
const Vector2 & v
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置节点绘图顺序
|
// 设置节点绘图顺序
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ protected:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Direction _direction;
|
Direction _direction;
|
||||||
Vector _posDelta;
|
Vector2 _posDelta;
|
||||||
Point _startPos;
|
Point _startPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue