我正在尝试制作迷宫游戏,但这是我似乎无法开始工作的唯一代码。我希望图片框(播放器)沿箭头键的方向移动。我试过这段代码:
Private Sub BLevel1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = 37 Then
PictureBoxPlayer.Left = PictureBoxPlayer.Left - 10
ElseIf e.KeyCode = 38 Then
PictureBoxPlayer.Top = PictureBoxPlayer.Top - 10
ElseIf e.KeyCode = 39 Then
PictureBoxPlayer.Left = PictureBoxPlayer.Left + 10
ElseIf e.KeyCode = 40 Then
PictureBoxPlayer.Top = PictureBoxPlayer.Top + 10
End If
End Sub
我也尝试过位置代码,但箭头键似乎没有移动图片框。这是我遇到的唯一问题。关于如何解决这个问题的任何想法?