Files
flame/test/components/has_game_ref_test.dart
Renan ccee9a466b 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>
2021-01-20 09:05:43 -03:00

29 lines
563 B
Dart

import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:test/test.dart';
class MyGame extends BaseGame {
bool calledFoo = false;
void foo() {
calledFoo = true;
}
}
class MyComponent extends PositionComponent with HasGameRef<MyGame> {
void foo() {
gameRef.foo();
}
}
void main() {
group('has game ref test', () {
test('simple test', () {
final MyComponent c = MyComponent();
final MyGame game = MyGame();
game.add(c);
c.foo();
expect(game.calledFoo, true);
});
});
}