Games [XUI2D] Parallax Background

Erel

Administrator
Staff member
Licensed User
1623657904030.png


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.

1623658014619.png

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.

 
Top