cocos 关于文件名称的各种坑 各种斜杠坑

cocos 全部文件路径 的斜杠 必须 用 /  而不能够用    

不然编译到安卓各种坑

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


/*比如
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的同学实用




原文地址:https://www.cnblogs.com/llguanli/p/7183855.html