Пример #1
0
        void TweenFrames(Frame startFrame, Frame endFrame, int tweenCount)
        {
            //tweenCount = Int32.Parse(textTweenFrames.Text);
            for (int i = 1; i < tweenCount; i++)
            {
                Frame thisFrame = new Frame();
                foreach (Part startPart in startFrame.Parts)
                {
                    foreach (Part endPart in endFrame.Parts)
                    {
                        if (startPart.ID == endPart.ID)
                        {
                            Part newPart = new Part(startPart.ID, startPart.Texture, startPart.SourceRect, endPart.DestRect);
                            newPart.Position = endPart.Position;
                            newPart.Rotation = startPart.Rotation;

                            if (startPart.Position != endPart.Position)
                            {
                                if (endPart.Position.X > startPart.Position.X && endPart.Position.Y < startPart.Position.Y) // I Quadrant
                                {
                                    newPart.Position = new Vector2(startPart.Position.X + ((endPart.Position.X - startPart.Position.X) / tweenCount) * i, startPart.Position.Y - ((startPart.Position.Y - endPart.Position.Y) / tweenCount) * i);
                                }
                                else if (endPart.Position.X < startPart.Position.X && endPart.Position.Y < startPart.Position.Y) // II Quadrant
                                {
                                    newPart.Position = new Vector2(startPart.Position.X - ((startPart.Position.X - endPart.Position.X) / tweenCount) * i, startPart.Position.Y - ((startPart.Position.Y - endPart.Position.Y) / tweenCount) * i);
                                }
                                else if (endPart.Position.X < startPart.Position.X && endPart.Position.Y > startPart.Position.Y) // III Quadrant
                                {
                                    newPart.Position = new Vector2(startPart.Position.X - ((startPart.Position.X - endPart.Position.X) / tweenCount) * i, startPart.Position.Y + ((endPart.Position.Y - startPart.Position.Y) / tweenCount) * i);
                                }
                                else if (endPart.Position.X > startPart.Position.X && endPart.Position.Y > startPart.Position.Y) // IV Quadrant
                                {
                                    newPart.Position = new Vector2(startPart.Position.X + ((endPart.Position.X - startPart.Position.X) / tweenCount) * i, startPart.Position.Y + ((endPart.Position.Y - startPart.Position.Y) / tweenCount) * i);
                                }
                            }

                            if (startPart.Rotation != endPart.Rotation)
                            {
                                if (endPart.Rotation > startPart.Rotation)
                                {
                                    newPart.Rotation += ((endPart.Rotation - startPart.Rotation) / tweenCount) * i;
                                }
                                else
                                {
                                    newPart.Rotation -= ((startPart.Rotation - endPart.Rotation) / tweenCount) * i;
                                }
                            }
                            thisFrame.AddPart(newPart);
                        }
                    }
                }
                CurrentAnimation.InsertFrame(thisFrame);
            }
        }
Пример #2
0
        public override void Execute()
        {
            base.Execute();
            Frame newFrame = CurrentAnimation.CurrentFrame;

            if (CurrentAnimation.Frames.Length > 1)
            {
                CurrentAnimation.AddFrame(new Frame(newFrame, false, CurrentAnimation.Bounds.Center));
                //textScript.Text = currentAnimation.Frames[currentAnimation.CurrentFrameIndex].Script;
            }
            else
            {
                CurrentAnimation.InsertFrame(new Frame(newFrame, false, CurrentAnimation.Bounds.Center));
                //textScript.Text = currentAnimation.Frames[currentAnimation.CurrentFrameIndex].Script;
            }
        }