修复MoveBy动作的问题
This commit is contained in:
parent
08d804475d
commit
7a28ddace2
|
|
@ -14,7 +14,7 @@ void e2d::MoveBy::_init()
|
|||
|
||||
if (_target)
|
||||
{
|
||||
_startPos = _target->getPos();
|
||||
_prevPos = _startPos = _target->getPos();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,14 @@ void e2d::MoveBy::_update()
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ protected:
|
|||
|
||||
protected:
|
||||
Point _startPos;
|
||||
Point _prevPos;
|
||||
Vector _deltaPos;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue