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.
Ecore_Timer * ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
Creates a timer to call the given function in the given period of time.
Definition: ecore_timer.c:189
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;
int size, i = -1;
{
size += i * 8;
i++;
if ((size < 20) || (size > 120))
continue;
}
#define EINA_LIST_FOREACH(list, l, _data)
Definition for the macro to iterate over a list.
Definition: eina_list.h:1415
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
EVAS_API void evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
Retrieves the position and (rectangular) size of the given Evas object.
Definition: evas_object_main.c:1335
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:185
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition: evas_object_main.c:1236
Type for a generic double linked list.
Definition: eina_list.h:318
}
Here we finish the example. The full source code can be found at test_growing_balls.c.