SpriteBuilder中CCMotionStreak提示图片文件找不到
来源:互联网 发布:淘宝上怎么投诉店铺 编辑:程序博客网 时间:2024/06/08 15:10
今天写代码时遇到上述问题,代码如下:
player.streak = [CCMotionStreak streakWithFade:3.f minSeg:1 width:30 color:[CCColor whiteColor] textureFilename:@"ccbResources/ccbParticleSnow.png"];
运行出错,console中显示png路径不存在.
路径肯定是正确的.而且其他使用该图片的方法工作正常.
于是找到该方法:
CCSpriteFrame *frame = [CCSpriteFrame frameWithImageNamed:@"ccbResources/ccbParticleSnow.png"];
做断点,运行后进入该方法:
+(instancetype) frameWithImageNamed:(NSString*)imageName{ CCSpriteFrame* frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:imageName]; if (!frame) { CCTexture* texture = [[CCTextureCache sharedTextureCache] addImage:imageName]; frame = [texture createSpriteFrame]; } return frame;}
发现并没有实际搜索磁盘上的文件,而是使用精灵帧缓存中的图片.所以有了下面变通的写法:
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"ccbResources/ccbParticleSnow.png"]; player.streak = [CCMotionStreak streakWithFade:3.f minSeg:1 width:30 color:[CCColor whiteColor] texture:frame.texture];
这样就可以了.
0 0
- SpriteBuilder中CCMotionStreak提示图片文件找不到
- SpriteBuilder中CCMotionStreak坐标类型不匹配
- SpriteBuilder中应用智能精灵集之后提示找不到文件的解决
- 打开图片文件时提示:windows找不到文件..........
- 提示找不到so文件
- SpriteBuilder中关于大量CCB文件的数字命名建议
- centos5中提示找不到mysql.h头文件
- 在项目中提示找不到Box2D.h头文件
- shell脚本文件中ll提示找不到命令
- tomcat 提示 JSP 文件找不到
- Delphi 提示找不到 dcu文件
- javah提示找不到类文件
- 输入./boa提示找不到文件
- javah提示找不到类文件
- 【解决方案】Android图片加载中drawable等图片资源报错,提示找不到该资源
- servlet图片文件上传中找不到文件位置和图片上传失败的原因
- SpriteBuilder中本地化的局限性
- JNI中javah -jni编辑.class文件提示找不到类文件
- Tomcat8使用数据源的三种方式
- 智能提示(三)facet 聚合属性(类别、标签)提示
- 定时任务 Crontab命令 详解
- 中文编码规则一网打尽
- java jar文件的制作方法
- SpriteBuilder中CCMotionStreak提示图片文件找不到
- location.href、parent.location.href、top.location.href、 window.open
- 网站统计中的数据收集原理及实现
- framebuffer开发有我想象的那么简单吗
- OPENWRT-4G-移植-ALT3800
- Codeforces Round #323 (Div. 2) B. Robot's Task(模拟)
- CentOS安装nvidia显卡驱动的正确方法
- 关于用mapreduce做kmeans聚类以及python的numpy和list做矩阵、向量乘法的速度对比
- [Java 程序员]成为优秀Java程序员的10个要点