/** @private */ public static void returnObject(AnimationState animationState) { animationState.clearVaribles(); if(_pool.IndexOf(animationState) < 0) { _pool.Add(animationState); } }
private void clearVaribles() { _updateState = 0; _bone = null; _animationState = null; _timeline = null; _currentFrame = null; _originTransform = null; _originPivot = null; }
public void FadeIn(Bone bone, AnimationState animationState, TransformTimeline timeline) { _bone = bone; _animationState = animationState; _timeline = timeline; _originTransform = _timeline.OriginTransform; _originPivot = _timeline.OriginPivot; //_originTransform.copy(_timeline.originTransform); /* var bLRX:Number = _bone.origin.skewX + _bone.offset.skewX + _bone._tween.skewX; var bLRY:Number = _bone.origin.skewY + _bone.offset.skewY + _bone._tween.skewY; _originTransform.skewX = bLRX + TransformUtils.formatRadian(_originTransform.skewX - bLRX); _originTransform.skewY = bLRY + TransformUtils.formatRadian(_originTransform.skewY - bLRY); */ _tweenTransform = false; _tweenColor = false; _totalTime = _animationState.TotalTime; Transform.X = 0; Transform.Y = 0; Transform.ScaleX = 0; Transform.ScaleY = 0; Transform.SkewX = 0; Transform.SkewY = 0; Pivot.X = 0; Pivot.Y = 0; _durationTransform.X = 0; _durationTransform.Y = 0; _durationTransform.ScaleX = 0; _durationTransform.ScaleY = 0; _durationTransform.SkewX = 0; _durationTransform.SkewY = 0; _durationPivot.X = 0; _durationPivot.Y = 0; _currentFrame = null; switch(_timeline.FrameList.Count) { case 0: _bone.arriveAtFrame(null, this, _animationState, false); _updateState = 0; break; case 1: _updateState = -1; break; default: _updateState = 1; break; } }
/** @private */ public void arriveAtFrame(Frame frame, TimelineState timelineState, AnimationState animationState, bool isCross) { if(frame!=null) { int mixingType = animationState.GetMixingTransform(Name); if(animationState.DisplayControl && (mixingType == 2 || mixingType == -1)) { if( DisplayController==null || DisplayController == animationState.Name ) { TransformFrame tansformFrame = frame as TransformFrame; if(_slot!=null) { int displayIndex = tansformFrame.DisplayIndex; if(displayIndex >= 0) { if(!float.IsNaN(tansformFrame.ZOrder) && tansformFrame.ZOrder != _slot._tweenZorder) { _slot._tweenZorder = tansformFrame.ZOrder; this._armature._slotsZOrderChanged = true; } } _slot.changeDisplay(displayIndex); _slot.updateVisible(tansformFrame.Visible); } } } if(frame.Evt!=null && this._armature.HasEventListener(FrameEvent.BONE_FRAME_EVENT)) { FrameEvent frameEvent = new FrameEvent(FrameEvent.BONE_FRAME_EVENT); frameEvent.Bone = this; frameEvent.AnimationState = animationState; frameEvent.FrameLabel = frame.Evt; this._armature._eventList.Add(frameEvent); } if(frame.Sound!=null && _soundManager.HasEventListener(SoundEvent.SOUND)) { SoundEvent soundEvent = new SoundEvent(SoundEvent.SOUND); soundEvent.Armature = this._armature; soundEvent.AnimationState = animationState; soundEvent.Sound = frame.Sound; _soundManager.DispatchEvent(soundEvent); } if(frame.Action!=null) { foreach(DBObject child in _children) { if(child is Slot) { Armature childArmature = (child as Slot).ChildArmature; if(childArmature!=null) { childArmature.Animation.GotoAndPlay(frame.Action); } } } } } else { if(_slot!=null) { _slot.changeDisplay(-1); } } }
private void addState(AnimationState animationState) { List <AnimationState> animationStateList = _animationLayer[(int)animationState.Layer]; animationStateList.Add(animationState); }
/** * Move the playhead to that AnimationData * @param animationName The name of the AnimationData to play. * @param fadeInTime A fade time to apply (> 0) * @param duration The duration of that AnimationData. * @param loop Loop(0:loop forever, 1~+∞:loop times, -1~-∞:will fade animation after loop complete). * @param layer The layer of the animation. * @param group The group of the animation. * @param fadeOutMode Fade out mode. * @param displayControl Display control. * @param pauseFadeOut Pause other animation playing. * @param pauseFadeIn Pause this animation playing before fade in complete. * @see dragonBones.objects.AnimationData. * @see dragonBones.animation.AnimationState. */ public AnimationState GotoAndPlay( string animationName, float fadeInTime = -1f, float duration = -1f, float loop = float.NaN, uint layer = 0, string group = null, string fadeOutMode = SAME_LAYER_AND_GROUP, bool displayControl = true, bool pauseFadeOut = true, bool pauseFadeIn = true ) { if (_animationDataList == null) { return(null); } int i = _animationDataList.Count; int j; AnimationData animationData = null; while (i-- > 0) { if (_animationDataList[i].Name == animationName) { animationData = _animationDataList[i]; break; } } if (animationData == null) { Debug.LogError(string.Format("Cannot find animation {0}", animationName)); return(null); } _isPlaying = true; fadeInTime = fadeInTime < 0?(animationData.FadeInTime < 0?0.3f:animationData.FadeInTime):fadeInTime; float durationScale; if (duration < 0) { durationScale = animationData.Scale < 0?1:animationData.Scale; } else { durationScale = duration / animationData.Duration; } loop = float.IsNaN(loop)?animationData.Loop:loop; layer = addLayer(layer); //autoSync = autoSync && !pauseFadeOut && !pauseFadeIn; AnimationState animationState; List <AnimationState> animationStateList; switch (fadeOutMode) { case NONE: break; case SAME_LAYER: animationStateList = _animationLayer[(int)layer]; i = animationStateList.Count; while (i-- > 0) { animationState = animationStateList[i]; animationState.FadeOut(fadeInTime, pauseFadeOut); } break; case SAME_GROUP: j = _animationLayer.Count; while (j-- > 0) { animationStateList = _animationLayer[j]; i = animationStateList.Count; while (i-- > 0) { animationState = animationStateList[i]; if (animationState.Group == group) { animationState.FadeOut(fadeInTime, pauseFadeOut); } } } break; case ALL: j = _animationLayer.Count; while (j-- > 0) { animationStateList = _animationLayer[j]; i = animationStateList.Count; while (i-- > 0) { animationState = animationStateList[i]; animationState.FadeOut(fadeInTime, pauseFadeOut); } } break; case SAME_LAYER_AND_GROUP: default: animationStateList = _animationLayer[(int)layer]; i = animationStateList.Count; while (i-- > 0) { animationState = animationStateList[i]; if (animationState.Group == group) { animationState.FadeOut(fadeInTime, pauseFadeOut); } } break; } _lastAnimationState = AnimationState.borrowObject(); _lastAnimationState.Group = group; _lastAnimationState.TweenEnabled = TweenEnabled; _lastAnimationState.fadeIn(_armature, animationData, fadeInTime, 1 / durationScale, (int)loop, layer, displayControl, pauseFadeIn); addState(_lastAnimationState); List <Slot> slotList = _armature._slotList; Slot slot; i = slotList.Count; while (i-- > 0) { slot = slotList[i]; if (slot.ChildArmature != null) { slot.ChildArmature.Animation.GotoAndPlay(animationName, fadeInTime); } } _lastAnimationState.AdvanceTime(0); return(_lastAnimationState); }