Properly propagate onMount and onRemove to children (#579)

* Fix rendering of children

* Game loop handles other restore

* Properly propagate onMount and onRemove to children

* Use BaseGame on gestures to minimize confusion

* Fix linting

* All children don't need preparation

* Add composability example

* gameRef might not be defined

* Add mustCallSuper

* isMounted on game

* Remove unused gameRef argument

* Made isMounted only modifiable by the component

* Move dartdoc to public isMounted

* Fix formatting
This commit is contained in:
Lukas Klingsbo
2020-12-21 12:42:45 +01:00
committed by GitHub
parent fdb12f3265
commit 692213d5a4
15 changed files with 194 additions and 26 deletions

View File

@ -12,7 +12,8 @@ void main() {
}
/// Includes an example mixing two advanced detectors
class MyGame extends Game with MultiTouchTapDetector, MultiTouchDragDetector {
class MyGame extends BaseGame
with MultiTouchTapDetector, MultiTouchDragDetector {
final _whitePaint = BasicPalette.white.paint;
Paint _paint;
@ -81,11 +82,9 @@ class MyGame extends Game with MultiTouchTapDetector, MultiTouchDragDetector {
);
}
@override
void update(double dt) {}
@override
void render(Canvas canvas) {
super.render(canvas);
_taps.values.forEach((rect) {
canvas.drawRect(rect, _paint);
});