refactor: renamed attach

pull/212/head
alestiago 3 years ago
parent 6ec63942cf
commit c2f0ae1409

@ -1,6 +1,5 @@
import 'package:flame/components.dart'; import 'package:flame/components.dart';
import 'package:flame/game.dart'; import 'package:flame/game.dart';
import 'package:flutter/foundation.dart';
// TODO(erickzanardo): Keeping this inside our code base // TODO(erickzanardo): Keeping this inside our code base
// so we can experiment with the idea, but this is a // so we can experiment with the idea, but this is a
@ -27,9 +26,7 @@ class Blueprint extends Component {
final List<Component> _components = []; final List<Component> _components = [];
/// Attaches children. Future<void> _addToParent(Component parent) async {
@mustCallSuper
Future<void> _attach(Component parent) async {
await parent.addAll(_components); await parent.addAll(_components);
} }
@ -39,9 +36,8 @@ class Blueprint extends Component {
/// Adds helper methods regarding [Blueprint]s to [FlameGame]. /// Adds helper methods regarding [Blueprint]s to [FlameGame].
extension FlameGameBlueprint on Component { extension FlameGameBlueprint on Component {
/// Shortcut to attach a [Blueprint] instance to this game /// Shortcut to add a [Blueprint]s components to its parent.
/// equivalent to `MyBluepinrt().attach(game)`
Future<void> addFromBlueprint(Blueprint blueprint) async { Future<void> addFromBlueprint(Blueprint blueprint) async {
await blueprint._attach(this); await blueprint._addToParent(this);
} }
} }

Loading…
Cancel
Save