initialize method
Implementation
void initialize(Vector2 screenSize, JoystickController joystickController) {
_joystickController = joystickController;
double radius = size / 2;
double dx = 0, dy = 0;
switch (align) {
case JoystickActionAlign.TOP_LEFT:
dx = margin.left + radius;
dy = margin.top + radius;
break;
case JoystickActionAlign.BOTTOM_LEFT:
dx = margin.left + radius;
dy = screenSize.y - (margin.bottom + radius);
break;
case JoystickActionAlign.TOP_RIGHT:
dx = screenSize.x - (margin.right + radius);
dy = margin.top + radius;
break;
case JoystickActionAlign.BOTTOM_RIGHT:
dx = screenSize.x - (margin.right + radius);
dy = screenSize.y - (margin.bottom + radius);
break;
}
_rect = Rect.fromCircle(
center: Offset(dx, dy),
radius: radius,
);
_rectBackgroundDirection = Rect.fromCircle(
center: Offset(dx, dy),
radius: _sizeBackgroundDirection / 2,
);
_dragPosition = _rect!.center;
}