Wir öffnen das Testprogram und erzeugen fünf
FloatAnimatoren, sowie ein AnimatorSet.
LinearAnimator LinearAnimator1 = new LinearAnimator();
LinearAnimator LinearAnimator2 = new LinearAnimator();
LinearAnimator LinearAnimator3 = new LinearAnimator();
LinearAnimator LinearAnimator4 = new LinearAnimator();
LinearAnimator LinearAnimator5 = new LinearAnimator();
AnimatorSet AnimatorSet = new AnimatorSet();
Wir initialisieren im Createabschnitt
protected override void OnCreated()
{
base.OnCreated();
Cone.Material = Materials.Gold;
AnimatorSet.Device = this;
LinearAnimator1.Device = this;
LinearAnimator2.Device = this;
LinearAnimator3.Device = this;
LinearAnimator4.Device = this;
LinearAnimator5.Device = this;
Sphere1.CompileEnable = false;
AnimatorSet.ChildAnimations.Add(LinearAnimator1);
LinearAnimator1.FromValue = new xyz(8, 0, 0);
LinearAnimator1.ToValue = new xyz(8, 8, 0);
LinearAnimator1.Animate += LinearAnimator_Animate;
AnimatorSet.ChildAnimations.Add(LinearAnimator2);
LinearAnimator2.Device = this;
LinearAnimator2.FromValue = new xyz(8, 8, 0);
LinearAnimator2.ToValue = new xyz(-8, 8, 0);
LinearAnimator2.Animate += LinearAnimator_Animate;
AnimatorSet.ChildAnimations.Add(LinearAnimator3);
LinearAnimator3.Device = this;
LinearAnimator3.FromValue = new xyz(-8, 8, 0);
LinearAnimator3.ToValue = new xyz(-8, -8, 0);
LinearAnimator3.Animate += LinearAnimator_Animate;
AnimatorSet.ChildAnimations.Add(LinearAnimator4);
LinearAnimator4.Device = this;
LinearAnimator4.FromValue = new xyz(-8, -8, 0);
LinearAnimator4.ToValue = new xyz(8, -8, 0);
LinearAnimator4.Animate += LinearAnimator_Animate;
AnimatorSet.ChildAnimations.Add(LinearAnimator5);
LinearAnimator5.Device = this;
LinearAnimator5.FromValue = new xyz(8, -8, 0);
LinearAnimator5.ToValue = new xyz(8,0, 0);
LinearAnimator5.Animate += LinearAnimator_Animate;
AnimatorSet.Start();
}
´
Dazu müssen wir das Event
LinearAnimator_Animate definieren
private void LinearAnimator_Animate(object sender, System.EventArgs e)
{
Sphere1.Center = (sender as LinearAnimator).Value;
}
Hier der Code