Games [XUI2D] Parallax Background

Erel

B4X founder
Staff member
Licensed User
Longtime User


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.

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…