TypeError: atlas.getSpriteFrame is not a function
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的更多相关文章
- TypeError: window.open is not a function
想必大家现在都已经到家了,而苦逼的我还要坐在办公室混拿微薄的工资,技不如人,平常不努力给自己充电,年终一毛钱都没多给.不说这扫兴的话题了,在这给同样在苦逼坚守岗位的同志们节日的问候,新的一年,好运连连 ...
- Meteor错误:TypeError: Meteor.userId is not a function
问题描述: 浏览器console提示错误TypeError: Meteor.userId is not a function. 原因分析: 通过查看Meteor API文档,可知该函数由包accoun ...
- extjs之TypeError: d.read is not a function解决方案
在创建如下代码时报出此错:TypeError: d.read is not a function Ext.define('shebyxgl_sheb_model', { extend: 'Ext.da ...
- TypeError: value.getTime is not a function (elementUI报错转载 )
"TypeError: value.getTime is not a function" 2018年07月02日 16:41:24 leeleejoker 阅读数:2091 标签: ...
- TypeError: Buffer.alloc is not a function
错误信息:TypeError: Buffer.alloc is not a function 截图如下: 解决办法(依次从上往下执行): sudo npm cache clean -f sudo np ...
- 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 ...
- Uncaught TypeError: (intermediate value)(...) is not a function 上一个方法结束没有加分号; 代码解析报错
Uncaught TypeError: (intermediate value)(...) is not a function 别忽略了, 第一个方法后面的结束 分号; 不起眼的,引来麻烦, 哎,规 ...
- 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 ...
- JQuery中button提交表单报TypeError: elem[type] is not a function jquery
错误: TypeError: elem[type] is not a function jquery 解决: 出现这种现象的原因是,提交的表单中,有标签的name,有以submit命名的 name中不 ...
随机推荐
- yii2项目中运行composer 过程中遇到的问题
问题1: Your requirements could not be resolved to an installable set of packages 则表明 未安装fxp/composer-a ...
- daemon进程fork一次和fork两次的区别?
守护进程也称为精灵进程(Daemon),是运行在后台的一种特殊的进程.它独立于控制终端并且周期性的执行某种任务负等待处理某些发生的事件.因为他们没有控制终端,所以说他们是在后台运行的. 守护进程的特点 ...
- Android之xml解析
利用类下载器解析Xml文件要解析的xml文件<?xml version="1.0" encoding="utf-8"?><info> & ...
- opencv学习之路(4)、Mat类介绍,基本绘图函数
一.Mat类创建 Mat img;//创建无初始化矩阵 Mat img1(,,CV_8UC1);//200行,100列(长200,宽100) Mat img2(Size(,),CV_8UC3,Scal ...
- hdu 1394 Minimum Inversion Number - 树状数组
The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that ...
- 2018年11月20日 远交近攻 list1
list 列表用法 li=[1,2,3,"abc"] #列表中的元素,可以为数字或者字符串或者布尔值或者就是列表等,所有都能放进去 #列表中也能嵌套列表 pi=[1,2,3,[2, ...
- A>B等CSS选择器
这些是CSS3特有的选择器,A>B 表示选择A元素的所有子B元素.与A B的区别在于,A B选择所有后代元素,而A>B只选择一代.另外:没有<的用法. A+B表示HTML中紧随A的B ...
- SQL 基础语法笔记教程整理
最近从图书馆借了本介绍 SQL 的书,打算复习一下基本语法,记录一下笔记,整理一下思路,以备日后复习之用. PS:本文适用 SQL Server2008 语法. 首先,附一个发现的 MySQL 读书笔 ...
- bzoj1566: [NOI2009]管道取珠 DP
题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=1566 思路 n个球,第i个球颜色为ai,对于颜色j,对答案的贡献为颜色为j的球的个数的平 ...
- 逆波兰表达式|2013年蓝桥杯A组题解析第六题-fishers
逆波兰表达式 正常的表达式称为中缀表达式,运算符在中间,主要是给人阅读的,机器求解并不方便. 例如:3 + 5 * (2 + 6) - 1 而且,常常需要用括号来改变运算次序. 相反,如果使用逆波兰表 ...