我正在制作一个简单的游戏,用户选择两种武器(主要和次要)。在游戏窗口中,武器显示在屏幕一角的图片框(picWeapon)中。我希望用户能够向上滚动(或向下滚动,因为只有一种其他武器)来选择辅助武器。我使用鼠标滚轮在图像中循环的代码是什么?
答案 0 :(得分:0)
Private isPrimary As Boolean = True 'assumes the Primary image is already loaded
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If e.Delta > 0 And isPrimary = False Then
Debug.WriteLine("Scrolled up!")
PicWeapon.Load(filepathOfPrimary)
isPrimary = True
ElseIF isPrimary = True Then
Debug.WriteLine("Scrolled down!")
PicWeapon.Load(filepathOfSecondary)
isPrimary = False
End If
End Sub