Using Parallax screen

前端 未结 1 1961
庸人自扰
庸人自扰 2021-01-22 10:47

I want to use parallax screen in my game code using libgdx in which screen is moving in y direction. My game code is given as...

   public class ParallaxLayer{
          


        
相关标签:
1条回答
  • 2021-01-22 11:25
    ParallaxBackground rbg = new ParallaxBackground(new ParallaxLayer[]{
                new ParallaxLayer(bgRegion,new Vector2(),new Vector2(0, 0)),
                new ParallaxLayer(bgRegion2,new Vector2(1.0f,1.0f),new Vector2(0, 500)),
                new ParallaxLayer(bgRegion3,new Vector2(0.1f,0),new Vector2(0,480),new Vector2(0, 0)),
        }, 480, 800, new Vector2(0,350)); 
    

    }

    if u read the documentation of this class u find that the last parameter is the relative velocity ratio and u passed 0 in y. u need to pass some other value than it

    i am giving another sample of my game

       new ParallaxLayer(Assets.backgroundSprite, new Vector2(0, 0), new Vector2(0, 200000)), 
           new ParallaxLayer(Assets.clouds, new Vector2(0, 0.05f), new Vector2(0, 440), new Vector2(0, 200000)),
            new ParallaxLayer(Assets.cloud1, new Vector2(0.4f, 0), new Vector2(240, 750), new Vector2(1000, 200000)), 
            new ParallaxLayer(Assets.cloud2, new Vector2(0.06f, 0), new Vector2(40, 600), new Vector2(500, 200000)),
            new ParallaxLayer(Assets.cloud1, new Vector2(0.5f, 0), new Vector2(700, 680), new Vector2(1500, 200000)), 
    

    hope it helps u out

    0 讨论(0)
提交回复
热议问题