docs: included initialize example

pull/12/head
alestiago 4 years ago
parent 7a16b557d7
commit 5b984b2754

@ -2,6 +2,17 @@ import 'package:flame_forge2d/flame_forge2d.dart';
/// {@template anchor} /// {@template anchor}
/// Non visual [BodyComponent] used to hold a [BodyType.dynamic] in [Joint]s. /// Non visual [BodyComponent] used to hold a [BodyType.dynamic] in [Joint]s.
///
/// It is recommended to [_position] the anchor first and then use the body
/// position as the anchor point when initializing a [JointDef].
///
/// ```dart
/// initialize(
/// dynamicBody.body,
/// anchor.body,
/// anchor.body.position,
/// );
/// ```
/// {@endtemplate} /// {@endtemplate}
class Anchor extends BodyComponent { class Anchor extends BodyComponent {
/// {@macro anchor} /// {@macro anchor}
@ -14,6 +25,7 @@ class Anchor extends BodyComponent {
@override @override
Body createBody() { Body createBody() {
final bodyDef = BodyDef()..position = _position; final bodyDef = BodyDef()..position = _position;
return world.createBody(bodyDef); return world.createBody(bodyDef);
} }
} }

Loading…
Cancel
Save