private void createLayers() { atlas = new TextureAtlas("data/main_atlas.atlas"); TextureRegion mountainsRegionA = atlas.findRegion("Layer0"); TextureRegionParallaxLayer mountainsLayerA = new TextureRegionParallaxLayer( mountainsRegionA, worldWidth * 2, new Vector2(.3f, .6f), WH.width); TextureRegion mountainsRegionB = atlas.findRegion("Layer1"); TextureRegionParallaxLayer mountainsLayerB = new TextureRegionParallaxLayer( mountainsRegionB, worldWidth * 2 /** .7275f */ , new Vector2(.6f, .6f), WH.width); // mountainsLayerB.setPadLeft(.2725f*worldWidth); TextureRegion cloudsRegion = atlas.findRegion("Layer2"); TextureRegionParallaxLayer cloudsLayer = new TextureRegionParallaxLayer( cloudsRegion, worldWidth * 2, new Vector2(.6f, .6f), WH.width); // cloudsLayer.setPadBottom(worldHeight*.467f); TextureRegion buildingsRegionA = atlas.findRegion("Layer3"); TextureRegionParallaxLayer buildingsLayerA = new TextureRegionParallaxLayer( buildingsRegionA, worldWidth * 2, new Vector2(.75f, .6f), WH.width); TextureRegion buildingsRegionB = atlas.findRegion("Layer4"); TextureRegionParallaxLayer buildingsLayerB = new TextureRegionParallaxLayer( buildingsRegionB, worldWidth * 2 /** .8575f */ , new Vector2(1, .6f), WH.width); // buildingsLayerB.setPadLeft(.07125f*worldWidth); // buildingsLayerB.setPadRight(buildingsLayerB.getPadLeft()); TextureRegion buildingsRegionC = atlas.findRegion("Layer5"); TextureRegionParallaxLayer buildingsLayerC = new TextureRegionParallaxLayer( buildingsRegionC, worldWidth * 2, new Vector2(1.3f, 1.3f), WH.width); parallaxBackground = new ParallaxBackground(); parallaxBackground.addLayers( mountainsLayerA, mountainsLayerB, cloudsLayer, buildingsLayerA, buildingsLayerB, buildingsLayerC); // parallaxBackground.addLayers(mountainsLayerA); }
@Override public void render() { if (inputOn) processInput(); Gdx.gl.glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); parallaxBackground.draw(worldCamera, batch); batch.end(); }