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中不 ...
随机推荐
- Golang两种执行流程以及区别
Go语言的执行方式有两种,一种是编译后再执行,另一种直接go run执行. 一.先编译后执行 .go文件(源代码)--->go build指令把源代码编译(如果是windows下会编译出一个.e ...
- fjwc2019
机房搬迁.......再加上文化课.......咕了十几天才有空补上....... day0听一个教授讲理论......在学长的带领下咕掉了..... D1 T1:#178. 「2019冬令营提高组」 ...
- tomcat日志警告WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did not find a matching property.
日志中有警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did ...
- oracle 12c多租户下的日常操作变化
Oracle 12c创建用户时出现“ORA-65096: invalid common user or role name”的错误 在oracle中,引入了多租户概念,以前是一个instance对应一 ...
- Mac下Homebrew的安装与使用
Homebrew简介,安装与使用 简介 Homebrew 官方网站 Homebrew是一个包管理器,用于安装Apple没有预装但你需要的UNIX工具.(比如著名的wget). Homebrew会将软件 ...
- 前端 --- 7 Bootstrop框架
一.基本结构 1.下载地址 官方地址:https://getbootstrap.com 中文地址:http://www.bootcss.com/ 2.HTML基本搭建结构 <!DOCTYPE ...
- C# 反射小结
废话不多说,直接上代码. 1.typeof(类名):它是一个运算符 eg_1:Type type = typeof(int) ; eg_2:public class Student { Type ty ...
- Python3基础 response.read 输出网页的源代码
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 内核中的xenfs是什么?
答: 是一个xen虚拟机高性能搜索文件系统,它基于共享内存通信协议和共享缓冲区缓存.
- 【Dalston】【第一章】 服务治理(Eureka)
Spring Cloud是一系列框架的集合,其基于Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,构建了服务治理(发现注册).配置中心.消息总线.负载均衡.断路器.数据监控.分 ...