这是andengine的autoparallaxbackgroundexample代码 - 我希望在运行时改变视差背景的速度,就像像jetpack兜风这样的免费游戏......
代码的链接是 - AutoParallaxBackgroundExample.java
设置背景的速度和位置的行是 -
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerBack.getHeight(), this.mParallaxLayerBack)));
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-5.0f, new Sprite(0, 80, this.mParallaxLayerMid)));
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-10.0f, new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerFront.getHeight(), this.mParallaxLayerFront)));
scene.setBackground(autoParallaxBackground);
我需要更改-5.0f值,使其在游戏运行后经过一段固定的时间后递增..
答案 0 :(得分:0)
尝试以下方法:
public void setParallaxChangePerSecond(final float pParallaxChangePerSecond)