示例#1
0
        /** Do not call this method.*/
        public virtual void gotoFrame(int frameIndex, bool isCheckedPreTags)
        {
            if (_curFrame == null || _curFrame.frameIndex != frameIndex)
            {
                _curFrame = _define.frames [frameIndex];

                if (isCheckedPreTags)
                {
                    for (int i = 1; i <= _depthDisplays.Length; i++)
                    {
                        applyPreKeyTags(frameIndex, i);
                    }
                }
                else
                {
                    for (int i = 0; i < _curFrame.objs.Length; i++)
                    {
                        FrameObject frameObj = _curFrame.objs [i];
                        ITag        iTag     = getTag(frameObj);
                        if (iTag is IDisplayListTag)
                        {
                            (iTag as IDisplayListTag).apply(this, frameObj);
                        }
                    }
                }
                _isBoundsDirty = true;
            }
        }
示例#2
0
        ITag getTag(FrameObject frameObj)
        {
            ITag iTag = null;

            if (frameObj.lastModfiedAtIndex != 0)
            {
                iTag = _define.tags[frameObj.lastModfiedAtIndex];
            }
            else
            {
                iTag = _define.tags[frameObj.placedAtIndex];
            }
            return(iTag);
        }
        public void apply(Movie movie, FrameObject frameObj)
        {
            Display display = movie.depthDisplays [depth - 1];

            if (display != null)
            {
                //cache
                display.removed = true;
                display.visible = false;

//				display.removeFromParent ();
//				movie.depthDisplays [depth - 1] = null;
//				display = null;
            }
        }
示例#4
0
		protected override void parse(byte[] data, Cursor cursor){
			base.parse (data, cursor);
			_maxDepth = Utils.ReadInt32 (data, cursor);

			int framesCount = Utils.ReadInt32 (data, cursor); 
			_label_indexs = new Dictionary<string, int> (framesCount/4);
			_frames = new FrameObject[framesCount];
			for(int i = 0; i<framesCount; i++){
				FrameObject frame = new FrameObject(i, data, cursor);
				_frames[i] = frame;

				if(frame.label!=null)
					_label_indexs[frame.label] = i;
			}
		}
示例#5
0
        public string trace(int indent)
        {
            string indent0 = Utils.RepeatString(indent);
            string indent2 = Utils.RepeatString(indent + 2);
            string s       = indent0 + "[Frame:" + frameIndex + (label == null?"":("," + label)) + "]" +
                             indent2 + "placeObjects(" + objs.Length + ")";

            if (objs.Length > 0)
            {
                s += ":\n";
                for (int i = 0; i < objs.Length; i++)
                {
                    FrameObject obj = objs[i];
                    s += obj.trace(indent + 2) + "\n";
                }
            }
            return(s);
        }
示例#6
0
        public Frame(int frameIndex, byte[] data, Cursor cursor)
        {
            this.frameIndex = frameIndex;
            int dataLength = Utils.ReadInt32(data, cursor);
            int nextIndex  = cursor.index + dataLength;

            //parse
            label = Utils.ReadString(data, cursor);

            int objsCount = Utils.ReadInt32(data, cursor);

            objs = new FrameObject[objsCount];
            for (int i = 0; i < objsCount; i++)
            {
                FrameObject obj = new FrameObject(data, cursor);
                objs[i] = obj;
            }
            cursor.index = nextIndex;
        }
