Ejemplo n.º 1
0
        private void CreateTweeners()
        {
            float start = GraphicsDevice.Viewport.Width * 0.1f;
            float end   = GraphicsDevice.Viewport.Width * 0.9f;

            frontToBackTweener = new Tweener(start, end, 3, Quadratic.EaseInOut);
            frontToBackTweener.Loop.FrontToBack();
            frontToBackTimesTweener = new Tweener(start, end, 3, Quadratic.EaseInOut);
            Loop.FrontToBack(frontToBackTimesTweener, 5);
            backAndForthTweener = new Tweener(start, end, 3, Sinusoidal.EaseInOut);
            Loop.BackAndForth(backAndForthTweener);
            backAndForthTimesTweener = new Tweener(start, end, 3, Sinusoidal.EaseInOut);
            backAndForthTimesTweener.Loop.BackAndForth(5);
        }
Ejemplo n.º 2
0
        public void LoopingBackAndForthWillWork()
        {
            float   from    = 0;
            float   to      = 100;
            Tweener tweener = new Tweener(from, to, 4, Linear.EaseNone);

            Loop.BackAndForth(tweener);
            for (int i = 0; i < 5; i++)
            {
                tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
                Assert.Greater(tweener.Position, from, "We have moved from the start, again");
                tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
                Assert.AreEqual(to, tweener.Position, "We are at the end");
                tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
                Assert.Less(tweener.Position, to, "We now on the way back");
                tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
                Assert.AreEqual(from, tweener.Position, "We now at the start");
            }
        }
Ejemplo n.º 3
0
        public void LoopoingBackAndForthANumberOfTimesWillWork()
        {
            float   from    = 0;
            float   to      = 100;
            int     times   = 4;
            Tweener tweener = new Tweener(from, to, 4, Linear.EaseNone);

            Loop.BackAndForth(tweener, times);
            for (int i = 0; i < times; i++)
            {
                tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
                Assert.Greater(tweener.Position, from, "We have moved from the start, again");
                tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
            }
            bool positionChanged = false;

            tweener.PositionChanged += delegate { positionChanged = true; };
            tweener.Update(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)));
            Assert.IsFalse(positionChanged, "The tweener is no longer active as it has looped as many times as it should");
        }