is there a bug in CCSpriteFrameCache::addSpriteFramesWithDictionary() ?

is there a bug in CCSpriteFrameCache::addSpriteFramesWithDictionary() ?
0.0 0


Hey guys,

I have a problem in which animation frames loaded with CCSpriteFrameCache::addSpriteFramesWithDictionary are loaded in the correct order on PC, but in the wrong order on iOS. So if I have an animation in which each image is labeled with numbers, in order, on PC it will play as, 1, 2, 3, 4, 5. But on iOS it will play out of order.

I think the bug occurs here:

    CCDICT_FOREACH(framesDict, pElement)   <--------- CCDICT_FOREACH does not return elements in order!
        CCDictionary* frameDict = (CCDictionary*)pElement->getObject();
        std::string spriteFrameName = pElement->getStrKey();
        CCSpriteFrame* spriteFrame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(spriteFrameName);

When I debug, I see that the CCDICT_FOREACH macro does not return the dictionary entries in order…but it’s supposed to, right?

Any help on this matter is much appreciated!



That’s probably not a bug, CCDictionary isn’t an ordered container after all. Although having different
results on different platforms is an issue. NSDictionary is there on iOS, but CCDictMaker is also there,
and it is also on every other platform, so why not always use it?