One spreetsheet for multiple buttons is better than one sprite per button?

Hello everyone,

I have a spritesheet that contains some button sprites (on/off versions of each button).

If I load a spritesheet in memory, to assign a sprite to a button in the display and I use the same spritesheet to add another sprite in another button, this spritesheet is loaded twice? or only once?

I’m thinking about two ways to solve this:

  1. Create an on/off version of each button in separated files

  2. Re-use the spritesheet as I said.

If my current spritesheet has a size of 384x384 (converted to PoT 512x512), the memory consumption is significately higher than use 2 on/off sprites (128x128 + 128x128). Maybe for 2 buttons the first solution is better but if I have 6 buttons? What can I do?

Any ideas or recomendations?

Thank you so very much

Hi @dani0,

If you load an image sheet, you can use it multiple times to pull frames from it. It will not take up more texture memory once loaded the first time. Just be sure to clean it up properly from Lua memory when you’re finished with it.

Best regards,

Brent

Hi @dani0,

If you load an image sheet, you can use it multiple times to pull frames from it. It will not take up more texture memory once loaded the first time. Just be sure to clean it up properly from Lua memory when you’re finished with it.

Best regards,

Brent