PolygonHitbox.fromPath constructor
PolygonHitbox.fromPath(})
With this constructor you create a PolygonHitbox from the given
contour (the first by default) of a Path.
A polygon only has straight edges, so the curves of the path are
approximated. The contour is sampled every sampling along its length,
and the samples that are not needed to stay within about half of the
sampling of the contour are left out. Higher values give fewer vertices,
which makes the collision detection cheaper, and a looser fit, while
straight stretches and the corners between them are exact whatever the
sampling is. The given tolerance decides what samples to discard:
by default, its value is half the sampling.
See PathMetricExtension.walkContour for the details of the sampling
and tolerance parameters.
Implementation
PolygonHitbox.fromPath(
super.path, {
super.contour,
super.sampling,
super.tolerance,
super.position,
super.angle,
super.anchor,
super.isSolid,
CollisionType collisionType = CollisionType.active,
}) : super.fromPath() {
this.collisionType = collisionType;
}