public override string trace(int indent) { string indent0 = Utils.RepeatString(indent); string indent2 = Utils.RepeatString(indent + 2); string s = base.trace(indent) + " MaxDepth: " + _maxDepth + "\n"; if (_label_indexs.Count > 0) { s += indent0 + "Labels(" + _label_indexs.Count + "):\n"; var enumerator = _label_indexs.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <string, int> kv = enumerator.Current; string label = kv.Key; s += indent2 + label + "\n"; } } if (_frames.Length > 0) { s += indent0 + "FrameCount(" + _frames.Length + "):\n"; for (int i = 0; i < _frames.Length; i++) { FrameObject frame = _frames[i]; s += frame.trace(indent + 2) + "\n"; } } return(s); }
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; } }
public virtual void SkipFrame(int frame) { if (_currentFrame != frame) { _currentFrame = frame; FrameObject frameObj = _define.frames [_currentFrame]; removeUnusedPlaceobjs(frameObj); } }
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; } } }
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; } } }