Module org.dyn4j

Interface ContactListener

  • All Superinterfaces:
    Listener
    All Known Implementing Classes:
    ContactAdapter

    public interface ContactListener
    extends Listener
    Represents an object that is notified of contact events.

    Implement this interface and register it with the World to be notified when contact events occur. Contact events occur after all CollisionListener events have been raised.

    Modification of the World is permitted from any of these methods.

    Returning false from any of the listener methods will disable the whole contact constraint. Other ContactListeners will still be notified of this event and other contact events for this constraint. A disabled contact constraint will not be solved. Contact constraints disabled this way are only disabled for this timestep.

    If a body is to be removed, make sure to return false to disable the contact. Otherwise the contact between the bodies will still be resolved even if the body has been removed. If a body is removed you should check the remaining contacts for that body and return false from the those as well.

    Since:
    1.0.0
    Version:
    3.2.5
    Author:
    William Bittle
    • Method Detail

      • sensed

        @Deprecated
        void sensed​(ContactPoint point)
        Deprecated.
        As of 3.3.0 this is not called, use the other methods in the listener and check the sensor flag instead
        Called when a contact has been sensed between two Bodys, where one or both Body's BodyFixtures are sensors.
        Parameters:
        point - the contact point that was sensed
      • begin

        boolean begin​(ContactPoint point)
        Called when two BodyFixtures begin to overlap, generating a contact point.
        Parameters:
        point - the contact point that was added
        Returns:
        boolean true if the contact should remain enabled
      • end

        void end​(ContactPoint point)
        Called when two BodyFixtures begin to separate.
        Parameters:
        point - the contact point that was removed
      • persist

        boolean persist​(PersistedContactPoint point)
        Called when two BodyFixtures remain in contact.
        Parameters:
        point - the persisted contact point
        Returns:
        boolean true if the contact should remain enabled
      • preSolve

        boolean preSolve​(ContactPoint point)
        Called before contact constraints are solved.
        Parameters:
        point - the contact point
        Returns:
        boolean true if the contact should remain enabled
      • postSolve

        void postSolve​(SolvedContactPoint point)
        Called after contacts have been solved.
        Parameters:
        point - the contact point that was solved