mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
Move files to src and comply with the dart package layout convention (#621)
* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631) * Move files to src and comply with the dart package layout convention * Fixing widgets example Co-authored-by: Serge Matveenko <lig@countzero.co> Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
This commit is contained in:
@ -1,111 +1 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
import 'game/game.dart';
|
||||
|
||||
mixin MultiTouchTapDetector on Game {
|
||||
void onTap(int pointerId) {}
|
||||
void onTapCancel(int pointerId) {}
|
||||
void onTapDown(int pointerId, TapDownDetails details) {}
|
||||
void onTapUp(int pointerId, TapUpDetails details) {}
|
||||
void onLongTapDown(int pointerId, TapDownDetails details) {}
|
||||
}
|
||||
|
||||
class DragEvent extends Drag {
|
||||
final Offset initialPosition;
|
||||
|
||||
DragEvent(this.initialPosition);
|
||||
|
||||
void Function(DragUpdateDetails) onUpdate;
|
||||
void Function() onCancel;
|
||||
void Function(DragEndDetails) onEnd;
|
||||
|
||||
@override
|
||||
void update(details) {
|
||||
onUpdate?.call(details);
|
||||
}
|
||||
|
||||
@override
|
||||
void cancel() {
|
||||
onCancel?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
void end(details) {
|
||||
onEnd?.call(details);
|
||||
}
|
||||
}
|
||||
|
||||
mixin MultiTouchDragDetector on Game {
|
||||
void onReceiveDrag(DragEvent drag) {}
|
||||
}
|
||||
|
||||
// Basic touch detectors
|
||||
mixin TapDetector on Game {
|
||||
void onTap() {}
|
||||
void onTapCancel() {}
|
||||
void onTapDown(TapDownDetails details) {}
|
||||
void onTapUp(TapUpDetails details) {}
|
||||
}
|
||||
|
||||
mixin SecondaryTapDetector on Game {
|
||||
void onSecondaryTapDown(TapDownDetails details) {}
|
||||
void onSecondaryTapUp(TapUpDetails details) {}
|
||||
void onSecondaryTapCancel() {}
|
||||
}
|
||||
|
||||
mixin DoubleTapDetector on Game {
|
||||
void onDoubleTap() {}
|
||||
}
|
||||
|
||||
mixin LongPressDetector on Game {
|
||||
void onLongPress() {}
|
||||
void onLongPressStart(LongPressStartDetails details) {}
|
||||
void onLongPressMoveUpdate(LongPressMoveUpdateDetails details) {}
|
||||
void onLongPressUp() {}
|
||||
void onLongPressEnd(LongPressEndDetails details) {}
|
||||
}
|
||||
|
||||
mixin VerticalDragDetector on Game {
|
||||
void onVerticalDragDown(DragDownDetails details) {}
|
||||
void onVerticalDragStart(DragStartDetails details) {}
|
||||
void onVerticalDragUpdate(DragUpdateDetails details) {}
|
||||
void onVerticalDragEnd(DragEndDetails details) {}
|
||||
void onVerticalDragCancel() {}
|
||||
}
|
||||
|
||||
mixin HorizontalDragDetector on Game {
|
||||
void onHorizontalDragDown(DragDownDetails details) {}
|
||||
void onHorizontalDragStart(DragStartDetails details) {}
|
||||
void onHorizontalDragUpdate(DragUpdateDetails details) {}
|
||||
void onHorizontalDragEnd(DragEndDetails details) {}
|
||||
void onHorizontalDragCancel() {}
|
||||
}
|
||||
|
||||
mixin ForcePressDetector on Game {
|
||||
void onForcePressStart(ForcePressDetails details) {}
|
||||
void onForcePressPeak(ForcePressDetails details) {}
|
||||
void onForcePressUpdate(ForcePressDetails details) {}
|
||||
void onForcePressEnd(ForcePressDetails details) {}
|
||||
}
|
||||
|
||||
mixin PanDetector on Game {
|
||||
void onPanDown(DragDownDetails details) {}
|
||||
void onPanStart(DragStartDetails details) {}
|
||||
void onPanUpdate(DragUpdateDetails details) {}
|
||||
void onPanEnd(DragEndDetails details) {}
|
||||
void onPanCancel() {}
|
||||
}
|
||||
|
||||
mixin ScaleDetector on Game {
|
||||
void onScaleStart(ScaleStartDetails details) {}
|
||||
void onScaleUpdate(ScaleUpdateDetails details) {}
|
||||
void onScaleEnd(ScaleEndDetails details) {}
|
||||
}
|
||||
|
||||
mixin MouseMovementDetector on Game {
|
||||
void onMouseMove(PointerHoverEvent event) {}
|
||||
}
|
||||
|
||||
mixin ScrollDetector on Game {
|
||||
void onScroll(PointerScrollEvent event) {}
|
||||
}
|
||||
export 'src/gestures.dart';
|
||||
|
||||
Reference in New Issue
Block a user