Posted by Marie Mon, April 30, 2012 12:40:09
* Front stars, moving fast and pulsating, large size
* Middle stars, moving fast, medium size
* Background stars, moving slow, small size
The depth feeling comes from the two last layers, when you see the "closer" (larger) stars moving past the "distant" (smaller) ones.
But lets talk and let me show you some code on the first one, the pulsating front stars. This layer if made up by three different textures, that each is transparent except for a few white painted stars.
I only show one of the three front star textures and once, and toggle which one is used, with a pause in between. When a texture is being used, I will gradually change the transparency to make a fade-in-fade-out pulsating effect.
I also move the layer to the left and paint it anew to the right as the side-scrolling game progresses.
Code sample from the pulsating stars: