moveFromAngle method
Move Player to direction by radAngle
Implementation
bool moveFromAngle(double speed, double angle) {
final rect = toRect();
final center = rect.center.toVector2();
Vector2 diffBase = BonfireUtil.diffMovePointByAngle(
center,
speed * dtUpdate,
angle,
);
Offset newDiffBase = diffBase.toOffset();
Rect newPosition = rect.shift(newDiffBase);
_updateDirectionBuAngle(angle);
if (_isCollision(newPosition.positionVector2)) {
onMove(0, lastDirection, angle);
return false;
}
isIdle = false;
position = newPosition.positionVector2;
onMove(speed, lastDirection, angle);
return true;
}