How to start/stop animation?



Hello all,

I have made a little animation (oh, well .. it is a square bouncing). I
do in the main-program:

gtk_timeout_add (100,Repaint, (gpointer) drawing_area);

with function Repaint:

gint Repaint (gpointer data)
{
 
  GtkWidget* drawing_area = (GtkWidget *) data; 
  GdkDrawable *drawable;
  time_t now;
  struct tm *now_tm;
  float move;
  
  drawable = drawing_area ->window;
  gdk_draw_rectangle  (etc. etc. nice drawings)

  //now timeinfo, did I mentione I use #include<time.h>
  time(&now);
  now_tm = localtime(&now);
  move = 25.0 * sin (5*now_tm->tm_sec*3.14/70);
  
  // I use move as input for my movement, so I can bounce a rectangle,
Okay, that works. It doesn't stop anymore, because it just uses the
clock and keeps on bouncing.

I want to add a toggle-button with 'start' and 'stop'. I can create the
buttons, that is no problem, but how can I make it stop/start the
animation. I can terminate the 
gtk_timeout_add bij returning Repaint with return (FALSE), but how would
I start the animation again?

Looking forward for your reactions. Edward Hage



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]