我已经更新了代码,现在它说索引超出了数组的范围,而且我在高中的cs1,并且意外地使用我的学校谷歌帐户制作了这个帐户。我已经包含了特定的代码来移动砖块(只是一点点),数组的代码,以及整个计时器块的代码,正如你所看到的,是非常有组织的区域
Dim newbrickx, newbricky As Integer
newbrickx = bricks(i).Location.X
newbricky = bricks(i).Location.Y + 10
'left wall
If (lblball.Location.X >= Me.ClientSize.Width - lblball.Width) Then
bricks(i).Location = New Point(newbrickx, newbricky)
End If
'right wall
If (lblball.Location.X = 0) Then
bricks(i).Location = New Point(newbrickx, newbricky)
End If
数组(在form load事件中)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
bricks = New PictureBox() {PictureBox1, PictureBox2, PictureBox3, PictureBox4, PictureBox5, PictureBox6, PictureBox7, PictureBox8}
End Sub
我还没有写评论的名声,所以我这样做。我假设bricks是一个包含图片盒的数组。因此,在条件块中你可以像这样分配新位置:
bricks(i).Location = New Point(newbrickx, newbricky)
如前所述,你可能还应该检查y坐标,以确保它没有越界。