Example #1
0
 /**
  * @inheritDoc
  */
 protected override void _onClear()
 {
     type = null;
     name = null;
     // data = null;
     armature       = null;
     bone           = null;
     slot           = null;
     animationState = null;
     frame          = null;
     userData       = null;
 }
    static int get_next(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.FrameData <DragonBones.AnimationFrameData> obj = (DragonBones.FrameData <DragonBones.AnimationFrameData>)o;
            DragonBones.AnimationFrameData ret = obj.next;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index next on a nil value" : e.Message));
        }
    }
    static int set_next(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.FrameData <DragonBones.AnimationFrameData> obj = (DragonBones.FrameData <DragonBones.AnimationFrameData>)o;
            DragonBones.AnimationFrameData arg0 = (DragonBones.AnimationFrameData)ToLua.CheckObject(L, 2, typeof(DragonBones.AnimationFrameData));
            obj.next = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index next on a nil value" : e.Message));
        }
    }
Example #4
0
    static int get_events(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationFrameData obj = (DragonBones.AnimationFrameData)o;
            System.Collections.Generic.List <DragonBones.EventData> ret = obj.events;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index events on a nil value" : e.Message));
        }
    }
    static int set_frame(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject        obj  = (DragonBones.EventObject)o;
            DragonBones.AnimationFrameData arg0 = (DragonBones.AnimationFrameData)ToLua.CheckObject <DragonBones.AnimationFrameData>(L, 2);
            obj.frame = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index frame on a nil value"));
        }
    }
    static int get_frame(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject        obj = (DragonBones.EventObject)o;
            DragonBones.AnimationFrameData ret = obj.frame;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index frame on a nil value"));
        }
    }
Example #7
0
    static int _CreateDragonBones_AnimationFrameData(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                DragonBones.AnimationFrameData obj = new DragonBones.AnimationFrameData();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: DragonBones.AnimationFrameData.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #8
0
        protected void _mergeFrameToAnimationTimeline(float framePostion,List <ActionData> actions,List <EventData> events)
        {
            var frameStart = (int)Math.Floor(framePostion * _armature.frameRate); // uint()
            var frames     = _animation.frames;

            if (frames.Count == 0)
            {
                var startFrame = BaseObject.BorrowObject <AnimationFrameData>(); // Add start frame.
                startFrame.position = 0.0f;

                if (_animation.frameCount > 1)
                {
                    DragonBones.ResizeList(frames,(int)_animation.frameCount + 1,null);                // One more count for zero duration frame.

                    var endFrame = BaseObject.BorrowObject <AnimationFrameData> ();                    // Add end frame to keep animation timeline has two different frames atleast.
                    endFrame.position = _animation.frameCount / _armature.frameRate;

                    frames[0] = startFrame;
                    frames[(int)_animation.frameCount] = endFrame;
                }
                else                 // TODO
                {
                    DragonBones.ResizeList(frames,1,null);
                    frames[0] = startFrame;
                }
            }

            AnimationFrameData insertedFrame = null;
            var replacedFrame = frames[frameStart];

            if (replacedFrame != null && (frameStart == 0 || frames[frameStart - 1] == replacedFrame.prev)) // Key frame.
            {
                insertedFrame = replacedFrame;
            }
            else
            {
                insertedFrame          = BaseObject.BorrowObject <AnimationFrameData>(); // Create frame.
                insertedFrame.position = frameStart / _armature.frameRate;
                frames[frameStart]     = insertedFrame;

                for (int i = frameStart + 1,l = frames.Count; i < l; ++i)  // Clear replaced frame.
                {
                    var frame = frames[i];
                    if (replacedFrame != null && frame == replacedFrame)
                    {
                        frames[i] = null;
                    }
                }
            }

            if (actions != null) // Merge actions.
            {
                foreach (var action in actions)
                {
                    insertedFrame.actions.Add(action);
                }
            }

            if (events != null) // Merge events.
            {
                foreach (var evt in events)
                {
                    insertedFrame.events.Add(evt);
                }
            }

            // Modify frame link and duration.
            AnimationFrameData prevFrame = null;
            AnimationFrameData nextFrame = null;

            for (int i = 0,l = frames.Count; i < l; ++i)
            {
                var currentFrame = frames[i];
                if (currentFrame != null && nextFrame != currentFrame)
                {
                    nextFrame = currentFrame;

                    if (prevFrame != null)
                    {
                        nextFrame.prev     = prevFrame;
                        prevFrame.next     = nextFrame;
                        prevFrame.duration = nextFrame.position - prevFrame.position;
                    }

                    prevFrame = nextFrame;
                }
                else
                {
                    frames[i] = prevFrame;
                }
            }

            nextFrame.duration = _animation.duration - nextFrame.position;

            nextFrame      = frames[0];
            prevFrame.next = nextFrame;
            nextFrame.prev = prevFrame;
        }