2
我有從左到右滾動的雲層。我正在使用OrthographicCamera來做到這一點。我想知道,我將如何調整這些雲層以便讓它們朝着屏幕移動,而不是從左到右移動?我還可以使用Orthographic相機嗎?我將如何做到這一點?側面滾動雲彩
我的代碼如下:
public void create() {
sky = new SkyFlux();
//getting the height and width for setup purposes
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
//setting up camera and batch
camera = new OrthographicCamera(1, h/w);
//setting up sky
for(Texture texture:sky.getTexture())
textures.add(texture);
//Adding the sky related sprites
for(Sprite sprite:sky.getSprite())
skySprites.add(sprite);
}
public void render() {
//clearing everything out
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
time += Gdx.graphics.getDeltaTime();
if(time > 1.0f)
time = 0.0f;
float speed = 1.0f;
//Adjusting the speed of the sprites except the first sprite which is the base image.
for(int i=1;i<skySprites.size();i++) {
skySprites.get(i).setV(time+speed);
skySprites.get(i).setV2(time);
speed = speed+1.0f;
}
//setting up
batch.setProjectionMatrix(camera.combined);
//begging draw
batch.begin();
//items to be drawn
//TODO: add other items to be drawn here
for(Sprite sprite:skySprites)
sprite.draw(batch);
//ending draw
batch.end();
}
嗯,好的。你會建議哪種類型的相機? ProjectionViewportCamera?等距?或透視? – BigBug
我已經使用過'libgdx',ProjectionViewportCamera(即使是2D煙霧等最小3D元素的遊戲),所以我建議。 –
好的。謝謝 – BigBug