Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling Player movement on larger Backgrounds

I'm building a 2D game in which the player is constantly moving in the upward direction and when the player reaches the max height visible (e.g 480) then the layer moves down. But the problem is that my FPS drops when I'm adding a larger background (e.g 8192) in height. My questions are:

  1. Should I re-use the same backgrounds again and again or should I look for something else?

  2. I have learned about TileMaps that their cab be a very huge layer which are rendered easily by the iPhone.

  3. Should I use the parallax scrolling or not?

like image 790
Moeez Akram Avatar asked Oct 01 '12 08:10

Moeez Akram


1 Answers

You should cut the large background into equal smaller ones.

You most likely don't need tile map for vertical scrolling. Just add your smaller backgrounds in an array and show only those that are visible to player.

On the example I'm updating only BG1, BG2 and BG3 parts. When BG1 go off the screen, I will remove it and add BG4 above BG3. The same goes with BG5, BG6, etc.

scrolling

You could also create infinitely looped background by sorting an array with smaller background parts.

Use of parallax scrolling depends on your game art. Parallax effect is created by two or more background layers scrolled with different speed. Watch some videos to understand it better.

like image 117
Ivan Mir Avatar answered Sep 22 '22 17:09

Ivan Mir