Introduce updateTree (#1158)

* Introduce updateTree

* Update tests

* Fix update for game-in-game situations

* Add dartdoc to updateTree
This commit is contained in:
Lukas Klingsbo
2021-12-03 14:01:46 +01:00
committed by GitHub
parent bc31e11d29
commit fe162c6d90
29 changed files with 43 additions and 49 deletions

View File

@ -1,6 +1,9 @@
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame/input.dart';
import 'package:flame/palette.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// This class only has `HasDraggables` since the game-in-game example moves a
// draggable component to this game.
@ -32,8 +35,15 @@ class ComposabilityExample extends FlameGame with HasDraggables {
}
class ParentSquare extends RectangleComponent with HasGameRef {
static final defaultPaint = BasicPalette.white.paint()
..style = PaintingStyle.stroke;
ParentSquare(Vector2 position, Vector2 size)
: super(position: position, size: size);
: super(
position: position,
size: size,
paint: defaultPaint,
);
@override
Future<void> onLoad() async {
@ -49,21 +59,25 @@ class ParentSquare extends RectangleComponent with HasGameRef {
position: Vector2(100, 100),
size: childSize,
angle: 2,
paint: defaultPaint,
),
RectangleComponent.square(
position: Vector2(160, 100),
size: childSize,
angle: 3,
paint: defaultPaint,
),
RectangleComponent.square(
position: Vector2(170, 150),
size: childSize,
angle: 4,
paint: defaultPaint,
),
RectangleComponent.square(
position: Vector2(70, 200),
size: childSize,
angle: 5,
paint: defaultPaint,
),
];