如何在libgdx中调整动画大小?

时间:2015-03-17 21:09:16

标签: animation resize libgdx

我想绘制一个动画,每帧的大小是500x500px,但是当我尝试调整大小时,动画似乎会旋转......

这里是加载帧和创建动画的代码:

纹理fireSheet = new Texture(Gdx.files.internal(“fire_sheet.png”));

    TextureRegion[] fireFrames = new TextureRegion[4];

    fireFrames[0] = new TextureRegion(fireSheet,0,0,500,500);
    fireFrames[1] = new TextureRegion(fireSheet,700,0,1200,500);
    fireFrames[2] = new TextureRegion(fireSheet,1450,0,1950,500);
    fireFrames[3] = new TextureRegion(fireSheet,2250,0,2750,500);


    fireAnimation = new Animation(0.5f, fireFrames);

在绘制方法中,我以这种方式调整动画的大小:

    public void draw(Batch batch, float parentAlpha) {

        batch.enableBlending();
        stateTime += Gdx.graphics.getDeltaTime();

        currentFrame = Assets.fireAnimation.getKeyFrame(stateTime, true);

        batch.draw(currentFrame, getX(), getY(), 200, 200 );

    }

所以,如果我使用:

batch.draw(currentFrame, getX(), getY() ); // WORKS!!! But too Big for me 500x500px

相反,如果我使用:

batch.draw(currentFrame, getX(), getY(), 200, 200 ); // Animation doesn't work properly

我该怎么办?

提前谢谢

1 个答案:

答案 0 :(得分:0)

尝试将此作为测试(假设500是您原始的TextureRegion大小):batch.draw(currentFrame,getX(),getY(),0,0,500,500,1.4f,0.4f,0); < / p>

Thaks to Tekkerue