本文共 1196 字,大约阅读时间需要 3 分钟。
使用AssetManager类加载数据与图片
AssetManager.prototype.loadTextData = function(path, data) { var _this = this; path = this.pathPrefix + path; this.toLoad++; _this.assets[path] = data; _this.toLoad--; _this.loaded++;}; AssetManager.prototype.loadTextureData = function(path, data, success, error) { var _this = this; path = this.pathPrefix + path; this.toLoad++; var img = new Image(); img.onload = function(ev) { var texture = _this.textureLoader(img); _this.assets[path] = texture; _this.toLoad--; _this.loaded++; if (success) success(path, img); }; img.onerror = function(ev) { _this.errors[path] = "Couldn't load image " + path; _this.toLoad--; _this.loaded++; if (error) error(path, "Couldn't load image " + path); }; img.src = data;}; .atlas文件<div>标签为\,并替换\为n\.json文件// 示例代码
以上内容详细描述了如何使用AssetManager类加载不同类型的数据,包括文本和图片,并提供了具体的使用方法和示例代码。
转载地址:http://byxc.baihongyu.com/