The purpose of this example is to demonstrate the EPhysics Collision Detection usage - The code adds two balls, one with impulse and the second with a collision detection callback, to show an effect.
For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys, we'll apply an impulse in one of then and the other will be stopped "waiting" for a collision.
The basic concepts like - initializing an EPhysics_World, render geometry, physics limiting boundaries, add an Ephysics_Body, associate it to evas objects, change restitution, friction and impulse properties, were already covered in EPhysics - Bouncing Ball
While in this example we'll be working with a struct to hold some objects in our code. For clarity sake we present you the struct declaration in the following block.
Calling ephysics_body_event_callback_add() will register a callback to a type of physics body event.
EPHYSICS_CALLBACK_BODY_COLLISION : called just after the collision has been actually processed by the physics engine. In other words, to be notified about a collision between two physical bodies.
See _EPhysics_Callback_Body_Type for more event types.
The callback function will filter the collision to be sure if that body is which we want and then show the effect.
First we need to create a specific variable type to get collision infos: EPhysics_Body_Collision
Now we want to know which body collides with and filter it.
We just get the collision position, move the impact effect to this coordinate and send a signal to edje to show it.
Here we finish the example. The full source code can be found at test_collision_detection.c.