不能与子文件夹中创建PNG时CCSprite口与的cocos2d-X的Andr​​oid应用程序? [英] Cannot create CCSprite with subfolder png when port to Android application with cocos2d-x?

查看:168
本文介绍了不能与子文件夹中创建PNG时CCSprite口与的cocos2d-X的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇见了我不能创建在cocos2d-X的Andr​​oid CCSprite的问题。

I met the problem I cannot create CCSprite in cocos2d-x Android.

我有一个存储文件路径的XML文件。而我读创建一个雪碧的文件路径。雪碧为NULL。

I have a xml file which store the file path. And I read the file path to create a Sprite. The Sprite is NULL.

CCSprite* pSprite1 = CCSprite::create(tempfilename.c_str());    

tempfilename包含 withword \\\\ stone_0.png 。所有我的资源位于资产\\ .. ,和PNG文件位于资产\\ withword \\ stone_0.png 。我不知道我为什么不能创建这个精​​灵。我怎样才能解决这个问题?

tempfilename contains withword\\stone_0.png.All my resources is located under assets\..,and this png is located under assets\withword\stone_0.png. I don't know why I cannot create this sprite. How can I solve this problem?

我已经检查这个话题,但还是不知道。

I have checked this topic but still don't know.

推荐答案

您必须子目录添加到您的搜索路径科科斯-2DX,
您可以加载任何场景之前做到这一点在你的的AppDelegate ::在applicationDidFinishLaunching()方法。

You have to add sub directories to your search path in cocos-2dx, You can do this in your AppDelegate::applicationDidFinishLaunching() method before loading any scene.

int i = 0;
CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths = fileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin() + i++, "withword");
fileUtils->setSearchPaths(searchPaths);

这篇关于不能与子文件夹中创建PNG时CCSprite口与的cocos2d-X的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