2

我有这张图片(http://imgur.com/4zxGATb)并试图让它占据整个屏幕。这是我的代码

static Texture img;
static Sprite sprite;
public static void load(){

    img = new Texture(Gdx.files.internal("menu/stick.PNG"));
    //libgdx scales it , it wont mess up
    img.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    sprite = new Sprite(img);
    sprite.flip(false, true);
    sprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}

输出仍然没有显示占满整个屏幕的简笔画。输出:http: //imgur.com/QPAUbaw

我会以错误的方式解决这个问题吗?我认为通过将精灵(将图像渲染到屏幕的对象)设置为屏幕的大小,图像也应该占据整个屏幕。

4

2 回答 2

3

像这样的东西应该工作:

batch.draw(sprite.getTexture() x, y, sprite.getWidth(), sprite.getHeight());
于 2014-07-07T00:58:04.973 回答
0

设置图像的边界。

        Image backgroundImage = new Image(Assets.loadTexture("wood.jpg"));
        backgroundImage.setBounds(0,0,screenWidth, screenHeight);
        backgroundImage.setOrigin(screenWidth/2,screenHeight/2);

看图像现在全屏

在此处输入图像描述

于 2021-04-15T00:13:51.397 回答