Пример #1
0
        private void SetAnimationsForAppTiles()
        {
            int Counter = 1;

            foreach (AppTile Tile in AppGrid.Children.OfType <AppTile>())
            {
                int Duration = Counter * 80;

                AnimationCollection Col = new AnimationCollection();
                OpacityAnimation    O   = new OpacityAnimation
                {
                    Duration = new TimeSpan(0, 0, 0, 0, Duration),
                    From     = 0,
                    To       = 1.0
                };

                TranslationAnimation T = new TranslationAnimation
                {
                    Duration = new TimeSpan(0, 0, 0, 0, Duration),
                    From     = "0, 80, 0",
                    To       = "0"
                };

                Col.Add(O);
                Col.Add(T);
                Implicit.SetShowAnimations(Tile, Col);
                Counter++;
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a SequencedAnimation as a child of this AnimationCollection,
        /// using the specified callback to configure the collection
        /// </summary>
        /// <param name="animationCollection">The target animation collection</param>
        /// <param name="configureFunction"></param>
        /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
        public static AnimationCollection Sequence(this AnimationCollection animationCollection, Action <SequencedAnimation> configureFunction)
        {
            var sequence = new SequencedAnimation();

            animationCollection.Add(sequence);
            configureFunction(sequence);
            return(animationCollection);
        }
Пример #3
0
        /// <summary>
        /// Adds a ParalleledAnimation as a child of this AnimationCollection,
        /// using the specified callback to configure the collection
        /// </summary>
        /// <param name="animationCollection">The target animation collection</param>
        /// <param name="configureFunction"></param>
        /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
        public static AnimationCollection Parallel(this AnimationCollection animationCollection, Action <ParalleledAnimation> configureFunction)
        {
            var parallel = new ParalleledAnimation();

            animationCollection.Add(parallel);
            configureFunction(parallel);
            return(animationCollection);
        }
Пример #4
0
        /// <summary>
        /// Run the application
        /// </summary>
        public void Go()
        {
            // Make the particle emitter.
            emit              = new ParticleRectangleEmitter(particles);
            emit.Frequency    = 50000; // 100000 every 1000 updates.
            emit.LifeFullMin  = 20;
            emit.LifeFullMax  = 50;
            emit.LifeMin      = 10;
            emit.LifeMax      = 30;
            emit.DirectionMin = -2; // shoot up in radians.
            emit.DirectionMax = -1;
            emit.ColorMin     = Color.DarkBlue;
            emit.ColorMax     = Color.LightBlue;
            emit.SpeedMin     = 5;
            emit.SpeedMax     = 20;
            emit.MaxSize      = new SizeF(5, 5);
            emit.MinSize      = new SizeF(1, 1);

            // Make the first particle (a pixel)
            ParticlePixel first = new ParticlePixel(Color.White, 100, 200, new Vector(0, 0, 0), -1);

            particles.Add(first); // Add it to the system

            if (File.Exists(Path.Combine(dataDirectory, "marble1.png")))
            {
                filePath = "";
            }

            // Make the second particle (an animated sprite)
            AnimationCollection anim     = new AnimationCollection();
            SurfaceCollection   surfaces = new SurfaceCollection();

            surfaces.Add(Path.Combine(filePath, Path.Combine(dataDirectory, "marble1.png")), new Size(50, 50));
            anim.Add(surfaces, 1);
            AnimatedSprite marble = new AnimatedSprite(anim);

            marble.Animate = true;
            ParticleSprite second = new ParticleSprite(marble, 200, 200, new Vector(-7, -9, 0), 500);

            second.Life = -1;
            particles.Add(second); // Add it to the system

            // Add some manipulators to the particle system.
            ParticleGravity grav = new ParticleGravity(0.5f);

            particles.Manipulators.Add(grav);                                                       // Gravity of 0.5f
            particles.Manipulators.Add(new ParticleFriction(0.1f));                                 // Slow down particles
            particles.Manipulators.Add(vort);                                                       // A particle vortex fixed on the mouse
            particles.Manipulators.Add(new ParticleBoundary(SdlDotNet.Graphics.Video.Screen.Size)); // fix particles on screen.


            Events.Run();
        }
Пример #5
0
        /// <summary>
        ///    Creates a new Animation object for animating this skeleton.
        /// </summary>
        /// <param name="name">The name of this animation</param>
        /// <param name="length">The length of the animation in seconds</param>
        /// <returns></returns>
        public virtual Animation CreateAnimation(string name, float length)
        {
            // Check name not used
            if (animationList.ContainsKey(name))
            {
                throw new Exception("An animation with the name already exists");
            }

            Animation anim = new Animation(name, length);

            animationList.Add(name, anim);

            return(anim);
        }
Пример #6
0
        public static AnimatedSprite CreateColored(AnimatedSprite os, Color c)
        {
            if (os == null)
            {
                return(null);
            }

            AnimatedSprite nsprite = new AnimatedSprite();

            foreach (KeyValuePair <string, AnimationCollection> kv in os.Animations)
            {
                string key = kv.Key; AnimationCollection anim = kv.Value;
                AnimationCollection nAnim = new AnimationCollection();
                foreach (Surface s in anim)
                {
                    Surface ns = CreateColored(s, c);
                    nAnim.Add(ns);
                }
                nAnim.Loop           = anim.Loop;
                nAnim.Delay          = anim.Delay;
                nAnim.FrameIncrement = anim.FrameIncrement;
                nAnim.Alpha          = anim.Alpha;
                nAnim.AlphaBlending  = anim.AlphaBlending;
                nAnim.AnimateForward = anim.AnimateForward;
                //nAnim.AnimationTime = anim.AnimationTime;
                nAnim.Transparent      = anim.Transparent;
                nAnim.TransparentColor = anim.TransparentColor;

                nsprite.Animations.Add(key, nAnim);
            }
            nsprite.AllowDrag        = os.AllowDrag;
            nsprite.Alpha            = os.Alpha;
            nsprite.AlphaBlending    = os.AlphaBlending;
            nsprite.Animate          = os.Animate;
            nsprite.AnimateForward   = os.AnimateForward;
            nsprite.CurrentAnimation = os.CurrentAnimation;
            nsprite.Frame            = os.Frame;
            nsprite.Transparent      = os.Transparent;
            nsprite.TransparentColor = os.TransparentColor;
            nsprite.Visible          = os.Visible;

            return(nsprite);
        }
Пример #7
0
        /// <summary>
        /// Constructs the internal sprites needed for our demo.
        /// </summary>
        public DragMode()
        {
            // Create the fragment marbles
            int rows = 3;
            int cols = 3;
            int sx   = (SpriteDemosMain.Size.Width - cols * 50) / 2;
            int sy   = (SpriteDemosMain.Size.Height - rows * 50) / 2;
            SurfaceCollection   m1    = LoadMarble("marble1");
            SurfaceCollection   m2    = LoadMarble("marble2");
            AnimationCollection anim1 = new AnimationCollection();

            anim1.Add(m1);
            AnimationCollection anim2 = new AnimationCollection();

            anim2.Add(m2);
            AnimationDictionary frames = new AnimationDictionary();

            frames.Add("marble1", anim1);
            frames.Add("marble2", anim2);

            DragSprite dragSprite;

            for (int i = 0; i < cols; i++)
            {
                Thread.Sleep(10);
                for (int j = 0; j < rows; j++)
                {
                    dragSprite = new DragSprite(frames["marble1"],
                                                new Point(sx + i * 50, sy + j * 50)
                                                );
                    dragSprite.Animations.Add("marble1", anim1);
                    dragSprite.Animations.Add("marble2", anim2);
                    dragSprite.Animate = true;
                    if (Randomizer.Next(2) == 1)
                    {
                        dragSprite.AnimateForward = false;
                    }
                    Thread.Sleep(10);
                    Sprites.Add(dragSprite);
                }
            }
        }
Пример #8
0
        public void InitializeAnimations()
        {
            var w = (int)Size.X;
            var h = (int)Size.Y;

            // Right
            _animations.Add(PlayerAnimationNames.IdleRight, 1, new List <Rectangle> {
                new Rectangle(0, 0, w, h)
            });
            _animations.Add(PlayerAnimationNames.UseRight, 1, new List <Rectangle> {
                new Rectangle(32, 0, w, h)
            });
            _animations.Add(PlayerAnimationNames.WalkRight, 1, new List <Rectangle>
            {
                new Rectangle(64, 0, w, h),
                new Rectangle(96, 0, w, h),
                new Rectangle(128, 0, w, h),
                new Rectangle(160, 0, w, h),
                new Rectangle(192, 0, w, h),
                new Rectangle(224, 0, w, h),
                new Rectangle(256, 0, w, h),
                new Rectangle(288, 0, w, h),
            });

            // Left
            _animations.Add(PlayerAnimationNames.IdleLeft, 1, new List <Rectangle> {
                new Rectangle(0, 48, w, h)
            });
            _animations.Add(PlayerAnimationNames.UseLeft, 1, new List <Rectangle> {
                new Rectangle(32, 48, w, h)
            });
            _animations.Add(PlayerAnimationNames.WalkLeft, 1, new List <Rectangle>
            {
                new Rectangle(64, 48, w, h),
                new Rectangle(96, 48, w, h),
                new Rectangle(128, 48, w, h),
                new Rectangle(160, 48, w, h),
                new Rectangle(192, 48, w, h),
                new Rectangle(224, 48, w, h),
                new Rectangle(256, 48, w, h),
                new Rectangle(288, 48, w, h),
            });

            _animations.ChangeAnimation(PlayerAnimationNames.IdleRight);
        }
Пример #9
0
 /// <summary>
 /// Adds a FunctionCallAnimation to the collection
 /// This will invoke the function when this animation is played
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="action">The action to be invoked</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Invoke(this AnimationCollection animationCollection, Action action)
 {
     return(animationCollection.Add(new FunctionCallAnimation(action)));
 }
Пример #10
0
 /// <summary>
 /// Adds a WaitAnimation to the collection that will wait for the specified amount of seconds
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Wait(this AnimationCollection animationCollection, float duration)
 {
     return(animationCollection.Add(new WaitAnimation(duration)));
 }
Пример #11
0
 /// <summary>
 /// Adds a BlendShapeAnimation (in a DelegateAnimation) as a child of this AnimationCollection
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="target">The target SkinnedMeshRenderer</param>
 /// <param name="blendShapeIndex">The Blend Shape Index</param>
 /// <param name="to">To value</param>
 /// <param name="duration">Duration of the animation</param>
 /// <param name="easingFunction">The easing function for the interpolation</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection BlendShapeTo(this AnimationCollection animationCollection, SkinnedMeshRenderer target, int blendShapeIndex,
                                                float to = 100f, float duration = 1.0f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(target.BlendTo(blendShapeIndex, to, duration, easingFunction)));
 }
