How do I…
Animate a while loop
What is the expected result
To zoom out the camera
What is the actual result
Black screen
Animate a while loop
To zoom out the camera
Black screen
Hi,
the wait action in your while loop causes it to freeze. Of course you added this because you noticed that the variable value of 256 is reached as soon as you start the review.
There is probably a way to make it work with the while loop, but you could just use a timer instead. Either you increase the zoom variable after the timer reached a certain value and just start it again or you directly add the value of the timer to the zoom variable. If you don’t want to use a timer, you could increase the zoom with TimeDelta.
I agree. A zoom tween would be the easiest approach.
As for the current events. The time for the wait event isn’t processed within the while event. Wait timers are processed between frames.
Since the waits never expire, The variable never gets increased which causes an infinite loop within the while event.
It is also worth mentioning that while events literally stop the game from processing other events or frame so long as the “while” conditions are true. Meaning animations or actions won’t proceed until the logic is completed.
You definitely wouldn’t use a while event to show anything gradual to the player.
Something interesting and unobvious about asynchronous actions too is that they will always resolve (= run the code that comes after it) not when it has finished its job, but at the start of the next frame after it has!
Even if 0.1 second elapses, and the condition of the wait has thus been met, the code after will only be called at the start of the next frame.
Ah, i see now, thanks! Right now animating loops would definitely help for future projects. Care telling me how to do that?
It depends on what you want to achieve with the animation loop. If it’s looping the same animation over and over, that’s a setting in the sprite object. If it’s something else, then you’ll need to explain.