Пример #1
0
        /// <inheritdoc />
        public override void Update(float frameTime)
        {
            base.Update(frameTime);

            if (sprite == null || IsSlaved())
            {
                return;
            }

            var worldRot = Owner.GetComponent <TransformComponent>().Rotation.ToVec();

            // world2screen
            worldRot = new Vector2(worldRot.X, worldRot.Y * -1);

            //If the sprite is idle, it won't try to update Direction, meaning you stay facing the way you move
            if (sprite.CurrentAnimationStateKey.Equals("idle"))
            {
                sprite.Update(frameTime);
            }
            else
            {
                sprite.Direction = worldRot.GetDir();
                sprite.Update(frameTime);
            }
        }
        /// <inheritdoc />
        public override void Update(float frameTime)
        {
            var transform = Owner.GetComponent <TransformComponent>();
            var physics   = Owner.GetComponent <PhysicsComponent>();

            physics.Velocity   = _moveDir * (_run ? FastMoveSpeed : BaseMoveSpeed);
            transform.Rotation = (float)(_moveDir.LengthSquared > 0.001 ? _moveDir.GetDir() : Direction.South).ToAngle();

            base.Update(frameTime);
        }