Hello! I’ve created a pixel sprite, where each frame represents a different growth stage of a plant. At the moment, I’ve done this through a labor-intensive and repetitive process (as shown in an event). Is there a simpler, more efficient way to produce the same effect without having to do the same thing many times?
you could just use the value of your GrowthVariable directly for setting the animation:
I really value your advice. I followed the solution you suggested, but it appears the animation isn’t modifying the way I anticipated. When I troubleshoot the variables, they do increase when I release the left mouse button, as it supposed to be. However, the animation appears to pause or not proceed as expected.
Here is the updated event with the old event being disabled.
And this is what the sprite looks like.
Ah, okay. I thought all your plant states are different animations but of course they are frames of one animation, which makes more sense.
There is also an action to change the frames for an animation:
Splendid, I ended up with the following events.
One issue persists after the event. Let’s say I inserted a new frame into the sprite. I would then need to adjust the value of the expected number to reset the animation frame to 0. Is it possible to verify whether a sprite animation’s current frame has arrived at the end? That way, I could reset the animation frame back to 0 somehow.
There are two expressions that might be helpful, you can find both in the expression builder under General → Sprite → Animations and Images.
This one gives you the number of frames in your animation: <your_sprite_name>.AnimationFrameCount()
and this one the number of the current frame: <your_sprite_name>.Sprite()
Cool, thanks for the help.
Using the following condition (event attached as image below) we can check if the current frame is the last frame of the animation and create an action based on that condition. Since the
AnimationFrameCount() is return the length of the frame and the index starts from 0 therefore we need to subtract it with 1.
Perhaps there is some more elegant and advance solution to handle such condition, but at the moment I’m happy with the current solution. Credit to @Drona for the help.