Пример #12
0
 /// <summary>
 /// Adds a UIFadeAnimation to the collection using a Graphic
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="graphic">The Graphic who's alpha will be faded</param>
 /// <param name="from">The start alpha value of the fade</param>
 /// <param name="to">The end alpha value of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Fade(this AnimationCollection animationCollection, Graphic graphic, float from, float to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(graphic.Fade(from, to, duration, easingFunction)));
 }
Пример #13
0
 /// <summary>
 /// Adds a ColorFadeAnimation to the animation collection
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="renderer">The renderer who's color will be faded</param>
 /// <param name="shaderProperty">The name of the target shader property</param>
 /// <param name="from">The start color of the fade</param>
 /// <param name="to">The end color of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection ColorFade(this AnimationCollection animationCollection, Renderer renderer, string shaderProperty, Color from, Color to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(renderer.ColorFade(shaderProperty, from, to, duration, easingFunction)));
 }
Пример #14
0
 /// <summary>
 /// Adds a UIFadeAnimation to the collection using a CanvasGroup
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="canvasGroup">The CanvasGroup who's alpha will be faded</param>
 /// <param name="from">The start alpha value of the fade</param>
 /// <param name="to">The end alpha value of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Fade(this AnimationCollection animationCollection, CanvasGroup canvasGroup, float from, float to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(canvasGroup.Fade(from, to, duration, easingFunction)));
 }
