Skip to content

Commit

Permalink
Added a required to GameWidget and updated the docs (#638)
Browse files Browse the repository at this point in the history
* Added a required to GameWidget and updated the docs

* Removed entry from CHANGELOG
  • Loading branch information
wolfenrain authored Jan 20, 2021
1 parent 5f52dcd commit ddcd679
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Added `Composition`, allows for composing multiple images into a single image.
- Move files to comply with the dart package layout convention
- Fix gesture detection bug of children of `PositionComponent`
- The `game` argument on `GameWidget` is now required

## 1.0.0-rc5
- Option for overlays to be already visible on the GameWidget
Expand Down
5 changes: 4 additions & 1 deletion doc/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ class MyGameSubClass extends Game {
main() {
final myGame = MyGameSubClass();
runApp(
GameWidget(
game: MyGameSubClass(),
game: myGame,
)
);
}
```

**Note:** Do not instantiate your game in a build method. Instead create an instance of your game and reference it within your widget structure. Otherwise your game will be rebuild every time the Flutter tree gets rebuild.

It is important to notice that `Game` is an abstract class with just the very basic implementations of the gameloop.

As an option and more suitable for most cases, there is the full-featured `BaseGame` class. For example, Forge2D games uses `Forge2DGame` class;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/game/game_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class GameWidget<T extends Game> extends StatefulWidget {
/// ```
const GameWidget({
Key key,
this.game,
@required this.game,
this.textDirection,
this.loadingBuilder,
this.errorBuilder,
Expand Down

0 comments on commit ddcd679

Please sign in to comment.