1.资源结构如下:

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 的根目录下。)

以上。

TypeError: atlas.getSpriteFrame is not a function的更多相关文章

  1. TypeError: window.open is not a function

    想必大家现在都已经到家了,而苦逼的我还要坐在办公室混拿微薄的工资,技不如人,平常不努力给自己充电,年终一毛钱都没多给.不说这扫兴的话题了,在这给同样在苦逼坚守岗位的同志们节日的问候,新的一年,好运连连 ...

  2. Meteor错误:TypeError: Meteor.userId is not a function

    问题描述: 浏览器console提示错误TypeError: Meteor.userId is not a function. 原因分析: 通过查看Meteor API文档,可知该函数由包accoun ...

  3. extjs之TypeError: d.read is not a function解决方案

    在创建如下代码时报出此错:TypeError: d.read is not a function Ext.define('shebyxgl_sheb_model', { extend: 'Ext.da ...

  4. TypeError: value.getTime is not a function (elementUI报错转载 )

    "TypeError: value.getTime is not a function" 2018年07月02日 16:41:24 leeleejoker 阅读数:2091 标签: ...

  5. TypeError: Buffer.alloc is not a function

    错误信息:TypeError: Buffer.alloc is not a function 截图如下: 解决办法(依次从上往下执行): sudo npm cache clean -f sudo np ...

  6. jquery.js 3.0报错, Uncaught TypeError: url.indexOf is not a function

    转载自:http://majing.io/questions/432   问题描述 jQuery升级到3.0.0后类型错误 jquery.js:9612 Uncaught TypeError: url ...

  7. Uncaught TypeError: (intermediate value)(...) is not a function 上一个方法结束没有加分号; 代码解析报错

    Uncaught TypeError: (intermediate value)(...) is not a function 别忽略了,  第一个方法后面的结束 分号; 不起眼的,引来麻烦, 哎,规 ...

  8. jquery3.1.1报错Uncaught TypeError: a.indexOf is not a function

    jquery3.1.1报错Uncaught TypeError: a.indexOf is not a function 使用1.9就没有问题,解决办法: 就是把写的代码中: $(window).lo ...

  9. JQuery中button提交表单报TypeError: elem[type] is not a function jquery

    错误: TypeError: elem[type] is not a function jquery 解决: 出现这种现象的原因是,提交的表单中,有标签的name,有以submit命名的 name中不 ...

随机推荐

  1. php 获取文件后缀

    /** * 获取文件后缀 * $path 本地存储临时文件路径 * */ private function getFileType($path){ $fp=fopen($path,'r'); $bin ...

  2. js输出

    JavaScript 可以通过4种不同的方式在html页面输出数据 1.使用window.alert() 弹出警告框,由于window为js的内置类,可简写为alter() <script> ...

  3. GitHub使用笔记1:git客户端配置多ssh key

    公司用gitlab 外网的github同时配置 这样就导致我们要配置不同的ssh-key对应不同的环境. 具体操作步骤如下: 1:生成一个公司用的SSH-Key $ ssh-keygen -t rsa ...

  4. devexpress 10.0升级为 15

  5. openvpn server setup

    Set Up an OpenVPN Server client access 内部环境搭建

  6. Springbooot +Mybaties 配置数据库多数据源

    前言 在实际项目中,我们可能会碰到在一个项目中会访问多个数据库的情况.针对这种情况,我们就需要配置动态的数据源了.一般按照以下步骤即可 一.在启动类上添加注解 二.在application.prope ...

  7. Plantuml画图工具

    1,Plantuml画图工具 安装指南: Mac sublimetext http://blog.csdn.net/zhangjikuan/article/details/53365730 win i ...

  8. Web开发中B/S架构和C/S架构的区别

    在web开发中有两种基本架构,即C/S架构和B/S架构那么这两种架构有什么区别呢?那么就一起来看看吧. C/S架构图: B/S架构图: C/S架构是 浏览/服务器端的交互,是早期的一种分布式架构,在该 ...

  9. vim使用跳转列表 jumps 来跟踪 (历史位置的)导航

    参考: Vim使用跳转列表来跟踪你的导航,你可以通过这个列表来向前或者向后导航. 跳转列表保留所有地方的轨迹,它可以跟踪文件名.行号和列号. 查看调整列表::jumps 导航键 描述 CTRL-o 跳 ...

  10. [Sdoi2017]序列计数 矩阵优化dp

    题目 https://www.lydsy.com/JudgeOnline/problem.php?id=4818 思路 先考虑没有质数限制 dp是在同余系下的,所以\(f[i][j]\)表示前i个点, ...