Loading multiple backgrounds for a scrolling shooter

Hi all.

Pretty much I’m making a top/down shooter and the floor (background) continuously scrolls underneath you. At the moment I have 2 images loaded and it scrolls through them until the first one is off-screen, positions it back to the top of the screen and continues. This works fine and lag free. The problem I’m having is i want different background to come and go, and pretty much loading extra background into memory causes alot of lag spikes. I’ve tried pre-loading them before the game starts but the game then lags frequently, and the fps fluctuates ALOT. Anyone have any ideas on how I could tackle this?

Also, just on the side, is 40mb of texture memory alot? I’m targeting android devices if that makes a difference but I can’t find a rough guide to the texture memory I should be aiming for.

Thanks for any advice :slight_smile:

well, if you’re getting lag spikes from whenever you’re loading extra background, perhaps lowering the quality of the background will speed up loadtime and and reduce lag? 

Not entirely sure how much texture memory is too little or too much honestly, the general rule of thumb i use is to make the images smallest I can without sacrificing too much image quality and to make sure the the image is properly cleaned up when it is off the screen. 

Not entirely sure how I should be picturing your idea. You’re loading two images: a background and a what? 

Edit: looked through some of my apps, most screen don’t seem to be <15MB of texture memory used. But my images are nothing complex or fancy or big. 

Pre-loading is certainly the way to go; as is rgame’s suggestion of reducing the image size and scaling up. 

Corona uses 32 bits per pixel (a byte per each channel), so a 1024x1024 image will use 4MB of texture memory. Texture memory is increasingly becoming available however it’s always worth being as efficient as possible - particularly if you’re targeting low-mid Android devices.

I’d be interested to see how you’re pre-loading your images, as this should be the correct technique - essentially it’s the image creation that typically causes the lag.

well, if you’re getting lag spikes from whenever you’re loading extra background, perhaps lowering the quality of the background will speed up loadtime and and reduce lag? 

Not entirely sure how much texture memory is too little or too much honestly, the general rule of thumb i use is to make the images smallest I can without sacrificing too much image quality and to make sure the the image is properly cleaned up when it is off the screen. 

Not entirely sure how I should be picturing your idea. You’re loading two images: a background and a what? 

Edit: looked through some of my apps, most screen don’t seem to be <15MB of texture memory used. But my images are nothing complex or fancy or big. 

Pre-loading is certainly the way to go; as is rgame’s suggestion of reducing the image size and scaling up. 

Corona uses 32 bits per pixel (a byte per each channel), so a 1024x1024 image will use 4MB of texture memory. Texture memory is increasingly becoming available however it’s always worth being as efficient as possible - particularly if you’re targeting low-mid Android devices.

I’d be interested to see how you’re pre-loading your images, as this should be the correct technique - essentially it’s the image creation that typically causes the lag.