@@ -596,28 +596,48 @@ def on_collision(
596596 separate : Optional [_CollisionCallback ] = None ,
597597 data : Any = None ,
598598 ) -> None :
599- """Set callbacks that will be called during the 4 phases of collision handling.
600-
601- Use None to indicate any collision_type.
602-
603- Fill the desired collision callback functions, for details see the
604- :py:class:`CollisionHandler` object.
599+ """Set callbacks that will be called during the 4 phases of collision
600+ handling.
605601
606602 Whenever shapes with collision types (:py:attr:`Shape.collision_type`)
607- a and b collide, this handler will be used to process the collision
608- events. If no handler is set, the default is to process collision as
603+ a and b collide, the callback will be used to process the collision
604+ events. If no callback is set, the default is to process collision
609605 normally.
610606
611- If multiple handlers match the collision, the order will be that the
612- most specific handler is called first .
607+ Its possible to pass in None for one or both of the collision types.
608+ None matches any collision type on a Shape .
613609
614- Note that if a handler already exist for the a,b pair, that existing
615- handler will be returned.
610+ If you call this multiple times with the same combination of
611+ collision_type_a and collision_type_b, then the last call will
612+ overwrite the earlier.
613+
614+ If multiple callbacks match the collision, the order will be that the
615+ most specific handler is called first.
616616
617- :param int collision_type_a: Collision type a
618- :param int collision_type_b: Collision type b
617+ Callback phases:
618+
619+ - **begin**: Two shapes just started touching for the first time
620+ this step.
621+ - **pre_solve**: Two shapes are touching during this step, before
622+ collision resolution. You may override collision values using
623+ Arbiter.friction, Arbiter.elasticity or Arbiter.surfaceVelocity
624+ to provide custom friction, elasticity, or surface velocity
625+ values. See Arbiter for more info.
626+ - **post_solve**: Two shapes are touching and their collision response
627+ has been processed. You can retrieve the collision impulse or
628+ kinetic energy at this time if you want to use it to calculate
629+ sound volumes or damage amounts. See Arbiter for more info.
630+ - **separate**: Two shapes have just stopped touching for the
631+ first time this step. To ensure that begin()/separate() are
632+ always called in balanced pairs, it will also be called when
633+ removing a shape while its in contact with something or when
634+ de-allocating the space.
635+
636+ From each callback you can set process_collision on the Arbiter,
637+ which decides if the collision should be processed or not.
638+
639+ data will be passed in to the callback function unchanged.
619640
620- :rtype: :py:class:`CollisionHandler`
621641 """
622642 # key = min(collision_type_a, collision_type_b), max(
623643 # collision_type_a, collision_type_b
0 commit comments