Typically, you assign a visual object (i.e. a sprite) to the Box2D body userdata object for contact listeners.
In the case of a contact callback, you get only box2d objects. Therefore, you get contact bodies from the body of userdata to send messages to the sprite, which represents the body visually.
For example, if you want to run a sprite animation in a collision.
source share