在libgdx中以不同的速度移动两个摄像头

时间:2013-06-27 04:23:13

标签: java android camera box2d libgdx

我可以使用box2D在libgdx中移动单个相机。但是我在游戏中有三个不同的背景层,想要以x速度移动layer1,以2x速度移动layer2,以3x速度移动layer3。目前我这样做:

camera.position.x =ActorBody.getPosition().x;

但是在这种情况下,当我的演员向前移动时,我的相机也会移动。我如何使用2或3个相机,还是有更多的方式以更优化的方式做到这一点?

1 个答案:

答案 0 :(得分:2)

使用parrallaxlayer和parrallaxBackground类

在你的演员的parrallax层传递速度为比率

期间
https://code.google.com/p/libgdx-users/wiki/ParallaxBackgound

https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/ParallaxTest.java