From b4b637d8997314cc7a27680866b0482d2b3ebd4d Mon Sep 17 00:00:00 2001 From: FongZooZ Date: Sun, 30 Aug 2015 20:01:34 +0700 Subject: [PATCH] draw a little bit outside the screen --- .../src/com/rahul/libgdx/parallax/ParallaxBackground.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/com/rahul/libgdx/parallax/ParallaxBackground.java b/core/src/com/rahul/libgdx/parallax/ParallaxBackground.java index f1039b0..8c2c959 100644 --- a/core/src/com/rahul/libgdx/parallax/ParallaxBackground.java +++ b/core/src/com/rahul/libgdx/parallax/ParallaxBackground.java @@ -76,20 +76,20 @@ public void draw(OrthographicCamera worldCamera, Batch batch){ worldCamera.position.set(origCameraPos.scl(layer.getParallaxRatio()),cachedPos.z); worldCamera.update(); batch.setProjectionMatrix(worldCamera.combined); - float currentX = (layer.getTileModeX().equals(TileMode.single)?0:((int)((worldCamera.position.x-worldCamera.viewportWidth*.5f*worldCamera.zoom) / layer.getWidth())) * layer.getWidth())-(Math.abs((1-layer.getParallaxRatio().x)%1)*worldCamera.viewportWidth*.5f); + float currentX = (layer.getTileModeX().equals(TileMode.single)?0:((int)((worldCamera.position.x-worldCamera.viewportWidth*.5f*worldCamera.zoom) / layer.getWidth())) * layer.getWidth())-(Math.abs((1-layer.getParallaxRatio().x)%1)*worldCamera.viewportWidth*.5f) - layer.getWidth(); do{ - float currentY = (layer.getTileModeY().equals(TileMode.single)?0:((int)((worldCamera.position.y-worldCamera.viewportHeight*.5f*worldCamera.zoom) / layer.getHeight())) * layer.getHeight())-(((1-layer.getParallaxRatio().y)%1)*worldCamera.viewportHeight*.5f); + float currentY = (layer.getTileModeY().equals(TileMode.single)?0:((int)((worldCamera.position.y-worldCamera.viewportHeight*.5f*worldCamera.zoom) / layer.getHeight())) * layer.getHeight())-(((1-layer.getParallaxRatio().y)%1)*worldCamera.viewportHeight*.5f) - layer.getHeight(); do{ if(!((worldCamera.position.x-worldCamera.viewportWidth*worldCamera.zoom*.5f>currentX+layer.getWidth())||(worldCamera.position.x+worldCamera.viewportWidth*worldCamera.zoom*.5fcurrentY+layer.getHeight())||(worldCamera.position.y+worldCamera.viewportHeight*worldCamera.zoom*.5f