Beispiel #1
0
 private void SetupFlyinAnim()
 {
     flyinAnim = new Animator()
     {
         OnCompleted = () =>
         {
             currentIndex       = newIndex;
             drawPrev           = imgs.Count > 0 && currentIndex > 0;
             drawNext           = currentIndex < imgs.Count - 1;
             opacityBrush.Color = Color.FromArgb(0, Color.Black);
             RecalcImageRect();
         }
     };
     flyinAnim.Add(new Step
     {
         Interval   = 20, // ms
         TotalStep  = step,
         AnimAction = (stepI) =>
         {
             // current
             currentImgRect     = currentImgRect.AdjustXF(direction * vCurrentHor);
             opacityBrush.Color = Color.FromArgb(255 - stepI * opacityStep, Color.Black);
             // next
             newImgRect = newImgRect.AdjustSizeFromCenter(vNewHor, vNewVer);
             Invalidate();
         }
     });
 }
Beispiel #2
0
        private void LoadAnimator(Texture2D texture)
        {
            AeAnimation      animation = new AeAnimation(texture, Animator);
            AeAnimationFrame frame1    = new AeAnimationFrame(0, 0, animation.Texture.Width, animation.Texture.Height, -1);

            SizeX = animation.Texture.Width;
            SizeY = animation.Texture.Height;
            animation.AddFrame(frame1);
            Animator.Add("default", animation);
            CollisionHull.SetSize((int)SizeX, (int)SizeY);
        }
Beispiel #3
0
        public Player(string name = "Player") : base(name, null)
        {
            Tag = "Player";

            AddComponent(new Animator());
            AddComponent(new Collider());
            AddComponent(new PhysicsBody());

            Animator = GetComponent <Animator>();
            Collider = GetComponent <Collider>();
            Body     = GetComponent <PhysicsBody>();

            Body.Mass       = 10;
            Body.Elasticity = 0;
            Collider.CoefficientOfFriction = 0.2;

            Animator.Add(Resources.GetAnimation("Idle"));
            Animator.Add(Resources.GetAnimation("Running"));
            Animator.Add(Resources.GetAnimation("Jumping"));

            Camera = new Camera("Player Camera");
            Transform.AddChild(Camera.Transform);
        }
Beispiel #4
0
        private void SetupAnimator(int x, int y)
        {
            _animator = new Animator()
            {
                Loop = true
            };

            int increaseX = 1;
            int increaseY = 1;

            _animator.Stop();
            _animator.Clear();

            // move top
            _animator.Add(new Step
            {
                Interval   = 25,
                TotalStep  = y,
                AnimAction = (stepI) =>
                {
                    _bgImageRect = _bgImageRect.MoveY(-increaseY);
                    Invalidate();
                }
            });

            // move left
            _animator.Add(new Step
            {
                Interval   = 25,
                TotalStep  = x,
                AnimAction = (stepX) =>
                {
                    _bgImageRect = _bgImageRect.MoveX(-increaseX);
                    Invalidate();
                }
            });

            // move bottom
            _animator.Add(new Step
            {
                Interval   = 25,
                TotalStep  = y,
                AnimAction = (stepI) =>
                {
                    _bgImageRect = _bgImageRect.MoveY(increaseY);
                    Invalidate();
                }
            });

            // move right
            _animator.Add(new Step
            {
                Interval   = 25,
                TotalStep  = x,
                AnimAction = (stepX) =>
                {
                    _bgImageRect = _bgImageRect.MoveX(increaseX);
                    Invalidate();
                }
            });
        }