LibGDX - 使用精灵表时如何更改精灵的大小

时间:2014-08-19 12:27:04

标签: java libgdx sprite game-development

这是我从精灵表中获取纹理的代码。

public Player(Vector2 position, String textureLoc){
        this.position = position;

        movement="";

        playerTexture = new Texture(Gdx.files.internal(("giant-sprite.png")));
        TextureRegion[][] tmp = TextureRegion.split(playerTexture, playerTexture.getWidth() / col, playerTexture.getHeight() / row);

        frames = new TextureRegion[col*row];

        int index = 0;
        for(int i =0; i < row; i++){
            for(int j=0; j<col; j++){
                frames[index++] = tmp[i][j];
            }
        }

        animation = new Animation(1f, frames);
        stateTime = 0f;
        currentFrame = animation.getKeyFrame(0);

        bounds = new Rectangle(position.x, position.y, currentFrame.getRegionWidth(), currentFrame.getRegionHeight());
    }

如果我改变纹理区域的大小,它不会改变精灵的大小。我想知道一种在分割精灵表后改变精灵大小的方法。

有什么想法吗?

0 个答案:

没有答案