Art source: https://opengameart.org/content/parallax-2d-backgrounds
ParallaxBackground class makes it simple to create a multilayer background.
The image files should be organized like this, where 0 is the top layer.
The code is very simple:
B4X:
Parallax.Initialize(Me, "layer", "png", 7) 'file names and count
Public Sub Tick (GS As X2GameStep)
HandleKeys
Parallax.Tick(GS)
End Sub
Public Sub DrawingComplete
Parallax.DrawComplete
End Sub
There are two configurable parameters in the class that can be modified to improve performance on behalf of the image scale and update frequency: https://www.b4x.com/android/forum/threads/xui2d-large-background-class-example.131589/post-829748
Note that ivBackground should be public variable.
GitHub - AnywhereSoftware/X2: B4X X2 Games Framework
B4X X2 Games Framework. Contribute to AnywhereSoftware/X2 development by creating an account on GitHub.
github.com