如何在SuperJUmper Game中实现Parallax屏幕?

时间:2012-02-29 08:24:26

标签: android libgdx

请任何人协助我在超级跳投游戏中实施视差屏幕,因为我无法实现这一点。我见过ParallaxTest.java 你的代码,但我无法实现它。我在一个类(ParallaxTest.java)中编写相同的代码并且只编写parallaxCamera类,在WorldRenderer中我实现as但是产生空指针异常。

代码:

  public void renderBackground()
   {
  // background layer, no parallax, centered around origin
 bath1.setProjectionMatrix(ParallaxCam.calculateParallaxMatrix(1, 1));

bath1.disableBlending();
bath1.begin();
bath1.draw(Assets.mainbackgroundRegion,ParallaxCam.position.x - FRUSTUM_WIDTH / 2,         ParallaxCam.position.y - FRUSTUM_HEIGHT/2, FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
bath1.end();
渲染器中的

---

if(ParallaxCam.position.y<FRUSTUM_HEIGHT)
{
ParallaxCam.position.y=FRUSTUM_HEIGHT;
//updateCamera = true;
}

And in constructr of WorldRendere--

this.ParallaxCam = new MyParallaxTest().new ParallaxCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
 mcontroller = new OrthoCamController(this.ParallaxCam);
Gdx.input.setInputProcessor(mcontroller);
}

1 个答案:

答案 0 :(得分:3)