diff --git a/lib/game/components/anchor.dart b/lib/game/components/anchor.dart index 62c4c42f..9ea79855 100644 --- a/lib/game/components/anchor.dart +++ b/lib/game/components/anchor.dart @@ -2,6 +2,17 @@ import 'package:flame_forge2d/flame_forge2d.dart'; /// {@template anchor} /// 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} class Anchor extends BodyComponent { /// {@macro anchor} @@ -14,6 +25,7 @@ class Anchor extends BodyComponent { @override Body createBody() { final bodyDef = BodyDef()..position = _position; + return world.createBody(bodyDef); } }