andrei_c wrote:
> Hello everyone, I was trying to make some simple program that involves 
> animation, and I came up whit the idea of making a program that draws a 
> rectangle at a different position each half a second.That seems pretty 
> simple.I managed to do that, but until I exit the aplication, the animation 
> never stops.So I wanted to make a version of it that stops after a number of 
> frames.But I couldn't do it.

--- code removed ---

> As you can see, I've addes a variable the increases by 1 every time the 
> timer_cb() function is called.But it does not work.How can I stop this 
> animation after a certain number of frames.I know it has something to do whit 
> remove_timeout(), but how do I do it.Please help me if you can.I know that 
> I'm close. :)

Yes, you are, probably.The main problem is in the draw() method. Move 
the calculation of the new random coordinates to the timer callback 
routine, and you should be done.

Without compiling and running your code I can only assume that you must 
do something like resizing the window to see your never ending 
animation. This happens because draw() is called whenever your widget 
needs any updates, e.g. by occluding parts of it or by resizing. Is this 
what you're seeing? This ought to stop if you don't calculate new 
coordinates in draw().

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to