Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 侧卷云_Java_Android_Android Emulator_Libgdx - Fatal编程技术网

Java 侧卷云

Java 侧卷云,java,android,android-emulator,libgdx,Java,Android,Android Emulator,Libgdx,我有从左向右滚动的云。我用的是正交摄影机。我在想,我该如何调整这些云,使它们朝着屏幕移动,而不是从左到右?我还能用正射相机吗?我该怎么做 我的代码如下: public void create() { sky = new SkyFlux(); //getting the height and width for setup purposes float w = Gdx.graphics.getWidth(); float h

我有从左向右滚动的云。我用的是正交摄影机。我在想,我该如何调整这些云,使它们朝着屏幕移动,而不是从左到右?我还能用正射相机吗?我该怎么做

我的代码如下:

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();
}
public void create(){
天空=新的天空通量();
//获取用于设置的高度和宽度
float w=Gdx.graphics.getWidth();
float h=Gdx.graphics.getHeight();
//设置摄影机和批处理
摄像机=新的正交摄像机(1,高/宽);
//架起天空
对于(纹理:sky.getTexture())
纹理。添加(纹理);
//添加与天空相关的精灵
for(精灵精灵:sky.getSprite())
天空精灵。添加(精灵);
}
公共无效呈现(){
//清理一切
Gdx.gl.glClearColor(1,1,1,1);
Gdx.gl.glClear(GL10.gl_颜色_缓冲_位| GL10.gl_深度_缓冲_位);
time+=Gdx.graphics.getDeltaTime();
如果(时间>1.0f)
时间=0.0f;
浮动速度=1.0f;
//调整精灵的速度,但第一个精灵是基础图像。

对于(int i=1;i正交投影,根据定义,不存储深度信息。唯一可以使云彩出现在屏幕上的方法是增加精灵大小,但我建议不要这样做


您应该使用非正交投影,只使用z轴。

Hmm,好的。您建议使用哪种类型的相机?ProjectionViewportCamera?等轴测?还是透视?我以前使用过ProjectionViewportCamera(即使是带有最小3d元素的2d游戏,如烟雾等),所以我建议使用。