1
Graphics / [SOLVED] Reusing a single sf::Sprite through a game: good or bad idea?
« on: April 02, 2020, 11:50:46 am »
I'm using a single sf::Sprite and sf::Texture for my entire game. My Texture contains my game's entire tileset and, every time I need to draw something, I update the TextureRect in the Sprite like this:
I found that, since I have to update the position and maybe scale, etc. on the sprite every frame anyway, I might as well update its TextureRect instead of storing lots of different sf::Sprite objects.
Is there any downside to doing this? Am I missing on some optimization (batching draws, etc.) because of this?
Thanks a lot, folks!
Code: [Select]
sprite.setTextureRect(<whatever>);
I found that, since I have to update the position and maybe scale, etc. on the sprite every frame anyway, I might as well update its TextureRect instead of storing lots of different sf::Sprite objects.
Is there any downside to doing this? Am I missing on some optimization (batching draws, etc.) because of this?
Thanks a lot, folks!