InteractionTracker.PositionVelocityInPixelsPerSecond Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Kecepatan saat ini diterapkan pada posisi.
Properti PositionVelocityInPixelsPerSecond mewakili kecepatan posisi InteractionTracker saat ini di Inertia. Ada dua kasus penggunaan utama untuk properti ini: Mengambil kecepatan posisi InteractionTracker tepat setelah interaksi terjadi atau mereferensikan kecepatan InteractionTracker terbaru dalam ExpressionAnimation.
public:
property float3 PositionVelocityInPixelsPerSecond { float3 get(); };
float3 PositionVelocityInPixelsPerSecond();
public Vector3 PositionVelocityInPixelsPerSecond { get; }
var vector3 = interactionTracker.positionVelocityInPixelsPerSecond;
Public ReadOnly Property PositionVelocityInPixelsPerSecond As Vector3
Nilai Properti
Kecepatan saat ini diterapkan pada posisi.
Contoh
// 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);
}
Keterangan
Saat mengakses properti PositionVelocityInPixelsPerSecond dari peristiwa InertiaStateEntered , Anda akan mengambil rekam jepret kecepatan terhitung berdasarkan interaksi. Kejadian ini hanya akan diaktifkan sekali setelah interaksi terjadi.