【问题标题】:Regarding Game Time in Libgdx关于 Libgdx 中的游戏时间
【发布时间】:2013-09-07 06:11:18
【问题描述】:

我有 actor Rectangle 和 powerUp Rectangle,我希望它与 actor 碰撞时有 10 秒的电源。这是通过以下方式实现的:

if (powerBoxRect.overlaps(actorRectObj)) {
    powerUpTime = System.currentTimeMillis() + 10000;
}

if (powerUpTime > System.currentTimeMillis()) {
        powerActor = IMMUNEACTOR;
    }

但是当我取电并按下暂停按钮时,我的游戏进入暂停状态,10 秒后当我恢复游戏时,由于同时系统时间正在运行,电源会丢失。 我想知道如何停止系统时间或 libgdx 提供任何其他功能来处理这种情况?

【问题讨论】:

  • 使用 libgdx 0.9.9 他们提供了时间 api

标签: android libgdx game-engine


【解决方案1】:
float time = 0;
int maxTime = 3;


public void update() {

time += Gdx.graphics.getDeltaTime();

 if(time > maxTime) {

// DO YOUR THING
 }


}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多