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:
Should I re-use the same backgrounds again and again or should I look for something else?
I have learned about TileMaps that their cab be a very huge layer which are rendered easily by the iPhone.
Should I use the parallax scrolling or not?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With