- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

EPhysics - Gravity

The purpose of this example is to demonstrate the EPhysics Gravity usage - The code apply gravity in an EPhysics_World with two cubes in movement.

For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys.

The basic concepts like - defining 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

Concepts like velocity and sleeping threshold were already covered in:

- EPhysics - Velocity
- EPhysics - Sleeping Threshold

# Setting Gravity

Here we set gravity on 3 axes (x, y, z) to (0, 0, 0). Gravity will act over bodies with mass over all the time.

ephysics_world_gravity_set(world, 0, 0, 0);

# Stopping a Body

We're using a button to call this function that receives test_data to stop the chosen body.

Stop angular and linear body movement, its equivalent to set linear velocity to 0 on both axis and angular velocity to 0 as well.

_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Test_Data *test_data = data;
EPhysics_Body *body = test_data->data;
ephysics_body_stop(body);
}

Here we finish the example. The full source code can be found at test_no_gravity.c.