Multiple single big images vs many small images for parallaxing stars? ✨

Just wondering in general what is a better strategy for optimization for a parallax background in a space shooter game.

I can do two big sprites that are larger than the height of the screen that just scroll infinitely, which would require less sprites on screen but would mean more screen updates, or i can dynamically generate stars, which would be many smaller sprites but less overall screen updates.

1 Like

I had the same situation and from my experience, a few large images are much faster than many small ones. Plus you save cpu time from the logic side of managing a few objects rather than many.
However I would advise against sprites for a parallax. Sprites are good for situation where you have a lot of assets on screen but only a few move and need a redraw. If all images need a redraw per frame then you’re better off with simple image:draw and manage your own class for coordinates and such. Sprites carry a lot of features that make them heavier than just a few tables and the simple logic you could code. I did some experiments and sprites seem to consume cpu time even when they’re not in the display list.

So I would say one large image combining all stars per parallax level.
Also, if it’s white stars I would not use an alpha channel but simply draw the images in Blacktransparent mode. And Whitetransparent mode if your stars are black.


@StephanRewind is spot on wrt sprite:moveBy being notably slow