私はc#とwpfを学んでいます。Visual Studio 2012 でプロジェクトを実行しています。C# と WPF をよりよく学ぶために、Simon Says ゲームである練習用アプリケーションを作成しています。私は2つの窓を持っています。最初のウィンドウには「PLAY!」があります。次のウィンドウを表示するボタン。このウィンドウには 4 つのボタンがあります。プレーヤーが順番にボタンを押す必要があるように、整数の配列があります。プレーヤーに順序を示すために、配列で生成された順序で各ボタンを 1 つずつアニメーション化したいと考えました。
ボタンは 4 つの異なる色で、それぞれのアニメーションは Blend のストーリーボードから作成しました。アニメーションにより、ボタンが元の色から赤に変わり、2 秒間かけて元の色に戻ります。
アニメーションは正常に動作しますが、すべてのボタンが同時にアニメーション化されます。最初のボタンをアニメーション化し、それが終了したら次のボタンなどを動かしたかったのです。C# と WPF を使用してこれを行うにはどうすればよいでしょうか。助けてくれてありがとう。必要に応じてコードをアップロードできます。
アニメーションを実行する関数
public void startbtn_Click(object sender, RoutedEventArgs e)
{
// Show the animation sequence for each button
// up until the current level. (getCurrentLevel is currently set to 5)
for (int i = 0; i <= engine.getCurrentLevel(); i++)
{
// engine.animate(i) returns the button at sequence i to animate
animate(engine.animate(i));
}
}
private void animate(int index)
{
// Storyboard for each button is in the format of ButtonAnimation_INDEX where INDEX is 1, 2, 3 or 4
Storyboard btnAnimation = (Storyboard)this.Resources["ButtonAnimation_" + index];
if (btnAnimation != null)
{
btnAnimation.Begin();
}
}