使用LibGdx JSONdevise一个无closures的运行游戏

我正在研究一个没有结果的跑步游戏,在移动背景的过程中,障碍物被放置在路上。 我在游戏中有很多关卡,并且正在使用JSON来实现它。

我的第一级JSON文件是这样的:

"obstacles": [ {"name":"rock","position":"middle","distance":"1000","speed":"350"}, {"name":"crow","position":"up","distance":"1600","speed":"350"}, {"name":"gap","position":"down","distance":"1600","speed":"350"}, {"name":"monkey","position":"middle","distance":"2200","speed":"350"}, {"name":"fish2","position":"down","distance":"2400","speed":"350"}, {"name":"crow","position":"up","distance":"2600","speed":"350"}, {"name":"snake","position":"up","distance":"3400","speed":"350"}, {"name":"fish","position":"down","distance":"3400","speed":"350"}, {"name":"fish2","position":"down","distance":"4400","speed":"350"}, {"name":"monkey","position":"middle","distance":"5500","speed":"350"}, {"name":"rock","position":"middle","distance":"6500","speed":"350"}, {"name":"fish","position":"down","distance":"6500","speed":"350"}, {"name":"cloud","position":"up","distance":"7200","speed":"350"}, {"name":"rock","position":"middle","distance":"8000","speed":"350"}, {"name":"gap","position":"down","distance":"8000","speed":"350"}, {"name":"snake","position":"up","distance":"8700","speed":"350"} ] 

在这里,我正在将移动视差背景上的障碍物放置到8700的x位置。

Level1工作正常,但我的问题是,我应该如何放置下一级障碍。我只有一个方法,8700之后,我必须select放置下一级障碍。

在这里我想澄清一件事情,当我使用这样的更大的值时,它会成为一个问题吗?

在我的项目中有超过20级的计划,每个级别完成后自动加载。

我希望有经验的人提出建议,devise这些方面的水平。

提前致谢。

我会以程序的方式放置对象。 在游戏中跟踪距离并尝试间隔地产生障碍物。 检查当前的行驶距离,并据此产生障碍物。 也许在一本字典中有特定水平的障碍,其中关键是产生障碍的最小距离

如果这是一个无尽的跑步游戏,那么devise所有关卡都是没有意义的。 也许devise第一个1000米作为教程,并在它之后使用一些程序生成下一个对象的方式。 当你越走越短的时间间隔,pe

无论如何,如果你想用json的方式去你可以试试看:

 "level1": [ {"name":"rock","position":"middle","distance":"1000","speed":"350"}, {"name":"crow","position":"up","distance":"1600","speed":"350"}, {"name":"gap","position":"down","distance":"1600","speed":"350"}], "level2":[ {"name":"cat","position":"middle","distance":"500","speed":"350"}, {"name":"gap","position":"up","distance":"1500","speed":"350"}, {"name":"rock","position":"down","distance":"1700","speed":"350"}] 

在产生障碍的时刻,乘以当前的距离。 这会使你的json更具可读性。