private void timer1_Tick(object sender, EventArgs e) { time++; background.Margin = new Thickness(background.Margin.Left - 0.5, background.Margin.Top, 0, 0); for (int i = 2; i < total + 2; i++) { /*if (distance < 40 || distance >= 70) {*/ //Canvas.SetTop(canvas.Children[i], Canvas.GetTop(canvas.Children[i]) - 6 + difficulty / 7); Canvas.SetLeft(canvas.Children[i], Canvas.GetLeft(canvas.Children[i]) -3 - difficulty / 7); if (Canvas.GetLeft(image) + 70 > Canvas.GetLeft(canvas.Children[i]) && Canvas.GetLeft(canvas.Children[i]) > 30) if ((Canvas.GetTop(image) + image.Height >= Canvas.GetTop(canvas.Children[i]) && Canvas.GetTop(image) + image.Height <= Canvas.GetTop(canvas.Children[i]) + 155) || (Canvas.GetTop(image) >= Canvas.GetTop(canvas.Children[i]) && Canvas.GetTop(image) <= Canvas.GetTop(canvas.Children[i]) + 155)) { player.Stop(); money.Stop(); timer.Stop(); MessageBox.Show("飛行時間:" + distance + "秒"); MainWindow mw = new MainWindow(); this.Close(); mw.Show(); } } }
private void ReturnToMainWindow(object sender, RoutedEventArgs e) { MainWindow mw = new MainWindow(); this.Close(); mw.Show(); }