LibGDX节奏游戏 - 同步相机的速度与音乐

LibGDX节奏游戏 - 同步相机的速度与音乐

问题描述:

您好我正在开发Android上的LibGDX类节奏游戏。在游戏中,当“形状”处于黑色方块时,您必须单击特定按钮。我需要将相机速度与音乐同步。我是以60/61 FPS定时相机速度,但是当帧速下降音乐脱臼时。LibGDX节奏游戏 - 同步相机的速度与音乐

My Game

每个“形状”具有存储在currentVelocity变量时“形状”是接近黑色正方形速度可变。

Move方法:

switch (currentDirection) { 
     case UP: 
      camera.position.y += currentVelocity; 
      for (Actor uiComponent : stage.getActors()) { 
       if (!(uiComponent instanceof ShapeObject)) { 
        uiComponent.setY(uiComponent.getY() + currentVelocity); 
       } 
      } 
      break; 
     case DOWN: 
      camera.position.y -= currentVelocity; 
      for (Actor uiComponent : stage.getActors()) { 
       if (!(uiComponent instanceof ShapeObject)) { 
        uiComponent.setY(uiComponent.getY() - currentVelocity); 
       } 
      } 
      break; 
     case RIGHT: 
      camera.position.x += currentVelocity; 
      for (Actor uiComponent : stage.getActors()) { 
       if (!(uiComponent instanceof ShapeObject)) { 
        uiComponent.setX(uiComponent.getX() + currentVelocity); 
       } 
      } 
      break; 
     case LEFT: 
      camera.position.x -= currentVelocity; 
      for (Actor uiComponent : stage.getActors()) { 
       if (!(uiComponent instanceof ShapeObject)) { 
        uiComponent.setX(uiComponent.getX() - currentVelocity); 
       } 
      } 
      break; 
    } 

我知道,你必须用BPM计算的话,但我不知道该怎么做。为了分析BPM,我使用了MixMeister BPM分析器。

我迷路了:)谢谢你的回复。

我找到了解决办法,问题是其他地方:

currentVelocity = shapes.get(currentShapeIndex).getVelocity() + Gdx.graphics.getDeltaTime 

如果你想单独移动对象:

currentVelocity = shapes.get(currentShapeIndex).getVelocity() * Gdx.graphics.getDeltaTime