【问题标题】:libGDX: Move an object up and down in a smooth waylibGDX:以平滑的方式上下移动对象
【发布时间】:2018-01-22 14:39:06
【问题描述】:

我想平稳地上下移动一个对象。这是一个游戏结束屏幕,其中“继续”按钮沿着平滑的路径上下移动。 我没有任何代码要显示,因为它基本上只是关于原理。

感谢您提供有用的答案!

【问题讨论】:

    标签: object animation path libgdx


    【解决方案1】:

    使用Scene2D库和Actions,它会给你很多可能性。简单例子:

    Button continueButton = // ... initialize the button
    
    float pathY = 100;
    float duration = 3f;
    continueButton.addAction(
            Actions.forever(
                    Actions.sequence(
                            Actions.moveBy(0f, pathY, duration),
                            Actions.moveBy(0f, -pathY, duration)
                    )
            )
    );
    

    有关更多信息,请阅读 LibGDX wiki:

    https://github.com/libgdx/libgdx/wiki/Scene2d,

    https://github.com/libgdx/libgdx/wiki/Actions,

    https://github.com/libgdx/libgdx/wiki/Interpolation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      • 1970-01-01
      相关资源
      最近更新 更多