mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
* 👌 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>
29 lines
563 B
Dart
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);
|
|
});
|
|
});
|
|
}
|