InteractionTracker.PositionVelocityInPixelsPerSecond Свойство

Определение

Скорость, применяемая в настоящее время к позиции.

Свойство PositionVelocityInPixelsPerSecond представляет текущую скорость позиции InteractionTracker в состоянии инерции. Существует два main вариантов использования этого свойства: получение скорости позиции InteractionTracker сразу после того, как произошло взаимодействие, или ссылка на самую текущую скорость InteractionTracker в ExpressionAnimation.

public:
 property float3 PositionVelocityInPixelsPerSecond { float3 get(); };
float3 PositionVelocityInPixelsPerSecond();
public Vector3 PositionVelocityInPixelsPerSecond { get; }
var vector3 = interactionTracker.positionVelocityInPixelsPerSecond;
Public ReadOnly Property PositionVelocityInPixelsPerSecond As Vector3

Значение свойства

Vector3 Vector3

float3

Скорость, применяемая в настоящее время к позиции.

Примеры

// Listen for the InertiaStateEntered event, so we can grab PositionVelocityInPixelsPerSecond value.
public void InertiaStateEntered(InteractionTracker sender, InteractionTrackerInertiaStateEnteredArgs args)
{
  // Grab the current velocity of InteractionTracker after interaction occurs out of the args when the event is fired.
  Vector3 interactionVelocity = args.PositionVelocityInPixelsPerSecond;}
}

void CustomSpringMotion(float springCoefficient, float dampingCoefficient, float maxPosition)
{
  // Create the InertiaModifier that will be a custom motion emulating a spring
  InteractionTrackerInertiaMotion modifier = InteractionTrackerInertiaMotion.Create(_compositor);

  modifier.Condition = _compositor.CreateExpressionAnimation("this.Target.NaturalRestingPosition.X > maxPosition");
  modifier.Condition.SetScalarParameter("maxPosition", maxPosition);

  // Utilize the current Velocity of InteractionTracker in the Expression defining 	the custom spring motion
  modifier.Motion = _compositor.CreateExpressionAnimation("(-springStiffnessCoefficient * (this.Target.Position.X – maxPosition)) + (-dampingCoefficient * this.target.PositionVelocityInPixelsPerSecond.X");
  modifier.Motion.SetScalarParameter("springStiffnessCoefficient", 	springCoefficient);
  modifier.Motion.SetScalarParameter("dampingCoefficient", dampingCoefficient);
  modifier.Motion.SetScalarParameter("maxPosition", maxPosition); 
}

Комментарии

При доступе к свойству PositionVelocityInPixelsPerSecond из события ИнерцияStateEntered вы будете получать snapshot вычисляемой скорости на основе взаимодействия. Это событие срабатывает только один раз после взаимодействия.

Применяется к