fuzzygoat
fuzzygoat

Reputation: 26223

Multi-Layer Parallax Scrolling views?

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%)

Upvotes: 2

Views: 1175

Answers (1)

JBRWilkinson
JBRWilkinson

Reputation: 4865

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

Upvotes: 1

Related Questions