Migrate examples back, change to monorepo (#701)

This commit is contained in:
Luan Nico
2021-03-12 09:24:50 -05:00
committed by GitHub
parent d3e8b87ee6
commit 769bb711c3
334 changed files with 2283 additions and 3279 deletions

View File

@ -0,0 +1,51 @@
import 'package:flame/components.dart';
import 'package:flame/game.dart';
class Square extends PositionComponent with HasGameRef<Composability> {
Square(Vector2 position, Vector2 size, {double angle = 0}) {
this.position.setFrom(position);
this.size.setFrom(size);
this.angle = angle;
}
}
class ParentSquare extends Square {
ParentSquare(Vector2 position, Vector2 size) : super(position, size);
@override
void onMount() {
super.onMount();
createChildren();
}
void createChildren() {
// All positions here are in relation to the parent's position
final children = [
Square(Vector2(100, 100), Vector2(50, 50), angle: 2),
Square(Vector2(160, 100), Vector2(50, 50), angle: 3),
Square(Vector2(170, 150), Vector2(50, 50), angle: 4),
Square(Vector2(70, 200), Vector2(50, 50), angle: 5),
];
children.forEach(addChild);
}
}
class Composability extends BaseGame {
ParentSquare _parent;
@override
bool debugMode = true;
Composability() {
_parent = ParentSquare(Vector2.all(200), Vector2.all(300));
_parent.anchor = Anchor.center;
add(_parent);
}
@override
void update(double dt) {
super.update(dt);
_parent.angle += dt;
}
}