我正在制作一个迷宫游戏,并且我已将生命设置为 5。与往常一样,在表格的顶部,我有:
Dim lives As Integer = 5
在我制作的表格的下方,当用户点击边界时,图片框会移回它的起始位置并扣除一个生命。然而,除了第一个初始生命失去时,这一切都有效,它减去 2 生命而不是 1。我使用的代码是这样的:
Private Sub PictureBoxPlayer_move(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBoxPlayer.Move
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall12.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall11.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall9.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall8.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall7.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall6.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall5.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall4.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall3.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall2.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall1.Bounds) Then
PictureBoxPlayer.Location = New Point(44, 503)
lives -= 1
LabelLives.Text = lives
End If
End Sub
我可能做错了什么?