Skip to content

Commit c4cead0

Browse files
committed
Updates
1 parent 715eab3 commit c4cead0

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

bricks/example/__brick__/lib/main.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,20 @@ class MyWorld extends World {
2929
class MyComponent extends RectangleComponent with TapCallbacks {
3030
final Vector2 speed = Vector2.zero();
3131

32-
@override
33-
final Paint paint = BasicPalette.magenta.paint();
34-
3532
MyComponent()
3633
: super.square(
37-
size: 32,
34+
size: 64,
3835
anchor: Anchor.center,
36+
paint: BasicPalette.magenta.paint(),
3937
);
4038

4139
@override
4240
void update(double dt) {
43-
position += speed * 32.0 * dt;
41+
position += speed * 128.0 * dt;
4442
}
4543

4644
@override
47-
void onTapUp(TapUpEvent event) {
45+
void onTapDown(TapDownEvent event) {
4846
speed.x = -1 + 2 * _rng.nextDouble();
4947
speed.y = -1 + 2 * _rng.nextDouble();
5048
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'package:flame/events.dart';
2+
import 'package:flame/game.dart';
3+
import 'package:flame_test/flame_test.dart';
4+
import 'package:flutter_test/flutter_test.dart';
5+
6+
import 'package:{{name}}/main.dart';
7+
8+
void main() {
9+
testWithGame<MyGame>(
10+
'game will load and MyComponent responds to taps',
11+
MyGame.new,
12+
(game) async {
13+
await game.ready();
14+
15+
expect(game.world.children.length, 1);
16+
expect(game.world.myComponent.speed, Vector2.zero());
17+
18+
final dispatcher = game.firstChild<MultiTapDispatcher>()!;
19+
dispatcher.onTapDown(
20+
createTapDownEvents(
21+
game: game,
22+
localPosition: (game.size / 2).toOffset(),
23+
globalPosition: (game.size / 2).toOffset(),
24+
),
25+
);
26+
27+
expect(game.world.myComponent.speed, isNot(equals(Vector2.zero())));
28+
},
29+
);
30+
}

bricks/example/__brick__/test/widget_test.dart

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/templates/bricks/example_bundle.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)