本文介绍了实时游戏开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用libgdx开发适用于Android的实时游戏.即使游戏未运行,我也需要更新一些变量.

I want to develop a real time game for Android with libgdx. I need to update some variables even dough the game is not running.

例如,我希望每小时增加10个信用额度(现实生活时间),以便您可以退出游戏并在一个小时后回来并获得该笔款项.

For example I want the money to be increased 10 credits per hour (real life hour) so that you can go out of the game and come back an hour later and get that money anyway.

我该怎么做?

谢谢

推荐答案

实时,无需设置您自己的服务器.只需使用公共时间服务器之一即可.从 ntp网站下载NtpMessage.java和SntpClient.java.然后使用ntp端口运行SntpClient.java.例如

For real time, no need to setup your own server. Just use one of the public time server. Download NtpMessage.java and SntpClient.java from ntp site. Then run SntpClient.java with a ntp port. e.g.

您可以使用SntpClient类的代码,并根据需要进行调整.

You can use the code of SntpClient class and tweak if you need to.

当用户退出游戏(暂停状态)时,请从ntp获取时间并保存.用户启动游戏后,请重新获得时间并进行比较.

When user gets out of game (pause state), get the time from ntp and save it. Once the user launches your game, get the time again and compare.

这篇关于实时游戏开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-09 07:52