mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-15 20:29:46 +08:00
New linter rules (#676)
This commit is contained in:
@@ -21,8 +21,10 @@ class Palette {
|
||||
static const PaletteEntry blue = PaletteEntry(Color(0xFF0000FF));
|
||||
}
|
||||
|
||||
class Square extends PositionComponent with HasGameRef<MyGame> {
|
||||
static const SPEED = 0.25;
|
||||
class Square extends PositionComponent {
|
||||
static const speed = 0.25;
|
||||
static const squareSize = 128.0;
|
||||
|
||||
static Paint white = Palette.white.paint;
|
||||
static Paint red = Palette.red.paint;
|
||||
static Paint blue = Palette.blue.paint;
|
||||
@@ -36,23 +38,21 @@ class Square extends PositionComponent with HasGameRef<MyGame> {
|
||||
c.drawRect(Rect.fromLTWH(width / 2, height / 2, 3, 3), blue);
|
||||
}
|
||||
|
||||
@override
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
angle += SPEED * dt;
|
||||
angle += speed * t;
|
||||
angle %= 2 * math.pi;
|
||||
}
|
||||
|
||||
@override
|
||||
void onMount() {
|
||||
super.onMount();
|
||||
size = Vector2.all(gameRef.squareSize);
|
||||
size = Vector2.all(squareSize);
|
||||
anchor = Anchor.center;
|
||||
}
|
||||
}
|
||||
|
||||
class MyGame extends BaseGame with DoubleTapDetector, TapDetector {
|
||||
final double squareSize = 128;
|
||||
bool running = true;
|
||||
|
||||
MyGame() {
|
||||
@@ -62,19 +62,19 @@ class MyGame extends BaseGame with DoubleTapDetector, TapDetector {
|
||||
}
|
||||
|
||||
@override
|
||||
void onTapUp(details) {
|
||||
void onTapUp(TapUpDetails details) {
|
||||
final touchArea = Rect.fromCenter(
|
||||
center: details.localPosition,
|
||||
width: 20,
|
||||
height: 20,
|
||||
);
|
||||
|
||||
bool handled = false;
|
||||
components.forEach((c) {
|
||||
final handled = components.any((c) {
|
||||
if (c is PositionComponent && c.toRect().overlaps(touchArea)) {
|
||||
handled = true;
|
||||
remove(c);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!handled) {
|
||||
|
||||
Reference in New Issue
Block a user