handlerPointerMove method

  1. @override
void handlerPointerMove(
  1. PointerMoveEvent event
)
override

Implementation

@override
void handlerPointerMove(PointerMoveEvent event) {
  final pointer = event.pointer;
  final position = event.localPosition.toVector2();
  bool canMove = hasGameRef &&
      _startDragPosition != null &&
      enableDrag &&
      pointer == _pointer;

  if (canMove) {
    if (this.isHud) {
      this.position = Vector2(
        _startDragPosition!.x + (position.x - _startDragOffset!.x),
        _startDragPosition!.y + (position.y - _startDragOffset!.y),
      );
    } else {
      final absolutePosition = this.gameRef.screenToWorld(position);
      this.position = Vector2(
        _startDragPosition!.x + (absolutePosition.x - _startDragOffset!.x),
        _startDragPosition!.y + (absolutePosition.y - _startDragOffset!.y),
      );
    }
    inMoving = true;
    onMoveDrag(pointer, position);
  }
  super.handlerPointerMove(event);
}