public void SetData(NTexture texture, Frame[] frames, Rect boundsRect)
        {
            this.frames = frames;
            this.frameCount = frames.Length;
            _contentRect = boundsRect;

            if (_end == -1 || _end > frameCount - 1)
                _end = frameCount - 1;
            if (_endAt == -1 || _endAt > frameCount - 1)
                _endAt = frameCount - 1;
            playState.Rewind();

            graphics.texture = texture;
            OnSizeChanged(true, true);
            InvalidateBatchingState();
            _forceDraw = true;
        }
Beispiel #2
0
        void LoadMovieClip(PackageItem item)
        {
            string str = GetDesc(item.id + ".xml");
            XML xml = new XML(str);
            string[] arr = null;

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                item.pivot.x = int.Parse(arr[0]);
                item.pivot.y = int.Parse(arr[1]);
            }
            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 Frame[frameCount];

            XMLList frameNodes = xml.GetNode("frames").Elements();

            int i = 0;
            foreach (XML frameNode in frameNodes)
            {
                Frame frame = new 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;

                AtlasSprite sprite;
                if (_sprites.TryGetValue(item.id + "_" + i, out sprite))
                    frame.texture = CreateSpriteTexture(sprite);
                item.frames[i] = frame;
                i++;
            }
        }