4.1) 如何管理成千上百的资源
在游戏开发的过程中,很有可能会有成千上百张图片。最直接的方式,是将这些图片编写在代码中,但是图片的名字很容易改变的,会造成大量的维护工作,甚至影响代码的打包和发布。我的同事Boris,在他的代码演示库中,给出了一个参考实现方式,如下。这种方式,可以保证,在需要修改或者调整资源名称或者路径的时候,不需要接触代码。
{
"assetRoot": "url/to/assets",
"bundles": [
{
"name": "unique bundle name",
"contents": [
"relative/path/to/asset.jpg",
"another/asset.mp3"
]
},
"autoDownload": true
}
var gal = new GameAssetLoader("http://path.to/gal.manifest");
// Load the GAL. If manifest indicates autoDownload, this call will
// start loading assets one by one.
gal.init(function() {
// Called when the library is initialized
});
查看更多关于HTML5游戏开发之资源加载篇(2)的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did69478