Ejemplo n.º 1
0
 static int Add(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Transform obj  = (DragonBones.Transform)ToLua.CheckObject(L, 1, typeof(DragonBones.Transform));
         DragonBones.Transform arg0 = (DragonBones.Transform)ToLua.CheckObject(L, 2, typeof(DragonBones.Transform));
         DragonBones.Transform o    = obj.Add(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        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);
        }