Difference between manually pushing a button (multiple times) and looping it?

Why does manually pressing a button multiple times give a different result than pressing a button once and then putting the button code in a loop? See specifics below:

Specifically, I have a button that when pressed calls a method that generates a random number and then displays the appropriate dice image.
I want the dice to have a spinning effect, so I put the code in a loop (say 100 times) with the expectation that the dice image will update 100 times (giving my spinning effect).
However this does not work. Only the final iteration (100th) updates the dice image. No matter how many iterations I use (100, 1,000, 10,000) it only displays the final one, so it’s not updating too quickly.

BUT…if i manually push the button many times then I get my spinning effect.

I feel like some sort of display update is occurring when the roll button method finishes, but I don’t know what exactly is happening.

Does anyone understand my problem and can you tell me what I need to do to cause my dice image to update correctly???

Thank you - Ed

If the code is called once, the animation is run once and the processor calls and shows the frames one by one. But if the code is called too many times, one after another, the processor can get locked up if the frames are heavy enough and calling them too many times results burdensome.

You shouldnt call an animation in a loop unless you have a way to ensure you run the animation only once, which is done via boolean flags.

I think I understand what you are saying, but how would I go about changing the image multiple times when the user pushes my button?

Specifically I am trying to display different dice images and create a spinning effect when the user presses the ROLL button.

Thanks - Ed

What you do is you set a boolean to false at the beginning. You check for the boolean and if false, run the animation. As soon as your animation finishes the first time around, set the boolean to true. So as soon as you reach the last frame in the animation, set it to true.