The purpose of this example is to demonstrate the dynamically growing and shrinking of an E\+Physics\+\_\+\+Body -\/ The code applies the growth of a ball and the shrink of another.

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics{growing_balls}}
\end{DoxyImageNoCaption}


For this example we'll have an E\+Physics\+\_\+\+World and three E\+Physics\+\_\+\+Bodys with different sizes associated with an evas\+\_\+object.

The basic concepts like -\/ defining an E\+Physics\+\_\+\+World, render geometry, physics limiting boundaries, add an E\+Physics\+\_\+\+Body, associate it to evas objects, change restitution, friction and impulse properties, were already covered in \hyperlink{tutorial_ephysics_bouncing_ball}{E\+Physics -\/ Bouncing Ball}\hypertarget{tutorial_ephysics_growing_balls_add-growshrink}{}\section{Adding the growing/shrinking}\label{tutorial_ephysics_growing_balls_add-growshrink}


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


\begin{DoxyCodeInclude}
   test\_data->data = ecore\_timer\_add(1, \_grow\_cb, test\_data);

\end{DoxyCodeInclude}


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.




\begin{DoxyCodeInclude}
\_grow\_cb(\textcolor{keywordtype}{void} *data)
\{
   Test\_Data *test\_data = data;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj;
   \hyperlink{struct__Eina__List}{Eina\_List} *l;
   \textcolor{keywordtype}{int} size, i = -1;

   \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(test\_data->evas\_objs, l, obj)
     \{
        \hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}(obj, NULL, NULL, &size, NULL);
        size += i * 8;
        i++;

        \textcolor{keywordflow}{if} ((size < 20) || (size > 120))
          \textcolor{keywordflow}{continue};

        evas\_object\_resize(obj, size, size);
     \}

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\end{DoxyCodeInclude}


Here we finish the example. The full source code can be found at \hyperlink{test_growing_balls_c}{test\+\_\+growing\+\_\+balls.\+c}. 