void parseVersion1(NSDictionary animations)
{
CCSpriteFrameCache frameCache = CCSpriteFrameCache.sharedSpriteFrameCache;
var enumerator = animations.GetEnumerator();
while (enumerator.MoveNext()) {
KeyValuePair<object, object> kv = enumerator.Current;
string name = (string)kv.Key;
NSDictionary animationDict = (NSDictionary)kv.Value;
ArrayList frameNames = (ArrayList)animationDict["frames"];
float delay = (float)animationDict["delay"];
CCAnimation animation = null;
if ( frameNames == null ) {
CCDebug.Log("cocos2d: CCAnimationCache: Animation '{0}' found in dictionary without any frames - cannot add to animation cache.", name);
continue;
}
List<CCAnimationFrame> frames = new List<CCAnimationFrame>(frameNames.Count);
var framesEnumerator = frameNames.GetEnumerator();
while (framesEnumerator.MoveNext()) {
string frameName = (string)framesEnumerator.Current;
CCSpriteFrame spriteFrame = frameCache.spriteFrameByName(frameName);
if ( spriteFrame == null ) {
CCDebug.Log("cocos2d: CCAnimationCache: Animation '{0}' refers to frame '{1}' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", name, frameName);
continue;
}
CCAnimationFrame animFrame = new CCAnimationFrame(spriteFrame, 1, null);
frames.Add(animFrame);
}
if ( frames.Count == 0 ) {
CCDebug.Log("cocos2d: CCAnimationCache: None of the frames for animation '{0}' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", name);
continue;
} else if ( frames.Count != frameNames.Count ) {
CCDebug.Log("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '{0}' may be missing.", name);
}
animation = new CCAnimation(frames, delay, 1);
CCAnimationCache.sharedAnimationCache.addAnimation(animation, name);
}
}