我希望能够在用户完成游戏后在代码中添加选项,再次显示“再次播放”按钮,点击后游戏可以全部开始供用户播放。下面是我的代码现在的样子,我希望能够添加Try Again按钮,这样当用户完成游戏后,用户可以再次开始玩游戏。
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