Пример #15
0
 /// <summary>
 /// Adds a MoveAnimation to the sequence that will move from the transform's current position to the specified position
 /// The current position will be the transform's position when the animation playback commences and not the position at the time of the creation of the animation
 /// </summary>
 /// <param name="animationCollection">The target animation sequence</param>
 /// <param name="rectTransform">The rect transform that will be used in the MoveAnimation</param>
 /// <param name="to">The end position (local) of the MoveAnimation</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection MoveAnchorTo(this AnimationCollection animationCollection, RectTransform rectTransform, Vector3 to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(rectTransform.MoveAnchorTo(to, duration, easingFunction)));
 }
Пример #16
0
 /// <summary>
 /// Adds a RotateAnimation to the collection, using local rotation
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="transform">The transform that will be used in the RotateAnimation</param>
 /// <param name="from">The start rotation (local) of the RotateAnimation</param>
 /// <param name="to">The end rotation (local) of the RotateAnimation</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection RotateLocal(this AnimationCollection animationCollection, Transform transform, Quaternion from, Quaternion to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(transform.RotateLocal(from, to, duration, easingFunction)));
 }
Пример #17
0
 /// <summary>
 /// Adds a UIColorFadeAnimation to the collection using a Graphic
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="graphic">The Graphic who's alpha will be faded</param>
 /// <param name="to">The end color value of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection ColorFadeTo(this AnimationCollection animationCollection, Graphic graphic, Color to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(graphic.ColorFadeTo(to, duration, easingFunction)));
 }
