void LoadMovieClip(PackageItem item)
{
string str = _descPack[item.id + ".xml"];
XML xml = new XML(str);
string[] arr = null;
str = xml.GetAttribute("interval");
if (str != null)
item.interval = float.Parse(str) / 1000f;
item.swing = xml.GetAttributeBool("swing", false);
str = xml.GetAttribute("repeatDelay");
if (str != null)
item.repeatDelay = float.Parse(str) / 1000f;
int frameCount = xml.GetAttributeInt("frameCount");
item.frames = new MovieClip.Frame[frameCount];
int i = 0;
string spriteId;
XML frameNode;
MovieClip.Frame frame;
AtlasSprite sprite;
XMLList.Enumerator et = xml.GetNode("frames").GetEnumerator();
while (et.MoveNext())
{
frameNode = et.Current;
frame = new MovieClip.Frame();
arr = frameNode.GetAttributeArray("rect");
frame.rect = new Rect(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]));
str = frameNode.GetAttribute("addDelay");
if (str != null)
frame.addDelay = float.Parse(str) / 1000f;
str = frameNode.GetAttribute("sprite");
if (str != null)
spriteId = item.id + "_" + str;
else if (frame.rect.width != 0)
spriteId = item.id + "_" + i;
else
spriteId = null;
if (spriteId != null && _sprites.TryGetValue(spriteId, out sprite))
{
PackageItem atlasItem = _itemsById[sprite.atlas];
if (atlasItem != null)
{
if (item.texture == null)
item.texture = (NTexture)GetItemAsset(atlasItem);
frame.uvRect = new Rect(sprite.rect.x / item.texture.width * item.texture.uvRect.width,
1 - sprite.rect.yMax * item.texture.uvRect.height / item.texture.height,
sprite.rect.width * item.texture.uvRect.width / item.texture.width,
sprite.rect.height * item.texture.uvRect.height / item.texture.height);
}
}
item.frames[i] = frame;
i++;
}
}