示例#7
0
        public void apply(Movie movie, FrameObject frameObj)
        {
            Display display = movie.depthDisplays [depth - 1];

            if (hasCharacter)
            {
                if (display != null)
                {
                    if (hasMove || characterId != display.define.characterId)
                    {
//                        display.removeFromParent();
                        display.removed = true;
                        display.visible = false;
                        movie.caches.DL_APPEND(display);

                        movie.depthDisplays [depth - 1] = null;
                        display = null;
                    }
                    else
                    {
                        //reuse cache
                        display.removed = false;
                    }
                }
                if (display == null)
                {
                    for (var ent = movie.caches.head; ent != null; ent = ent.next)
                    {
                        if (ent.obj.define.characterId == characterId)
                        {
                            display         = ent.obj;
                            display.removed = false;
                            display.visible = true;
                            movie.caches.DL_DELETE(ent);
                            movie.depthDisplays [depth - 1] = display;
                            if (display is Movie)
                            {
                                (display as Movie).movieCtrl.start();
                            }
                            break;
                        }
                    }
                }
                if (display == null)
                {
                    TagDefine newCharacterDefine = flash.getDefine(characterId);
                    if (newCharacterDefine is TagDefineDisplay)
                    {
                        display = flash.displayFactory.ctDisplay(newCharacterDefine as TagDefineDisplay);
                        movie.depthDisplays [depth - 1] = display;
                        movie.addChild(display);
                        if (display is Movie)
                        {
                            (display as Movie).movieCtrl.start();
                        }
                    }
                }
                NSUtils.Assert(display != null, "TagPlaceObject#apply failed to create display.");

                display.position = Vector2.zero;
                display.rotation = 0;
                display.scaleX   = 1; //display.define.preScale;
                display.scaleY   = 1; //display.define.preScale;
                display.zOrder   = depth;
                if (display.hasUserVisible)
                {
                    display.visible = display.userVisible;
                }
                else
                {
                    display.visible = true;
                }
                if (display.hasUserColorTransform)
                {
                    display.colorTransform   = display.userColorTransform;;
                    display.opacityTransform = new OpacityTransform(display.userColorTransform.tint.a, display.userColorTransform.add.a);
                }
                else
                {
                    display.colorTransform   = ColorTransform.Default;
                    display.opacityTransform = new OpacityTransform(display.userColorTransform.tint.a, display.userColorTransform.add.a);
                }
            }
            NSUtils.Assert(display != null, "TagPlaceObject#apply try to reference a null display.");


            if (display != null)
            {
                if (hasMatrix)
                {
                    float preScale = display.define.preScale;
                    display.position = new Vector2(position.x, -position.y);
                    display.rotation = rotation;
                    display.scaleX   = scaleX / preScale;
                    display.scaleY   = scaleY / preScale;
                }
                if (hasVisible)
                {
                    if (display.hasUserVisible)
                    {
                        display.visible = display.userVisible;
                    }
                    else
                    {
                        display.visible = visible;
                    }
                }
                if (hasColorTransform)
                {
                    if (display.hasUserColorTransform)
                    {
                        display.colorTransform   = display.userColorTransform;;
                        display.opacityTransform = new OpacityTransform(display.userColorTransform.tint.a, display.userColorTransform.add.a);
                    }
                    else
                    {
                        display.colorTransform   = colorTransform;
                        display.opacityTransform = new OpacityTransform(colorTransform.tint.a, colorTransform.add.a);
                    }
                }
                display.instanceName = instanceName;
            }
        }
示例#8
0
        void applyPreKeyTags(int fromFrameIndex, int depth)
        {
            utList <FrameObject> preTags = new utList <FrameObject>();
            bool removed = false, hasCharacter = false;
            int  i = fromFrameIndex;

            for (; i >= 0; i--)
            {
                Frame frame = _define.frames [i];
                for (int k = 0; k < frame.objs.Length; k++)
                {
                    FrameObject frameObj = frame.objs [k];
                    ITag        iTag     = getTag(frameObj);
                    if (iTag is TagRemoveObject)
                    {
                        TagRemoveObject tagRemoveObj = iTag as TagRemoveObject;
                        if (tagRemoveObj.depth == depth)
                        {
                            preTags.DL_APPEND(frameObj);
                            removed = true;
                            break;
                        }
                    }
                    else if (iTag is TagPlaceObject)
                    {
                        TagPlaceObject tagPlaceObj = iTag as TagPlaceObject;
                        if (tagPlaceObj.depth == depth)
                        {
                            preTags.DL_APPEND(frameObj);
                            hasCharacter |= tagPlaceObj.hasCharacter;
                            if (hasCharacter)
                            {
                                break;
                            }
                        }
                    }
                }

                if (removed || (hasCharacter))
                {
                    break;
                }
            }
            if (preTags.head != null)
            {
                for (var ent = preTags.head.prev; ent != preTags.head; ent = ent.prev)
                {
                    FrameObject     frameObj = ent.obj;
                    IDisplayListTag iTag     = getTag(frameObj) as IDisplayListTag;
                    iTag.apply(this, frameObj);
                }
                {
                    FrameObject     frameObj = preTags.head.obj;
                    IDisplayListTag iTag     = getTag(frameObj) as IDisplayListTag;
                    iTag.apply(this, frameObj);
                }
            }
            else
            {
                Display display = _depthDisplays [depth - 1];
                if (display != null)
                {
                    //cache
                    display.removed = true;
                    display.visible = false;
                }
            }
        }
示例#9
0
		void removeUnusedPlaceobjs(FrameObject frameObj){
//			foreach(int removeObjDepth in frameObj.removedObjectDepths){
//				DisplayObject displayObj = _depth_displays[removeObjDepth];
//				if(displayObj!=null){
//					recycleDisplayCache(removeObjDepth, displayObj);
//				}
//				_depth_displays[removeObjDepth] = null;
//			}

			
			bool[] modified = new bool[_depth_displays.Length];
			for(int i=modified.Length - 1; i>=0; i--)
				modified[i] = false;

//			frameObj.reset();
//			for(int i=0; i<frameObj.placeObjectCount; i++){
//				PlaceObject placeObj = frameObj.nextPlaceObject();
			for(int i=0; i<frameObj.placeObjects.Length; i++){
				PlaceObject placeObj = frameObj.placeObjects[i];
				modified[placeObj.depth] = true;			
			}

			for(int i=modified.Length-1; i>=0; i--){
				if(!modified[i]){
					DisplayObject displayObj = _depth_displays[i];
					if(displayObj!=null){
						recycleDisplayCache(i, displayObj);
					}
					_depth_displays[i] = null;
				}
			}
		}