l4u at October 5th, 2011 00:34 — #1
I am using CCTextureCache::sharedTextureCache()->addPVRImage(“/data/data/com.mycompany/a_texture_file”);
but CCFileUtils::getFileData prepends “assets/”
so the path become “assets//data/data/com.mycompany/a_texture_file”
It works in iOS, but not in android.
zhangbin at October 7th, 2011 22:31 — #2
Thanks for your feedback!
In the situation you described, you want to read a texture file which is not in assets directory.
Sorry that the methods in the engine only support read resource files in the assets directory of the apk file.
And the parameter of the function CCTextureCache::addPVRImage() should be the relative path of assets directory.
If you want read resource files in the system folders but not in the apk file, you must use fopen/fclose to implement that!
Or if you have much better ideas, welcome to share with us!
busterkika at November 8th, 2011 04:17 — #3
Hi Bin Zhang,
I try load texture by fopen…. look this:
FILE * pFile;
char * buffer;
pFile = fopen ( “/mnt/sdcard/mms/test.png” , “rb” );
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
buffer = (char*) malloc (sizeof(char)lSize);
// copy the file into the buffer:
result = fread ;
CCImage image = new CCImage;
image.initWithImageDatabuffer, nSize, CCImage::kFmtPng);
CCTexture2Dtexture = new CCTexture2D();
CCSprite *sprite = new CCSprite;
But, if i add sprite into layer, he dont appear….. I can solve this problem??? do you help me please?
zhangxm at November 8th, 2011 18:37 — #4
I think you should set the texture rect by CCSprite::setTextureRect().