views:

51

answers:

1

I am looking to setup a multi-layer parallax scrolling background for a game application and was wondering how I might go about this. The application will scroll left to right (in landscape mode) and I am looking to setup three layers, foreground trees, background hills and distant clouds all moving in parallax. Each layer going back will scroll at a slightly slower speed than the layer in-front.

Foreground Trees (Front)
Background Hills (Middle)
Distant Clouds (Back)

My initial thinking as to setup a single UIScrollView and then use 3 separate UIViews each with a UIImage for the required layer. UIImages will have alphas for the transparent areas so the layer below is visible behind.

My question is, is this the right way to go about this, also can anyone give me any pointers on how I can reduce the scroll speed of each layer as they go back in depth. (i.e. Trees 100%, Hills 85%, clouds 50%)

+1  A: 

AFAIK, a UIScrollView will move the entire area that needs to scroll using a bit-blit operation for speed. This means that everything would move at the pace of the foreground, and you'd have to do lots of redrawing to fix it.

A better option would be to look into using OpenGLES to get hardware-accelerated blit'ting of your own layer graphics. Here's a starting point - 2D games with OpenGL

JBRWilkinson
Much appreciated JBRWilkinson, I will check that out, thanks for pointing me in the right direction.
fuzzygoat