Sprite vs AnimatedSprite Pros and Cons?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By shianiawhite

From what I’ve seen the primary difference between a Sprite and an AnimatedSprite is that the sprite uses a spritesheet, while the AnimatedSprite uses individual images for each frame. Are there more differences? Or is this it?

I’ve also seen some vague comments about the individual images being better in some cases, because loading large spritesheets can cause problems in some cases. However, I’ve also seen other comments suggesting that since you can just load the spritesheet into memory, it’s better on speed because you don’t need to keep swapping things in and out of memory. Are there general guidelines for when one is better than the other? If relatively small sprites are being used, does this ever lead to concerns on modern devices (as long as you’re not doing anything too crazy)? Or is it a very common problem to have speed issues due to the choice? Lastly, assuming there isn’t a concern performance-wise, is one option generally easily to work with than the other? Thank you much!

I would also love to see someone explain this. I had this exact doubt just now!

rafgp | 2018-08-07 10:27

:bust_in_silhouette: Reply From: Phileas

I made some experiments and using AnimatedSprite seams less memory intensive that Sprites (+AnimationPlayer).

Here is how I did:

  • Create 4 sprites (500x500px PNG 16b color) and create an AnimatedSprite with it.
  • Create a 2000x500px spritesheat to use my sprites in a Sprite and configure an Animation Player accordingly.

I instanciate either Sprites or Animated Sprites multiple times with a script and use the monitoring tools to benchmark them:

  • Static memory for 100 Sprites: 24Mio (Animated Sprites) / 26Mio (Sprites)
  • Static memory for 1000 Sprites: 25Mio (Animated Sprites) / 51Mio (Sprites)
  • Static memory for 10000 Sprites: 43Mio (Animated Sprites) / 302Mio (Sprites, can only display at 50FPS)
  • Static memory for 20000 Sprites: 62Mio (Animated Sprites, 50FPS) / 580Mio (Sprites 40FPS)

I tried to preload the texture in the script and assign it to every Sprite but it did not change the result.


If someone can explain why I may be interrested. Nevertheless because I like to use Blender to animate my 2D characters it’s easier for me to use Animaed Sprites.
Version: Godot v3.2.2 (official)

Hi :slight_smile:

Stayed very nice this the benchmark, thank you very much by test it! I thing too that be useful whether you make this scenario available in some repository for other peoples too can run this benchmark.

LuizTM | 2021-05-05 06:29