简体   繁体   English

加载游戏位图:最佳做法

[英]Loading game bitmaps: best practice

Suppose we have a game with multiple scenes like menu, level menu etc. What is a better practice to implement when loading the game's bitmaps in memory? 假设我们有一个具有多个场景的游戏,例如菜单,关卡菜单等。将游戏的位图加载到内存中时,有什么更好的实践方法?

  1. Load only the current scene's bitmaps, and then unload them dynamically when changing to another scene (can cause glitches when changing since the unload/load process takes time). 仅加载当前场景的位图,然后在更改为另一个场景时动态地将其卸载(更改时可能会导致毛刺,因为卸载/加载过程需要时间)。
  2. Load all bitmaps at the start of the game and unload them all when the game is closed (can cause out of memory errors, since there can be many bitmaps). 在游戏开始时加载所有位图,并在游戏关闭时将其全部卸载(这可能会导致内存不足错误,因为可能会有很多位图)。

What is considered best? 什么才是最好的? Thanks for your answers. 感谢您的回答。

Most common approach i see is: 我看到的最常见的方法是:

All non actual game related graphics get loaded on start(this is menu, level select, high score and options) 开始时会加载所有与游戏无关的图形(这是菜单,级别选择,高分和选项)

And when a level is selected start loading those graphics, unload the ones you won't be needing for the next level. 然后,选择一个级别开始加载这些图形时,请卸载下一个级别不需要的图形。

Unloading when the game is closed is not needed as android will clear the memory anyway if it's not being used. 无需在游戏关闭时进行卸载,因为如果不使用android,它将清除内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM