AnimatedAppComponent Question?


Hi guys,

I am testing something with the AnimatedAppComponent class and I think there is a problem with getFrameCounter() method or maybe it's me who doesn't know how to make it work.

In the paint method of this Animated project I am drawing an Ellipse that increases its size using getFrameCounter().

Now the thing is that I want to make the ellipse increase its size only to a given value for ex. 250 pixels and then repeat itself on and on from 5-250 pixels, but it wont work and it will continue increasing its size infinitely because of the getFrameCounter() which doesn't repeat the value I am giving.

Here you have a gif so you can understand what I'm saying :

I used a label to display the getFrameCounter() and see its value and this shows that the problem is that the getFrameCounter() increases infinitely and doesn't repeat from 5 to 250 again and again. That's the reason that the ellipse doesn't repeat from 5-250 again.

If you want I can give you the code.



Well that's the way getFrameCounter() is designed: it will monotonically increase. You probably want to use the mod operator:

int radius = getFrameCounter() % 250;


That works.

Thank you Fabian. winkyes