Add flame_lint to examples (#1090)

This commit is contained in:
Lukas Klingsbo
2021-11-12 10:35:56 +01:00
committed by GitHub
parent 3a60f25401
commit d53ac50859
7 changed files with 91 additions and 218 deletions

View File

@ -212,12 +212,14 @@ class CollidableSnowman extends MyCollidable {
addHitbox(top);
addHitbox(middle);
addHitbox(bottom);
add(randomCollidable(
Vector2(size.x / 2, size.y * 0.75),
size / 4,
Vector2.zero(),
screenCollidable,
));
add(
randomCollidable(
Vector2(size.x / 2, size.y * 0.75),
size / 4,
Vector2.zero(),
screenCollidable,
),
);
}
}

View File

@ -5,6 +5,7 @@ import 'package:flame/game.dart';
import 'package:flame/src/effects2/move_effect.dart'; // ignore: implementation_imports
import 'package:flame/src/effects2/standard_effect_controller.dart'; // ignore: implementation_imports
import 'package:flutter/material.dart';
import '../../commons/square_component.dart';
class MoveEffectExample extends FlameGame {
@ -36,37 +37,43 @@ class MoveEffectExample extends FlameGame {
add(
SquareComponent(position: Vector2(20, 50), size: 20, paint: paint1)
..add(MoveEffect.to(
Vector2(380, 50),
StandardEffectController(
duration: 3,
reverseDuration: 3,
infinite: true,
curve: Curves.easeOut,
..add(
MoveEffect.to(
Vector2(380, 50),
StandardEffectController(
duration: 3,
reverseDuration: 3,
infinite: true,
curve: Curves.easeOut,
),
),
)),
),
);
add(
SquareComponent(position: Vector2(20, 150), size: 20, paint: paint2)
..add(MoveEffect.to(
Vector2(380, 150),
StandardEffectController(
duration: 3,
reverseDuration: 3,
infinite: true,
..add(
MoveEffect.to(
Vector2(380, 150),
StandardEffectController(
duration: 3,
reverseDuration: 3,
infinite: true,
),
),
))
..add(MoveEffect.by(
Vector2(0, -50),
StandardEffectController(
duration: 0.25,
reverseDuration: 0.25,
startDelay: 1,
atMinDuration: 2,
curve: Curves.ease,
infinite: true,
)
..add(
MoveEffect.by(
Vector2(0, -50),
StandardEffectController(
duration: 0.25,
reverseDuration: 0.25,
startDelay: 1,
atMinDuration: 2,
curve: Curves.ease,
infinite: true,
),
),
)),
),
);
final path1 = Path()..moveTo(200, 250);
@ -80,12 +87,13 @@ class MoveEffectExample extends FlameGame {
CircleComponent(5)
..add(
MoveEffect.along(
path1,
StandardEffectController(
duration: 10,
startDelay: i * 0.2,
infinite: true,
)),
path1,
StandardEffectController(
duration: 10,
startDelay: i * 0.2,
infinite: true,
),
),
),
);
}
@ -95,14 +103,16 @@ class MoveEffectExample extends FlameGame {
add(
SquareComponent(size: 10)
..paint = (Paint()..color = const Color(0xFF00FFF7))
..add(MoveEffect.along(
path2,
StandardEffectController(
duration: 6,
startDelay: i * 0.3,
infinite: true,
..add(
MoveEffect.along(
path2,
StandardEffectController(
duration: 6,
startDelay: i * 0.3,
infinite: true,
),
),
)),
),
);
}
}

View File

@ -35,26 +35,35 @@ class RotateEffectExample extends FlameGame {
),
);
compass.arrow
..add(RotateEffect.to(
..add(
RotateEffect.to(
Transform2D.tau,
StandardEffectController(
duration: 20,
infinite: true,
)))
..add(RotateEffect.by(
),
),
)
..add(
RotateEffect.by(
Transform2D.tau * 0.015,
StandardEffectController(
duration: 0.1,
reverseDuration: 0.1,
infinite: true,
)))
..add(RotateEffect.by(
),
),
)
..add(
RotateEffect.by(
Transform2D.tau * 0.021,
StandardEffectController(
duration: 0.13,
reverseDuration: 0.13,
infinite: true,
)));
),
),
);
}
}

View File

@ -428,21 +428,23 @@ class ParticlesGame extends FlameGame with FPSCounter {
return AcceleratedParticle(
speed: initialSpeed,
acceleration: deceleration + gravity,
child: ComputedParticle(renderer: (canvas, particle) {
final paint = randomElement(paints);
// Override the color to dynamically update opacity
paint.color = paint.color.withOpacity(1 - particle.progress);
child: ComputedParticle(
renderer: (canvas, particle) {
final paint = randomElement(paints);
// Override the color to dynamically update opacity
paint.color = paint.color.withOpacity(1 - particle.progress);
canvas.drawCircle(
Offset.zero,
// Closer to the end of lifespan particles
// will turn into larger glaring circles
rnd.nextDouble() * particle.progress > .6
? rnd.nextDouble() * (50 * particle.progress)
: 2 + (3 * particle.progress),
paint,
);
}),
canvas.drawCircle(
Offset.zero,
// Closer to the end of lifespan particles
// will turn into larger glaring circles
rnd.nextDouble() * particle.progress > .6
? rnd.nextDouble() * (50 * particle.progress)
: 2 + (3 * particle.progress),
paint,
);
},
),
);
},
);