|
|
|
@ -14,6 +14,24 @@ class TestBodyComponent extends BodyComponent with Layered {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TestNestedBodyComponent extends BodyComponent with Layered {
|
|
|
|
|
TestNestedBodyComponent({required this.childLayer});
|
|
|
|
|
|
|
|
|
|
final Layer childLayer;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Body createBody() {
|
|
|
|
|
final fixtureDef = FixtureDef(CircleShape());
|
|
|
|
|
return world.createBody(BodyDef())..createFixture(fixtureDef);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
await add(TestBodyComponent()..layer = childLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
final flameTester = FlameTester(Forge2DGame.new);
|
|
|
|
|
|
|
|
|
@ -121,6 +139,24 @@ void main() {
|
|
|
|
|
expect(component.layer, equals(Layer.all));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'nested children will keep their layer',
|
|
|
|
|
(game) async {
|
|
|
|
|
const parentLayer = Layer.jetpack;
|
|
|
|
|
const childLayer = Layer.board;
|
|
|
|
|
|
|
|
|
|
final component = TestNestedBodyComponent(childLayer: childLayer)
|
|
|
|
|
..layer = parentLayer;
|
|
|
|
|
|
|
|
|
|
await game.ensureAdd(component);
|
|
|
|
|
expect(childLayer, isNot(equals(parentLayer)));
|
|
|
|
|
|
|
|
|
|
for (final child in component.children) {
|
|
|
|
|
expect((child as TestBodyComponent).layer, equals(childLayer));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('LayerMaskBits', () {
|
|
|
|
|