ユーザーがゲームを終了したときにコードにオプションを配置できるようにしたいのですが、「もう一度プレイ」ボタンが表示され、クリックするとゲームを最初からやり直すことができます。以下は、私のコードが現在どのように見えるかです。ユーザーがゲームを終了したときに、ユーザーがゲームを再開できるように、[再試行] ボタンを追加できるようにしたいと考えています。
Private Sub btnSubmit_Click(sender As Object, e As RoutedEventArgs) Handles btnSubmit.Click
Dim i As Integer
For i = 0 To 244
If txtbWords.Text = strArr(i) Then
score = score + txtbWords.Text.Length
strArr(i) = ""
End If
Next i
txtScore.Text = "Score: " & score
End Sub
Private Sub MainPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
txtA.Visibility = Windows.UI.Xaml.Visibility.Collapsed
txtC.Visibility = Windows.UI.Xaml.Visibility.Collapsed
txtE.Visibility = Windows.UI.Xaml.Visibility.Collapsed
btnSubmit.Visibility = Windows.UI.Xaml.Visibility.Collapsed
txtbWords.Visibility = Windows.UI.Xaml.Visibility.Collapsed
End Sub
Private i As Integer = 0
Private j As Integer = 3
Public Sub Each_Tick(ByVal o As Object, ByVal sender As EventArgs)
i = i + 1
If i = 60 Then
myDispatcherTimer.Stop() 'Game ends here.
btnSubmit.Visibility = Windows.UI.Xaml.Visibility.Collapsed
End If
myTextBlock.Text = i
End Sub
Private Sub btnStart_Click(sender As Object, e As RoutedEventArgs) Handles btnStart.Click
txtA.Visibility = Windows.UI.Xaml.Visibility.Visible
txtC.Visibility = Windows.UI.Xaml.Visibility.Visible
txtE.Visibility = Windows.UI.Xaml.Visibility.Visible
txtK.Visibility = Windows.UI.Xaml.Visibility.Visible
btnSubmit.Visibility = Windows.UI.Xaml.Visibility.Visible
txtbWords.Visibility = Windows.UI.Xaml.Visibility.Visible
btnStart.Visibility = Windows.UI.Xaml.Visibility.Collapsed
myDispatcherTimer.Interval = New TimeSpan(0, 0, 0, 0, 1000)
' 100 Milliseconds
AddHandler myDispatcherTimer.Tick, AddressOf Me.Each_Tick
myDispatcherTimer.Start()
End Sub