我有从左到右滚动的云。我正在使用 OrthographicCamera 这样做。我想知道,我将如何调整这些云以使它们朝向屏幕移动,而不是从左到右?我还可以使用正交相机吗?我该怎么做?
我的代码如下:
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();
}