Performance from animation with one frame


#1

Hi all, this question is more out of curiosity than anything else. When creating an animation group in the defold editor, the default fps is set to 60. If the animation is then given only one sprite, and played in the game, will there be any difference in the rendering for this animation than if its fps were to be set to, say, 1?

I suspect the rendering would ignore updating the (single) frame 60 times per second, but it is always nice to know for a fact that there is no performance hit (however slim) by leaving it at 60 fps for single-frame animations.


#2

Good question! I honestly don’t know if we give one frame animations any special treatment. I think we do. One thing is that one frame animations will not generate an animation_done message (could be considered a bug maybe). @Mathias_Westerdahl can probably answer this. I assume you mean if it is set to loop right?


#3

Yes, exactly: are one frame animations looped just like animations with more than one frame?


#4

Not sure, but probably if you set the Playback to one of the looping ones.


#5

Alright, well, if it were, then I suppose having them not do that could be a feature request, as it could potentially affect performance (however slightly :roll_eyes:). Or would such a conditional in the rendering slow things down more than “updating” the sprite of the single frame animation could ever do?


#6

Hard to say. Maybe. Your best bet is to never set playback to loop on one frame animation groups.


#7

What advantage is there of using a one-frame animation over a sprite? Perhaps defold should stop you from using one-frame animations?


#8

I am not sure what the advantage would be, but I suspect negligible to none. Perhaps someone more senior knows the answer to that with regards to the exact implementation.

I feel that one-frame animations are useful enough as proof-of-concept tools (I will add more frames to this animation later, but for now I just want to see that it works) to warrant keeping them, and I don’t see any particular reason why they should be removed.


#9

So I’ve faced this “bug” today, but I noticed animation_done triggered on PC, but not on the browser (debug mode, no bundling!). So my solution in my game was to just do whatever I wanted to do right after the call to play the animation instead on the callback so it just played the one frame and keeps going (calling go.delete() in my game). I’m targeting messenger instant so the web behavior matters to me and I keep testing it