【问题标题】:How to rotate a Sprite around the circle in LibGDX?如何在 LibGDX 中围绕圆圈旋转 Sprite?
【发布时间】:2018-04-06 18:45:10
【问题描述】:

我想围绕一个圆圈旋转一个精灵,但我做不到。如果我不能说出我的问题,你可以从这张照片中理解:

【问题讨论】:

    标签: java libgdx image-rotation


    【解决方案1】:

    Sprite有一个方法setOrigin()https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Sprite.html#setOrigin-float-float-

    Sprite 的原点设置在圆心并旋转它。代码将如下所示:

    float circleCenterX = ...;
    float circleCenterY = ...;
    float angle = ...;
    Sprite sprite = ...;
    
    sprite.setOrigin(circleCenterX, circleCenterY);
    sprite.rotate(angle); // or sprite.setRotation(angle);
    

    【讨论】:

      猜你喜欢
      • 2019-04-25
      • 2011-10-13
      • 1970-01-01
      • 2020-10-02
      • 2018-07-01
      • 2016-12-28
      • 1970-01-01
      • 2021-07-30
      • 2016-12-25
      相关资源
      最近更新 更多