Hi.
This is example with two simple classes "ParallaxLayer" and "ParallaxBackground".
It help us to make scrolling backgrounds very easily in just few lines of code and
"unlimited" number of layers.
You can set scrolling speed of any individual layer.
Example on using it:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
and in "LG_Render" method we call
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
The code of those classes is not mine, I fond it somewhere on the internet (java) and
adapted it to work with B4A and Informatix libGDX library.
So all the credits goes to them
See the attached example.
You'll need version 1.0 of the libGDX library.
screenshoot of attached example:
		
		
	
	
the file is too big for the forum, so there is a mine dropbox link
https://dl.dropboxusercontent.com/u/40815149/parallaxExample.zip
second example: (see the post #5)
https://dl.dropboxusercontent.com/u/40815149/parallaxExample2.zip
CheerS!
			
			This is example with two simple classes "ParallaxLayer" and "ParallaxBackground".
It help us to make scrolling backgrounds very easily in just few lines of code and
"unlimited" number of layers.
You can set scrolling speed of any individual layer.
Example on using it:
			
				B4X:
			
		
		
		    'Horizontal Scrolling
    Dim Layer1 As ParallaxLayer: Layer1.Initialize(backgroundRegion,.1,0): ParalaxLayers.Add(Layer1): Layer1.Name = "Hills" ' the "Name" parameter is just helper (like a Tag property of a button)
    Dim Layer2 As ParallaxLayer: Layer2.Initialize(cloudsRegion,.2,0)    : ParalaxLayers.Add(Layer2): Layer2.Name = "clouds"
    Dim Layer3 As ParallaxLayer: Layer3.Initialize(MidleRegion,.4,0)    : ParalaxLayers.Add(Layer3): Layer3.Name = "fence"
    Dim Layer4 As ParallaxLayer: Layer4.Initialize(landRegion,4,0)      : ParalaxLayers.Add(Layer4): Layer4.Name = "land"
    myParallaxBackground.Initialize(ParalaxLayers,Camera,Batch)and in "LG_Render" method we call
			
				B4X:
			
		
		
		If myParallaxBackground.ScrolingHorizontal = True Then
        myParallaxBackground.moveX(Velocity * DeltaTime)
        myParallaxBackground.render
    Else
        myParallaxBackground.moveY(Velocity * DeltaTime)
        myParallaxBackground.render 
End IfThe code of those classes is not mine, I fond it somewhere on the internet (java) and
adapted it to work with B4A and Informatix libGDX library.
So all the credits goes to them
See the attached example.
You'll need version 1.0 of the libGDX library.
screenshoot of attached example:

the file is too big for the forum, so there is a mine dropbox link
https://dl.dropboxusercontent.com/u/40815149/parallaxExample.zip
second example: (see the post #5)
https://dl.dropboxusercontent.com/u/40815149/parallaxExample2.zip
CheerS!
			
				Last edited: 
			
		
	
							 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		