initialize method

void initialize(
  1. PlayerControllerListener controller,
  2. Viewport viewport
)

Implementation

void initialize(
  PlayerControllerListener controller,
  camera.Viewport viewport,
) {
  if (_screenSize == viewport.virtualSize) return;
  _viewport = viewport;
  _screenSize = viewport.virtualSize.clone();
  _controller = controller;
  double radius = size / 2;
  final screenRect = Rect.fromLTRB(
    margin.left + radius,
    margin.top + radius,
    _screenSize.x - margin.right - radius,
    _screenSize.y - margin.bottom - radius,
  );

  Offset osBackground = alignment.withinRect(screenRect);
  _rect = Rect.fromCircle(
    center: osBackground,
    radius: radius,
  );

  _rectBackgroundDirection = Rect.fromCircle(
    center: osBackground,
    radius: _sizeBackgroundDirection / 2,
  );

  _dragPosition = _rect!.center;
}