lig
June 1, 2011, 7:06am
1
if pszPlist is only a file name (“some.plist”), not includes directory, this function is failed.
— /a/CCSpriteFrameCache.cpp 2011-05-29 23:23:34.000000000 0800
**+ /b/CCSpriteFrameCache.cpp 2011-06-01 21:46:59.802755638 0800
@ -242,7 +242,12
@
textureBase.erase(indexOfLastSeperator, 1);
indexOfLastSeperator = textureBase.find_last_of(‘/’);
}
textureBase.erase(indexOfLastSeperator);
if (indexOfLastSeperator > –1) {
textureBase.erase(indexOfLastSeperator);
} else {
textureBase.clear();
}
// stringByAppendingPathComponent
if (! textureBase.empty())
@lig hwong,
Sorry that I can’t understand your post!
Can you provide more information? Sucn as the error message, line of source code, environment and so on.
at NDK, android-ndk-r5b, android-sdk-r11, cocos2d-0.99.5-x-0.8.4, TexturePacker(ImageA.plist, ImageA.png)
crashed.
CCSpriteFrameCache.cpp
Line: 224
void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
....
textureBase.erase(indexOfLastSeperator); <- here
--------------------------------------------------------------------------------
void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
{
const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist);
CCDictionary *dict = CCFileUtils::dictionaryWithContentsOfFile(pszPath);
string texturePath("");
CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey(string("metadata"));
if (metadataDict)
{
// try to read texture file name from meta data
texturePath = string(valueForKey("textureFileName", metadataDict));
}
if (! texturePath.empty())
{
+ if (pszPath != pszPlist) {
// build texture path relative to plist file
// stringByDeletingLastPathComponent
string textureBase(pszPath);
int indexOfLastSeperator = textureBase.find_last_of('/');
if (indexOfLastSeperator == textureBase.length() - 1)
{
textureBase.erase(indexOfLastSeperator, 1);
indexOfLastSeperator = textureBase.find_last_of('/');
}
if (0<=indexOfLastSeperator)
textureBase.erase(indexOfLastSeperator);
// stringByAppendingPathComponent
if (! textureBase.empty())
{
texturePath = textureBase + "/" + texturePath;
}
+ }
}
else
..................
Two lines are inserted...
OK..
lig
June 3, 2011, 8:58am
4
Sorry, my english is poor, and i am reply later. such as Deahoon Jang’ reply.
mySpriteFrameCache~~>addSpriteFramesWithFile —> crashed
mySpriteFrameCache~~>addSpriteFramesWithFile(“mydir/my.plist”) —> work fine
test at android-ndk-r5b, android-sdk-r11, cocos2d-0.9.5-x-0.8.1 and cocos2d-0.9.5-x-0.8.4
Thanks for your feedback!
I think it’s a bug of the engine. And I have created an issue #522 for this problem.