TypeError: atlas.getSpriteFrame is not a function
2017-12-08 02:43
836 查看
1.资源结构如下:
2.在使用cc.loader.loadRes动态异步加载cc.SpriteAtlas资源时出现这个错误,代码如下:
2.原因是url路径不对,不应该包含resources。路径不对竟然报函数错误!
(PS:动态加载资源都必须放置在
以上。
2.在使用cc.loader.loadRes动态异步加载cc.SpriteAtlas资源时出现这个错误,代码如下:
var self = this; var url = "resources/test_atlas/atlas"; var res = cc.loader.getRes(url, cc.SpriteAtlas); cc.loader.release(res); cc.loader.loadRes(url, cc.SpriteAtlas, function (err, atlas) { cc.loader.setAutoRelease(url, true); var node = new cc.Node(); self.node.addChild(node); node.position = cc.v2(0, 0); var sprite = node.addComponent(cc.Sprite); sprite.spriteFrame = atlas.getSpriteFrame('sheep_run_0'); });
2.原因是url路径不对,不应该包含resources。路径不对竟然报函数错误!
var url = "test_atlas/atlas";
(PS:动态加载资源都必须放置在
resources文件夹或它的子文件夹下。
resources需要在 assets 文件夹中手工创建,并且必须位于 assets 的根目录下。)
以上。
相关文章推荐
- 海康web视频插件错误:TypeError: c.HWP_GetLocalConfig is not a function
- dva -react TypeError: root.findRouters(...).getRouterInfo is not a function
- js报错:TypeError: document.GetElementById is not a function
- 奇怪的TypeError: Error #1006: getInstance is not a function.
- js报错:TypeError: document.GetElementById is not a function
- Uncaught TypeError: XXX.getTime is not a function
- TypeError: record.get is not a function
- Uncaught TypeError: this.canvas.getContext is not a function
- Uncaught TypeError: UE.getEditor is not a function
- Uncaught TypeError: XXX is not a function解决
- TypeError: jQuery(...).validationEngine is not a function
- [dataTables.js error] Uncaught TypeError: myTable.row is not a function
- ajaxfileupload.js结合低版本jquery报异常:TypeError: jQuery.handleError is not a function
- Controller中错误 TypeError: $rootScope.$broadcast is not a function
- TypeError: e.indexOf is not a function解决方法
- node.js开发错误——TypeError: req.flash is not a function
- 经典错误之:TypeError: res.json is not a function
- jquery.js里面报错Uncaught TypeError: a.indexOf is not a function
- python TypeError: 'builtin_function_or_method' object is not iterable keys
- js错误:Uncaught TypeError: accept is not a function at HTMLInputElement.onclick