Beispiel #1
0
        private void _getTimelineFrameMatrix(AnimationData animation,BoneTimelineData timeline,float position,Transform transform)    // Support 2.x ~ 3.x data.
        {
            var frameIndex = (int)Math.Floor(position * animation.frameCount / animation.duration);

            if (timeline.frames.Count == 1 || frameIndex >= timeline.frames.Count)
            {
                transform.CopyFrom(timeline.frames[0].transform);
            }
            else
            {
                var   frame         = timeline.frames[frameIndex];
                float tweenProgress = 0.0f;

                if (frame.tweenEasing != DragonBones.NO_TWEEN)
                {
                    tweenProgress = (position - frame.position) / frame.duration;
                    if (frame.tweenEasing != 0.0f)
                    {
                        tweenProgress = TweenTimelineState <BoneFrameData,BoneTimelineData> ._getEasingValue(tweenProgress,frame.tweenEasing);
                    }
                }
                else if (frame.curve != null)
                {
                    tweenProgress = (position - frame.position) / frame.duration;
                    tweenProgress = TweenTimelineState <BoneFrameData,BoneTimelineData> ._getCurveEasingValue(tweenProgress,frame.curve);
                }

                var nextFrame = frame.next;

                transform.x      = nextFrame.transform.x - frame.transform.x;
                transform.y      = nextFrame.transform.y - frame.transform.y;
                transform.skewX  = Transform.NormalizeRadian(nextFrame.transform.skewX - frame.transform.skewX);
                transform.skewY  = Transform.NormalizeRadian(nextFrame.transform.skewY - frame.transform.skewY);
                transform.scaleX = nextFrame.transform.scaleX - frame.transform.scaleX;
                transform.scaleY = nextFrame.transform.scaleY - frame.transform.scaleY;

                transform.x      = frame.transform.x + transform.x * tweenProgress;
                transform.y      = frame.transform.y + transform.y * tweenProgress;
                transform.skewX  = frame.transform.skewX + transform.skewX * tweenProgress;
                transform.skewY  = frame.transform.skewY + transform.skewY * tweenProgress;
                transform.scaleX = frame.transform.scaleX + transform.scaleX * tweenProgress;
                transform.scaleY = frame.transform.scaleY + transform.scaleY * tweenProgress;
            }

            transform.Add(timeline.originTransform);
        }
Beispiel #2
0
 protected override void _OnUpdateFrame()
 {
     if (this._tweenState == TweenState.Always)
     {
         this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR;
         if (this._tweenType == TweenType.Curve)
         {
             this._tweenProgress = TweenTimelineState._GetEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, (int)this._frameOffset + (int)BinaryOffset.FrameCurveSamples);
         }
         else if (this._tweenType != TweenType.Line)
         {
             this._tweenProgress = TweenTimelineState._GetEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing);
         }
     }
     else
     {
         this._tweenProgress = 0.0f;
     }
 }