| Collision-2D documentation | view source | Contained in the Collision-2D distribution. |
The time of collision. For example, consider a point-circle collision, where the point is moving towards the circle. $collision->time is the exact moment of collision between the two.
The axis of collision. Basically a vector from one entity to the other. It depends entirely on how they collide.
If the collision involves a vertical or horizontal line, the axis will be 'x' or 'y'. If it's between a point or corner and a circle, it will be an arrayref, of the form [$x,$y].
This vector will not be normal (normal means of length 1). Collision::2D::normalize_vec($v) is provided for that purpose.
Again, the axis of collision. If you call this, it will always return the vector form [$x,$y]. If the axis existed as 'x' or 'y', it is translated to [$x,$y].
This vector will not be normal (normal means of length 1). Collision::2D::normalize_vec($v) is provided for that purpose.
$collision->ent1
This is to provide some context for axis. This is useful because
dynamic_collision doesn't preserve the order of your entities. If you would
like for the order to be preserved, use the entity->collide($ent2) method,
or use the keep_order parameter in dynamic_collision.
my $bouncevec = $co->bounce_vector (elasticity => .8);
Assuming that $co->ent2 has infinite mass, the $co->bounce_vector is
the resulting velocity of $co->ent1. The elasticity parameter is 1 by default.
my $other_collision = $self->invert();
This returns the inverse of this collision. That is, the time remains, but ent1 and ent2 are swapped, and the axis is inversed. This does not effect $self.
| Collision-2D documentation | view source | Contained in the Collision-2D distribution. |