我正在开发一款实时多人游戏,玩家可以通过bluetooth.Device A连接他们的设备到设备B(反之亦然)。这个游戏有一个倒计时时钟。我很难让两个玩家同时开始玩游戏。这是由于蓝牙延迟造成的。这个延迟时间从几毫秒到1到2秒不等。
我应该采取什么方法来解决这个问题呢?
现在,我有以下过程:
- player A and player B are connected through bluetooth
- Player A goes into "ready" state by pressing the ready button.
- message gets send to player B informing that player A is ready
- Player B goes into "ready" state by pressing the ready button.
- message gets send to player A informing that player B is ready.**
- when both players ready, the count down begins.**由于到达玩家A的“就绪”消息稍有延迟,所以B的倒计时已经开始,因为它只需要更新一个本地状态变量。
发布于 2014-10-17 18:59:12
如果两个设备时钟都与相同的网络源同步,您可以让它们在未来明确的时间内完成倒计时,而不是尝试“相对于现在”执行"x秒“。大多数设备自动与相同的网络时间同步。
https://stackoverflow.com/questions/26431578
复制相似问题