我一直在 VB 2010 express 中制作这款游戏,这是我的第一款游戏。我正在使用图片框作为我的角色屋湖箱等。我一直有一些问题。其中之一是当我的角色(Picturebox1/myplayer)触摸胸部(Picturebox2)时,我可以选择打开胸部并离开它。如果您选择打开箱子,您将获得 10 个硬币。但是当我打开箱子并拿到 10 枚硬币时,我无法让它无法使用,所以我可以无限次进行并且仍然可以获得硬币。
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
任何人都可以帮助我吗?