Пример #18
0
 /// <summary>
 /// Adds a CustomAnimation as a child of this AnimationCollection
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="customUpdate">A Custom Update function</param>
 /// <param name="from">From value</param>
 /// <param name="to">To value</param>
 /// <param name="duration">Duration of the animation</param>
 /// <param name="easingFunction">The easing function for the interpolation</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Custom(this AnimationCollection animationCollection, Action <float> customUpdate,
                                          float from = 0, float to = 1.0f, float duration = 1.0f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(new CustomAnimation(customUpdate, from, to, duration, easingFunction)));
 }
Пример #19
0
 /// <summary>
 /// Adds a ScaleAnimation to the collection that scales the Y component of the transform
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="transform">The transform that will be used in the ScaleAnimation</param>
 /// <param name="from">The start scale of the ScaleAnimation</param>
 /// <param name="to">The end scale of the ScaleAnimation</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection ScaleY(this AnimationCollection animationCollection, Transform transform, float from, float to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(transform.ScaleY(from, to, duration, easingFunction)));
 }
Пример #20
0
 /// <summary>
 /// Adds a FadeAnimation to the animation collection
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="renderer">The renderer who's alpha will be faded</param>
 /// <param name="shaderPropertyID">The ID of the target shader property</param>
 /// <param name="from">The start alpha value of the fade</param>
 /// <param name="to">The end alpha value of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Fade(this AnimationCollection animationCollection, Renderer renderer, int shaderPropertyID, float from, float to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(renderer.Fade(shaderPropertyID, from, to, duration, easingFunction)));
 }
Пример #21
0
 /// <summary>
 /// Adds a ColorFadeToAnimation to the animation collection
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="renderer">The renderer who's color will be faded</param>
 /// <param name="shaderPropertyID">The ID of the target shader property</param>
 /// <param name="to">The end color of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection ColorFadeTo(this AnimationCollection animationCollection, Renderer renderer, int shaderPropertyID, Color to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(renderer.ColorFadeTo(shaderPropertyID, to, duration, easingFunction)));
 }
Пример #22
0
 /// <summary>
 /// Adds an animation to the collection that activates (or deactivates) a GameObject
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="gameObject">The GameObject to activate or deactivate</param>
 /// <param name="value">A boolean value indicating the desired active state of the game object after this animation</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Activate(this AnimationCollection animationCollection, GameObject gameObject, bool value)
 {
     return(animationCollection.Add(new FunctionCallAnimation(() => gameObject.SetActive(value))));
 }
Пример #23
0
 /// <summary>
 /// Adds a RotateAnimation to the collection that will rotate from the transform's current rotation to the specified rotation
 /// The current rotation will be the transform's rotation when the animation playback commences and not the rotation at the time of the creation of the animation
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="transform">The transform that will be used in the RotateAnimation</param>
 /// <param name="to">The end rotation (local) of the RotateAnimation, expressed in eulerAngles</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <param name="useLocalRotation">Indicates if the animation will use localRotation</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection RotateTo(this AnimationCollection animationCollection, Transform transform, Quaternion to, float duration = 1f, Func <float, float> easingFunction = null, bool useLocalRotation = false)
 {
     return(animationCollection.Add(transform.RotateTo(to, duration, easingFunction, useLocalRotation)));
 }
Пример #24
0
 /// <summary>
 /// Adds an animation to the collection that enables (or disables) a Behaviour
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="behaviour">The Behaviour to enable or disable</param>
 /// <param name="value">A boolean value indicating the desired enabled state of the behaviour after this animation</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Enable(this AnimationCollection animationCollection, Behaviour behaviour, bool value)
 {
     return(animationCollection.Add(new FunctionCallAnimation(() => behaviour.enabled = value)));
 }
Пример #25
0
 /// <summary>
 /// Adds a FadeToAnimation to the animation collection
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="renderer">The renderer who's alpha will be faded</param>
 /// <param name="to">The end alpha value of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection FadeTo(this AnimationCollection animationCollection, SpriteRenderer renderer, float to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(renderer.FadeTo(to, duration, easingFunction)));
 }
