【发布时间】:2014-11-12 12:42:50
【问题描述】:
我正在尝试根据 3 个数组列表随机生成图片框(stickimage)将出现的 3 个不同位置。
到目前为止我的代码:
Private Sub GenerateObjects()
Dim RandomClass As New Random() 'Generate random number
Dim Y As Integer 'Y axis
Dim ObstaclePos(3) As Integer 'Position where obstacle is allocated
ObstaclePos(1) = 404
ObstaclePos(2) = 310
ObstaclePos(3) = 290
Me.stickImage.Left -= 20
If stickImage.Bounds.IntersectsWith(LeftStickBrake.Bounds) Then
For pos = 1 To 3
Y = 'This is where I am stuck
stickImage.Location = New Point(1014, Y)
Next pos
End If
End Sub
【问题讨论】:
-
Y = ObstaclePos(RandomClass.Next(1, 4))
标签: .net arrays vb.net random basic