cocos 所有文件路径 的斜杠 必须 用 / 而不可以用 \

不然编译到安卓各种坑

相对路径 第一个字符不可 带 /

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*例如
res/test.png
这种应该是标准的


/res/test.png
这种在pc上可以工作 到安卓上不工作
*/
//pc一切正常 ,android上回调函数都不带执行的
Director::getInstance()->getTextureCache()->addImageAsync("/res/test.png",[&](Texture2D* texture){ });
//正确写法
Director::getInstance()->getTextureCache()->addImageAsync("res/test.png",[&](Texture2D* texture){ });


auto animation = Animation::create();
//这种pc正常,android上直接闪退
animation->addSpriteFrameWithFile("res\\test.png");
//正确写法
animation->addSpriteFrameWithFile("res/test.png");

希望对刚接触cocos的同学有用

感谢您的阅读,本文由 smallwhite's Blog 版权所有。如若转载,请注明出处:smallwhite's Blog(https://smallwhite.ml/pub/uncategorized/cocos-guan-yu-wen-jian-ming-de-ge-chong-keng-ge-chong-xie-gang-keng.html
欢迎使用CSDN-markdown编辑器
cocos studio lua 项目没有 print 输出解决办法