jetlag2d
    Preparing search index...

    Class AdvancedCollisionService

    AdvancedCollisionService is a physics simulator that provides the ability to run code in response to collisions.

    Hierarchy (View Summary)

    Index
    pointQuerier: PointToActorCallback = ...

    For querying the point that was touched

    world: b2World = ...

    The physics world in which all actors interact

    • Query to find the actors at a coordinate. This finds the actors whose bounding boxes overlap a square centered on the coordinate. Box2D pads each bounding box by about 0.1 meters, so the search area is about 0.2 meters larger than bbLength in each dimension.

      NB: The returned array is reused by the next call, so copy it if you need to keep it.

      Parameters

      • coords: { x: number; y: number }
        • x: number

          The X coordinate (in meters) to look up

        • y: number

          The Y coordinate (in meters) to look up

      • bbLength: number = 0.2

        The side length (in meters) of the square to search. Use a small value to find what's at a point (like a tap), or the size of something you want to place, to find out if anything is in its way. Defaults to 0.2.

      Returns Actor<unknown>[]

    • Register a new endContactHandler to run when a collision ends

      Parameters

      • actor1: Actor

        One of the actors of the collision. This actor should be the first argument to callback.

      • actor2: Actor

        The other actor from the collision / the second argument to callback.

      • callback: (a: Actor, b: Actor) => void

        The code to run when the collision ends

      Returns void