【问题标题】:how to set TextureRegion's centre point to rotate around. (libGdx)如何设置 TextureRegion 的中心点旋转。 (libGdx)
【发布时间】:2016-07-07 06:34:52
【问题描述】:

我正在尝试围绕其中心旋转 TextureRegion,但是每当我尝试旋转它时,旋转点要么是 Texture Region 的底角,要么是屏幕的远处。 这是我的对象类中的更新方法(纹理区域将模拟此对象的运动。

public void update(float delta) {

   if (velocity.x < 0) {
        rotation -= 50*delta;

        if (rotation > 25) {
            rotation = 25;
        }
    }
    if (velocity.x > 0){
        rotation += 50*delta;

        if (rotation > 25) {
            rotation = 25;
        }
    }
}

我在这里调用draw 方法将纹理区域显示在屏幕上

batcher.draw(AssetLoader.saum, sam.getX(), (gameHeight - (gameHeight / 3)), -(sam.getWidth()), (gameHeight - (gameHeight / 3)), -(sam.getWidth()), -(sam.getWidth()), 1, 1, sam.getRotation());

【问题讨论】:

    标签: java android libgdx


    【解决方案1】:

    使用具有originXoriginY 参数的batch.draw 方法之一。 originXoriginY 应设置为 width/2height/2

    See methods here.

    【讨论】:

    • 这完美!非常感谢,你救了我很多头发都掉了:)
    猜你喜欢
    • 2014-12-26
    • 2013-02-12
    • 2012-07-22
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    • 2013-07-22
    • 1970-01-01
    • 2016-01-16
    相关资源
    最近更新 更多