Пример #26
0
 /// <summary>
 /// Adds a RotateAnimation to the collection that will rotate the transform by the offset specified from it's current rotation.
 /// The current rotation will be the transform's rotation when the animation playback commences and not the rotation at the time of the creation of the animation
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="transform">The transform that will be used in the MoveAnimation</param>
 /// <param name="offset">The offset or delta the animation will move the transform by</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection RotateRelative(this AnimationCollection animationCollection, Transform transform, Vector3 offset, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(transform.RotateRelative(offset, duration, easingFunction)));
 }
Пример #27
0
 /// <summary>
 /// Adds a RotateAnimation to the collection
 /// </summary>
 /// <param name="animationCollection">The target animation collection</param>
 /// <param name="transform">The transform that will be used in the RotateAnimation</param>
 /// <param name="from">The start rotation of the RotateAnimation expressed as eulerAngles</param>
 /// <param name="to">The end rotation of the RotateAnimation expressed as eulerAngles</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Rotate(this AnimationCollection animationCollection, Transform transform, Vector3 from, Vector3 to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(transform.Rotate(from, to, duration, easingFunction)));
 }
Пример #28
0
        public HeroExample()
        {
            // Start up the window
            Video.WindowIcon();
            Video.WindowCaption = "SDL.NET - Hero Example";
            Video.SetVideoMode(400, 300);

            string filePath      = Path.Combine("..", "..");
            string fileDirectory = "Data";
            string fileName      = "hero.png";

            if (File.Exists(fileName))
            {
                filePath      = "";
                fileDirectory = "";
            }
            else if (File.Exists(Path.Combine(fileDirectory, fileName)))
            {
                filePath = "";
            }

            string file = Path.Combine(Path.Combine(filePath, fileDirectory), fileName);

            // Load the image
            Surface image = new Surface(file);

            // Create the animation frames
            SurfaceCollection walkUp = new SurfaceCollection();

            walkUp.Add(image, new Size(24, 32), 0);
            SurfaceCollection walkRight = new SurfaceCollection();

            walkRight.Add(image, new Size(24, 32), 1);
            SurfaceCollection walkDown = new SurfaceCollection();

            walkDown.Add(image, new Size(24, 32), 2);
            SurfaceCollection walkLeft = new SurfaceCollection();

            walkLeft.Add(image, new Size(24, 32), 3);

            // Add the animations to the hero
            AnimationCollection animWalkUp = new AnimationCollection();

            animWalkUp.Add(walkUp, 35);
            hero.Animations.Add("WalkUp", animWalkUp);
            AnimationCollection animWalkRight = new AnimationCollection();

            animWalkRight.Add(walkRight, 35);
            hero.Animations.Add("WalkRight", animWalkRight);
            AnimationCollection animWalkDown = new AnimationCollection();

            animWalkDown.Add(walkDown, 35);
            hero.Animations.Add("WalkDown", animWalkDown);
            AnimationCollection animWalkLeft = new AnimationCollection();

            animWalkLeft.Add(walkLeft, 35);
            hero.Animations.Add("WalkLeft", animWalkLeft);

            // Change the transparent color of the sprite
            hero.TransparentColor = Color.Magenta;
            hero.Transparent      = true;

            // Setup the startup animation and make him not walk
            hero.CurrentAnimation = "WalkDown";
            hero.Animate          = false;
            // Put him in the center of the screen
            hero.Center = new Point(
                Video.Screen.Width / 2,
                Video.Screen.Height / 2);
        }
Пример #29
0
 /// <summary>
 /// Adds a MoveAnimation to the sequence that will move from the transform's current position to the specified position
 /// The current position will be the transform's position when the animation playback commences and not the position at the time of the creation of the animation
 /// </summary>
 /// <param name="animationCollection">The target animation sequence</param>
 /// <param name="transform">The transform that will be used in the MoveAnimation</param>
 /// <param name="to">The end position (local) of the MoveAnimation</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <param name="useLocalPosition">Indicates if the animation will use localPosition</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection MoveTo(this AnimationCollection animationCollection, Transform transform, Vector3 to, float duration = 1f, Func <float, float> easingFunction = null, bool useLocalPosition = false)
 {
     return(animationCollection.Add(transform.MoveTo(to, duration, easingFunction, useLocalPosition)));
 }