Fixing gestures conflicts and adding a gestures example

This commit is contained in:
Erick Zanardo
2019-10-31 20:05:23 -03:00
committed by Erick (CptBlackPixel)
parent 655a70b0a6
commit 6f44e0514b
6 changed files with 221 additions and 35 deletions

View File

@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:flame/game.dart';
void main() {
final game = MyGame();
runApp(game.widget);
}
class MyGame extends Game {
final _whitePaint = Paint()..color = const Color(0xFFFFFFFF);
final _bluePaint = Paint()..color = const Color(0xFF0000FF);
final _greenPaint = Paint()..color = const Color(0xFF00FF00);
Paint _paint;
Rect _rect = const Rect.fromLTWH(50, 50, 50, 50);
MyGame() {
_paint = _whitePaint;
}
@override
void onTap() {
_paint = _paint == _whitePaint ? _bluePaint : _whitePaint;
}
@override
bool useDoubleTapDetectors() => true;
@override
void onDoubleTap() {
_paint = _greenPaint;
}
@override
bool usePanDetectors() => true;
@override
void onPanUpdate(DragUpdateDetails details) {
_rect = _rect.translate(details.delta.dx, details.delta.dy);
}
@override
void update(double dt) {}
@override
void render(Canvas canvas) {
canvas.drawRect(_rect, _paint);
}
}