Player movement control on large backgrounds

I am creating a 2D game in which the player is constantly moving in the upward direction, and when the player reaches the maximum height (for example, 480), then the layer moves down. But the problem is that my FPS crashes when I add a larger background (e.g. 8192) in height. My questions:

  • Should I reuse the same background over and over again, or should I look for something else?

  • I learned about TileMaps that their cabs are a very huge layer that iPhone easily renders.

  • Should I use parallax scroll or not?

+6
source share
1 answer

You should cut a large background into equal smaller ones.

You most likely do not need a tile map to scroll vertically. Just add your smaller backgrounds to the array and show only those that are visible to the player.

In this example, I am updating only parts of BG1 , BG2 and BG3 . When BG1 turns off the screen, I will remove it and add BG4 above BG3 . The same thing happens with BG5 , BG6 , etc.

scrolling

You can also create an infinitely looped background by sorting an array with smaller parts of the background.

The use of parallax scrolling depends on your game art. The parallax effect is created by two or more background layers that scroll at different speeds. Watch a few videos to better understand it.

+1
source

Source: https://habr.com/ru/post/926652/


All Articles