Ejemplo n.º 1
0
        public virtual void GotoFrame(int frame)
        {
            if (_currentFrame != frame)
            {
                _currentFrame = frame;
                FrameObject frameObj = _define.frames[_currentFrame];
                removeUnusedPlaceobjs(frameObj);

//				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];
                    DisplayObject displayObj = _depth_displays[placeObj.depth];
                    //no exist display, new one
                    if (displayObj == null)
                    {
                        displayObj = getDisplayCache(placeObj.depth, placeObj.characterId);
                        if (displayObj == null)
                        {
                            displayObj = createDisplayObject(placeObj.characterId);
                            _view.addChild(displayObj.view);
                        }
                        _depth_displays[placeObj.depth] = displayObj;
                    }
                    //exist display obj, but the tag indicats to new one
//					else if (placeObj.hasCharacter){
//						if(displayObj.characterId != placeObj.characterId){
//							DisplayObject newDisplayObj = getDisplayCache(placeObj.depth, placeObj.characterId);
//							if(newDisplayObj == null){
//								newDisplayObj = createDisplayObject(placeObj.characterId);
//								_view.addChild(newDisplayObj.view);
//							}
//							recycleDisplayCache(placeObj.depth, displayObj);
//							displayObj = newDisplayObj;
//							_depth_displays[placeObj.depth] = displayObj;
//						}
//					} else if(displayObj.characterId != placeObj.characterId){
//						CCDebug.Log("abc");
//					}
                    else if (displayObj.characterId != placeObj.characterId)
                    {
                        DisplayObject newDisplayObj = getDisplayCache(placeObj.depth, placeObj.characterId);
                        if (newDisplayObj == null)
                        {
                            newDisplayObj = createDisplayObject(placeObj.characterId);
                            _view.addChild(newDisplayObj.view);
                        }
                        recycleDisplayCache(placeObj.depth, displayObj);
                        displayObj = newDisplayObj;
                        _depth_displays[placeObj.depth] = displayObj;
                    }

                    displayObj.applyPlaceObject(placeObj);
                }
                _isBoundsDirty = true;
            }
        }
Ejemplo n.º 2
0
 public void applyPlaceObject(PlaceObject obj)
 {
     _instanceName = obj.instanceName;
     if (obj.hasMatrix)
     {
         view.position = new Vector2(obj.position.x, -obj.position.y);
         view.rotation = obj.rotation;
         view.scaleX   = obj.scaleX;
         view.scaleY   = obj.scaleY;
     }
     else if (obj.hasCharacter)
     {
         view.position = Vector2.zero;
         view.rotation = 0;
         view.scaleX   = 1;
         view.scaleY   = 1;
     }
     view.zOrder = obj.depth;
     if (obj.hasColorTransform)
     {
         if (obj.colorTransform.add == new Color32(0, 0, 0, 0))
         {
             Color viewColor = view.color;
             viewColor.a = obj.colorTransform.multiply.a;
             if (viewColor != obj.colorTransform.multiply)
             {
                 view.color = obj.colorTransform.multiply;
             }
             byte alpha = (byte)(Mathf.RoundToInt(viewColor.a * 255));
             if (view.opacity != alpha)
             {
                 view.opacity = alpha;
             }
         }
         else
         {
             Color viewColor = view.color;
             viewColor.a = obj.colorTransform.multiply.a;
             byte alpha = (byte)(Mathf.RoundToInt(viewColor.a * 255));
             if (view.opacity != alpha)
             {
                 view.opacity = alpha;
             }
             //TODO shader support for add color
         }
     }
     else if (obj.hasCharacter)
     {
         view.color   = Color.white;
         view.opacity = 255;
     }
 }
Ejemplo n.º 3
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;
                }
            }
        }