Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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
Animation 如何在libgdx中调整动画大小?_Animation_Resize_Libgdx - Fatal编程技术网

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

Animation 如何在libgdx中调整动画大小?,animation,resize,libgdx,Animation,Resize,Libgdx,我想画一个动画,每个帧的大小是500x500px,但当我尝试调整大小时,动画似乎在旋转 下面是加载帧和创建动画的代码: 纹理fireSheet=新纹理(Gdx.files.internal(“fire_sheet.png”) 在“绘制方法”中,我按以下方式调整动画的大小: public void draw(Batch batch, float parentAlpha) { batch.enableBlending(); stateTime += Gdx.

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

下面是加载帧和创建动画的代码:

纹理fireSheet=新纹理(Gdx.files.internal(“fire_sheet.png”)

在“绘制方法”中,我按以下方式调整动画的大小:

    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
如果我使用:

batch.draw(currentFrame, getX(), getY() ); // WORKS!!! But too Big for me 500x500px
batch.draw(currentFrame, getX(), getY(), 200, 200 ); // Animation doesn't work properly
我能做什么

提前感谢您

将此作为测试(假设500是您的原始纹理区域大小):batch.draw(当前帧,getX(),getY(),0,0,500,500,0.4f,0.4f,0)


Thaks to Tekkerue

我还没有测试过它,但是这个批量绘制方法有scaleX和scaleY参数,这可能会调整纹理区域:谢谢,我会试试。。。但我想以像素为单位缩放到一个确定的宽度和高度。。。所以也许ScaleX=desideredWidth/originalwidth=200/500=0,4…是的,没错。“desidered/original”应该为您提供适当的比例。我已经尝试过,但不起作用:currentFrame=Assets.fireAnimation.getKeyFrame(stateTime,true);batch.draw(currentFrame,getX(),getY(),currentFrame.getRegionWidth()/2,currentFrame.getRegionHeight()/2,currentFrame.getRegionWidth(),currentFrame.getRegionHeight(),(float)getWidth()/(float)currentFrame.getRegionWidth(),(float)getHeight()/(float)currentFrame.getRegionHeight(),getRotation());动画似乎在旋转,而不是期望的效果