+5 votes

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!

in Engine by (109 points)

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

1 Answer

+3 votes

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)

by (20 points)

Hi :)

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.