Automatically scroll the background with libGDX

Method

From ParallaxBackground, go to [ParallaxBackground.java](https://github.com/surahul/ParallaxBackground-libgdx/blob/master/core/src/com/ rahul / libgdx / parallax / ParallaxBackground.java) and ParallaxLayer.java Is copied in its entirety. Then write the code to scroll the background on the game screen.

Game screen

For horizontal scrolling, ** horizontal scrolling speed ** 1.0f, ** vertical scrolling speed ** 0.0f, and adjust well according to the size of the background. For the last * new Vector2 (0,100) *, change the first number to 0 for horizontal scrolling. You can change the scroll speed by playing with the numbers here.

GameScreen.java


ParallaxBackground rbg;
public GameScreen(){ 
assets = new AssetManager();
         assets.load("background.pack", TextureAtlas.class);
         assets.finishLoading();

         atlas = assets.get("background.pack");

rbg = new ParallaxBackground(new ParallaxLayer[]{
                new ParallaxLayer(atlas.findRegion("background"), 
                new Vector2(Side-scrolling speed,Vertical scroll speed), new Vector2(0, 0)),},
Background width,Background height, new Vector2(0, 100));
} 

public void render(float delta){
rbg.render(Gdx.graphics.getDeltaTime());
}

Recommended Posts

Automatically scroll the background with libGDX
The story of tuning android apps with libGDX
Background image transparency (layering the image with your favorite color)
Automatically test with Gauge
When I tried to scroll automatically with JScrollBar, the event handler was drawn only once.
Import the date string automatically converted to Excel with java.time.LocalDate
Automatically adjust the height of the WebView dialog with the size of the content
Mock the constructor with PowerMock
With the error Cordova-> Looper.prepare ()
Monitor the clipboard with JNA
JavaFX-Load Image in the background