tutorial_ephysics_growing_balls(3)

NAME
tutorial_ephysics_growing_balls - EPhysics - Growing Balls The purpose of this example is to demonstrate the dynamically growing and shrinking of an EPhysics_Body - The code applies the growth of a ball and the shrink of another.

For this example we'll have an EPhysics_World and three EPhysics_Bodys with different sizes associated with an evas_object.

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

Adding the growing/shrinking

In this example we'll use a timer to handle the callback function.

   test_data->data = ecore_timer_add(1, _grow_cb, test_data);

 In this callback, we'll pass through a list with 3 balls and apply the growth and the shrink between the limit we'll set. Note that the variable i receives different values on each iteration (-1, 0, 1). For the first iteration it will decrease the size variable, the second will keep the same value, and the last one will increase the size variable.

_grow_cb(void *data)
{
   Test_Data *test_data = data;
   Evas_Object *obj;
   Eina_List *l;
   int size, i = -1;
   EINA_LIST_FOREACH(test_data->evas_objs, l, obj)
     {
        evas_object_geometry_get(obj, NULL, NULL, &size, NULL);
        size += i * 8;
        i++;
        if ((size < 20) || (size > 120))
          continue;
        evas_object_resize(obj, size, size);
     }
   return EINA_TRUE;
}

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