Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doc/flame/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ major versions of Flame, together with the steps required to migrate your code.
## Migrating from v1.38.0 to v2.0.0


### `HasGameRef` removed in favour of `HasGameReference`

The deprecated `HasGameRef` mixin has been removed. Use `HasGameReference` instead, which is
otherwise identical apart from not offering the `gameRef` alias — use `game`:

```dart
// Before
class MyComponent extends Component with HasGameRef<MyGame> {
void doSomething() => gameRef.score++;
}

// After
class MyComponent extends Component with HasGameReference<MyGame> {
void doSomething() => game.score++;
}
```

The `game` getter, its setter (useful for mocking in tests), and the `findGame()` override all
behave exactly as before.


### `onDragCancel` no longer delegates to `onDragEnd`

`DragCallbacks.onDragCancel` used to convert the cancellation into an `onDragEnd` event by default,
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/platformer/step_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class EmberPlayer extends SpriteAnimationComponent
}
```

This file uses the `HasGameRef` mixin which allows us to reach back to `ember_quest.dart` and
This file uses the `HasGameReference` mixin which allows us to reach back to `ember_quest.dart` and
leverage any of the variables or methods that are defined in the game class. You can see this in
use with the line `game.images.fromCache('ember.png')`. Earlier, we loaded all the files into
cache, so to use that file now, we call `fromCache` so it can be leveraged by the `SpriteAnimation`.
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorials/platformer/step_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ class PlatformBlock extends SpriteComponent
}
```

We are going to extend the Flame `SpriteComponent` and we will need the `HasGameRef` mixin to access
our game class just like we did before. We are starting with the empty `onLoad` and `update`
We are going to extend the Flame `SpriteComponent` and we will need the `HasGameReference` mixin to
access our game class just like we did before. We are starting with the empty `onLoad` and `update`
methods and we will begin adding code to create the functionality that is necessary for the game.

The secret to any gaming engine is the game loop. This is an infinite loop that calls all the
Expand Down
2 changes: 0 additions & 2 deletions packages/flame/lib/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export 'src/components/mixins/has_ancestor.dart';
export 'src/components/mixins/has_auto_batched_children.dart'
show HasAutoBatchedChildren;
export 'src/components/mixins/has_decorator.dart' show HasDecorator;
// ignore: deprecated_member_use_from_same_package
export 'src/components/mixins/has_game_ref.dart' show HasGameRef;
export 'src/components/mixins/has_game_reference.dart' show HasGameReference;
export 'src/components/mixins/has_paint.dart';
export 'src/components/mixins/has_time_scale.dart';
Expand Down
49 changes: 0 additions & 49 deletions packages/flame/lib/src/components/mixins/has_game_ref.dart

This file was deleted.

44 changes: 0 additions & 44 deletions packages/flame/test/components/mixins/has_game_ref_test.dart

This file was deleted.

2 changes: 1 addition & 1 deletion packages/flame/test/components/mixins/has_world_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class _ParentComponent extends Component {
class _ChildComponent extends _ParentComponent with HasWorldReference<World> {}

void main() {
group('HasGameRef', () {
group('HasWorldReference', () {
testWithGame<FlameGame>('onRemove calls super', FlameGame.new, (
game,
) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void main() {
expect(game.calledFoo, true);
});

testWithGame<_MyGame>('gameRef can be mocked', _MyGame.new, (game) async {
testWithGame<_MyGame>('game can be mocked', _MyGame.new, (game) async {
final component = _BarComponent();
await game.ensureAdd(component);

Expand Down
2 changes: 1 addition & 1 deletion packages/flame/test/experimental/has_world_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void main() {
expect(c.world.calledFoo, isTrue);
});

testWithGame<_MyGame>('gameRef can be mocked', _MyGame.new, (game) async {
testWithGame<_MyGame>('game can be mocked', _MyGame.new, (game) async {
final component = _BarComponent();
await game.world.ensureAdd(component);

Expand Down
Loading