修复MoveBy动作的问题

This commit is contained in:
Nomango 2018-05-29 22:12:01 +08:00
parent 08d804475d
commit 7a28ddace2
2 changed files with 10 additions and 2 deletions

View File

@ -14,7 +14,7 @@ void e2d::MoveBy::_init()
if (_target) if (_target)
{ {
_startPos = _target->getPos(); _prevPos = _startPos = _target->getPos();
} }
} }
@ -24,7 +24,14 @@ void e2d::MoveBy::_update()
if (_target) if (_target)
{ {
_target->setPos(_startPos + _deltaPos * _delta); Point currentPos = _target->getPos();
Vector diff = currentPos - _prevPos;
_startPos = _startPos + diff;
Point newPos = _startPos + (_deltaPos * _delta);
_target->setPos(newPos);
_prevPos = newPos;
} }
} }

View File

@ -144,6 +144,7 @@ protected:
protected: protected:
Point _startPos; Point _startPos;
Point _prevPos;
Vector _deltaPos; Vector _deltaPos;
}; };