handlerPointerDown method

  1. @override
void handlerPointerDown(
  1. PointerDownEvent event
)
override

Implementation

@override
void handlerPointerDown(PointerDownEvent event) {
  final pointer = event.pointer;
  final position = event.localPosition.toVector2();

  if (enableDrag && hasGameRef) {
    if (this.isHud) {
      if (containsPoint(position)) {
        _pointer = pointer;
        _startDragOffset = position;
        _startDragPosition = this.position.clone();
        onStartDrag(pointer, position);
      }
    } else {
      final absolutePosition = this.gameRef.screenToWorld(position);
      if (containsPoint(absolutePosition)) {
        _pointer = pointer;
        _startDragOffset = absolutePosition;
        _startDragPosition = this.position.clone();
      }
    }
  }

  super.handlerPointerDown(event);
}