Sprite optimization

Hi Guys,

I’m just wondering what the best way of tackling a problem would be. In my game, Stay Alive, you fly through space that is littered with rocks. When you shoot the rocks, they explode. Here’re the two options that I can think of:

  1. Have a rock sprite sheet (not animated, it’s so I can display a random frame so the rocks are varied) and an explosion spritesheet. When the rock is destroyed, I create a new animation of an explosion and place it where the rock was.

  2. Have a single sprite sheet. The first set of frames will be rocks and the rest with be the explosion animation. I then would simply play the animation at the correct frame when the rock explodes.

My confusion is that with option 2, the sprite sheet would be bigger. Would printing, say, 50 rocks to the screen with a larger sprite sheet effect the performance? Or is it only loaded into memory once?

Currently I’m using option 1, and it can get slow when a lot of rocks explode at the same time. I thought it would be faster with option 2, where I don’t need to create any new objects.

Thanks! [import]uid: 35072 topic_id: 21625 reply_id: 321625[/import]

I think option 2 [import]uid: 7911 topic_id: 21625 reply_id: 85794[/import]

Option 2 is the best. If you can fit them all on one sheet go for it.

Remember the actual filesize of your sheet uses much more memory than its filesize when loaded on device.

for instance your png is 248kb.

A 24 bit 1024x1024 image uses 3MB

1024 = 1k and 1k*1k=1MB
And RGB is 24 bit, or 3 bytes per pixel
So 1024x1024x3=3MB [import]uid: 84637 topic_id: 21625 reply_id: 85856[/import]