moveFromDirection method
Implementation
bool moveFromDirection(
Direction direction, {
Vector2? speedVector,
bool enabledDiagonal = true,
}) {
double speedX = speedVector?.x ?? speed;
double speedY = speedVector?.y ?? speed;
switch (direction) {
case Direction.left:
return moveLeft(speedX);
case Direction.right:
return moveRight(speedX);
case Direction.up:
return moveUp(speedY);
case Direction.down:
return moveDown(speedY);
case Direction.upLeft:
if (enabledDiagonal) {
return moveUpLeft(speedX, speedY);
} else {
return moveRight(speed);
}
case Direction.upRight:
if (enabledDiagonal) {
return moveUpRight(speedX, speedY);
} else {
return moveRight(speed);
}
case Direction.downLeft:
if (enabledDiagonal) {
return moveDownLeft(speedX, speedY);
} else {
return moveLeft(speed);
}
case Direction.downRight:
if (enabledDiagonal) {
return moveDownRight(speedX, speedY);
} else {
return moveRight(speed);
}
}
}