[英]Proper use of the AssetManager class in libgdx
I am developing a platform game in libgdx in which has few levels and a player that running on the ground, very simple name. 我正在libgdx中开发一个平台游戏,该游戏中的关卡数量很少,并且有一个在地面上运行的玩家,这个名字非常简单。
I just started to use the AssetManager class and I have a question: 我刚开始使用AssetManager类,但我有一个问题:
1) Am I need to load all the tmx maps and all the atlasses at the beginning of the game (before the menu, for example). 1)我是否需要在游戏开始时加载所有tmx地图和所有地图集(例如,在菜单之前)。 Or I need to show before each level the loading screen ang load all the staff their?
还是我需要在每个级别之前显示加载屏幕和加载所有人员的界面?
2) The user can return to the menu screen at every time he want, so am I load the menu staff before the menu and only unloading them when the user quit the game? 2)用户可以根据需要随时返回菜单屏幕,那么我是否在菜单之前加载了菜单人员,并且仅在用户退出游戏时才将其卸载?
Thank for those who will help me, and sorry for my poor english. 感谢那些能帮助我的人,并为我的英语不好对不起。
It depends on how heavy your assets are. 这取决于您的资产有多沉重。
AssetManager
is a versatile class and allows you to perform loading in any order at any time. AssetManager
是通用类,可让您随时以任何顺序执行加载。 All use cases stated by you are possible to achieve using AssetManager
. 您陈述的所有用例都可以使用
AssetManager
实现。
You can load all tmx maps and all atlasses at the beginning of the game. 您可以在游戏开始时加载所有tmx地图和所有地图集。
You can also load them level wise. 您也可以按级别加载它们。
Now the question is what you should do. 现在的问题是你应该怎么做。
Same in case of menu too. 菜单也一样。 You can do both.
两者都可以。 If the menu is lightweight, you should keep it loaded.
如果菜单是轻量级的,则应保持其加载状态。 It's a good idea to have menu ready each time (at least pause menu).
每次都准备好菜单(至少是暂停菜单)是一个好主意。
Provide a loading screen for menu only if it is hard on memory. 仅在内存上有硬盘时,才为菜单提供加载屏幕。
Since you have so much freedom, you should take these decisions depending upon how would the user experience be in each case. 由于您有很大的自由度,因此应根据每种情况下的用户体验来做出这些决定。 Players don't like to be disturbed frequently by a loading screen.
玩家不希望被加载屏幕频繁打扰。 But it does not make sense to make him/her wait for loading levels they are not going to use.
但是让他/她等待将不使用的负载水平是没有意义的。
Just make sure to have the asset loaded before using it. 只需确保在使用资产之前先加载资产。 If loading code is becoming distributed, don't worry about redundant calls of
load
method. 如果加载代码正在分发,则不必担心
load
方法的冗余调用。 AssetManager
loads each asset exactly once irrespective of how many times have you asted it to load a particular asset. 无论您为资产加载了多少次资产,
AssetManager
都会精确地加载一次。
Good luck. 祝好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.