0

我正在尝试显示使用 Sprite 类缩放的纹理。问题是当我尝试运行我的代码时。我可以在 Android 4.1 中显示纹理,但是当我在另一个 Android 中运行相同的程序时,例如 2.2、2.3.6... Sprite 没有显示。这是我的代码。

public void render() {
    // TODO Auto-generated method stub
    Gdx.gl10.glClearColor(1, 0.4f, 0.3f, 1);
    Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT);
    if(estadojuego==0){
        batch.begin();
        sboton1.draw(batch);
        sboton2.draw(batch);
        batch.end();
        if(Gdx.input.isTouched()){
            System.out.println("x"+Gdx.input.getX());
            System.out.println("y"+Gdx.input.getY());
            if(Gdx.input.getY()<(altura-posicion1.y) && Gdx.input.getY()>(altura-(posicion1.y+posicion1.height))){
                if(Gdx.input.getX()<(posicion1.x+posicion1.width) && Gdx.input.getX()>posicion1.x){
                    //estadojuego=1;
                    System.out.println("boton1");
                }
                if(Gdx.input.getX()<(posicion2.x+posicion2.width) && Gdx.input.getX()>posicion2.x){
                    estadojuego=2;
                }
            }
        }
    }
    if(estadojuego==2){
        batch.begin();
        sboton3.draw(batch);
        batch.end();
        if(Gdx.input.isTouched()){
            if(Gdx.input.getY()<(altura-posicion3.y) && Gdx.input.getY()>(altura-(posicion3.y+posicion3.height))){
                if(Gdx.input.getX()<(posicion3.x+posicion3.width) && Gdx.input.getX()>posicion3.x){
                    estadojuego=0;
                }
            }
        }
    }
}

非常感谢,很抱歉我的英语不好。

4

1 回答 1

0

好像您没有为您的批次设置Matrix4

用这个 :

private Matrix4 Projection;

create()中:

Projection = new Matrix4().setToOrtho2D(0, 0, (float) Gdx.graphics.getWidth(), (float) Gdx.graphics.getHeight());

在batch.begin( )之前的 render() 中;

batch.setProjectionMatrix(Projection);

我希望这会帮助你。

于 2013-05-26T06:01:45.833 回答