mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
741 B
29 lines
741 B
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
/// {@template joint_anchor}
|
|
/// Non visual [BodyComponent] used to hold a [BodyType.dynamic] in [Joint]s
|
|
/// with this [BodyType.static].
|
|
///
|
|
/// It is recommended to use [JointAnchor.body.position] to position the anchor
|
|
/// point when initializing a [JointDef].
|
|
///
|
|
/// ```dart
|
|
/// initialize(
|
|
/// dynamicBody.body,
|
|
/// anchor.body,
|
|
/// anchor.body.position,
|
|
/// );
|
|
/// ```
|
|
/// {@endtemplate}
|
|
class JointAnchor extends BodyComponent with InitialPosition {
|
|
/// {@macro joint_anchor}
|
|
JointAnchor();
|
|
|
|
@override
|
|
Body createBody() {
|
|
final bodyDef = BodyDef()..position = initialPosition;
|
|
return world.createBody(bodyDef);
|
|
}
|
|
}
|