0
我一直在使用VB 2010中的這個遊戲快車,這是我的第一場比賽。而我正在使用pictureboxes作爲我的角色屋湖箱等。我一直在與它有幾個問題。其中之一就是我讓我的角色(Picturebox1/myplayer)觸摸胸部(Picturebox2)時,它會讓我選擇打開胸部或胸部。如果你的選擇是打開胸部,你會得到10個硬幣。但是當我打開箱子並拿到了10個硬幣時,我無法讓它變得無法使用,所以我可以做到無窮無盡的時間,並且還能獲得硬幣。VB.net如何使一個picturebox不可用
Private Sub mymap_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim Loc As Point
Select Case e.KeyCode
Case Keys.W
If Not myplayer.Location.Y - 5 < 0 Then
Loc = New Point(myplayer.Location.X, myplayer.Location.Y - 5)
myplayer.Location = Loc
End If
Case Keys.S
If Not myplayer.Location.Y + 5 < 0 Then
Loc = New Point(myplayer.Location.X, myplayer.Location.Y + 5)
myplayer.Location = Loc
End If
Case Keys.A
If Not myplayer.Location.X - 5 < 0 Then
Loc = New Point(myplayer.Location.X - 5, myplayer.Location.Y)
myplayer.Location = Loc
End If
Case Keys.D
If Not myplayer.Location.X + 5 < 0 Then
Loc = New Point(myplayer.Location.X + 5, myplayer.Location.Y)
myplayer.Location = Loc
End If
End Select
If myplayer.Bounds.IntersectsWith(PictureBox2.Bounds) Then
Chest1.Show()
End If
End Sub
然後它打開打開胸部或不打開之間的選項。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
MsgBox("You found 10 coins in the chest")
Form1.ProgressBar1.Increment(10)
HouseBuy.ProgressBar1.Increment(10)
HouseSell.ProgressBar1.Increment(10)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
End Sub
可以any1幫助我嗎?
'picturebox2。 enabled = false'或者'button1.enabled = fale'不確定是否要禁用給出硬幣的圖片框或按鈕 – Plutonix
或者只是設置一個標誌或狀態表示發生了動作,並在隨後的點擊中檢查它。 –