Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a required to GameWidget and updated the docs #638

Merged
merged 3 commits into from
Jan 20, 2021
Merged
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
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