I've been working on a 2-D Platformer shoot-em-up and I've encountered an error.
When I try to run my program, I'm struck by a "Object reference not set to an instance of an object." I'm not entirely sure WHY this is happening but it has to do with my monster's spawning.
The code I have for spawning is
Dim i As Integer = 19
Dim Bats(i) As PictureBox
Dim Slime(i) As PictureBox
and
For Me.i = 1 To 1
Me.Controls.Add(Bats(i))
Me.Controls.Add(Slime(i))
Bats(i) = New PictureBox
Slime(i) = New PictureBox
Bats(i).Location = New Point(12, 415)
Bats(i).Size = New Size(50, 50)
Bats(i).BackgroundImage = My.Resources.Bat
Slime(i).Location = New Point(666, 415)
Slime(i).Size = New Size(50, 25)
Slime(i).BackgroundImage = My.Resources.slime
Next i
and the code that I'm getting the error from is...
If picAttack.Bounds.IntersectsWith(Bats(i).Bounds) Then
If prgEXP.Value >= prgEXP.Maximum Then
lblLevelCounter.Text = lblLevelCounter.Text + 1
prgEXP.Value = 0
prgEXP.Maximum = prgEXP.Maximum * 2
prgLife.Maximum = prgLife.Maximum + 50
prgLife.Value = prgLife.Maximum
lblLifeValue.Text = prgLife.Value & "/" & prgLife.Maximum
End If
I'm kind of a beginner so I wouldn't be surprised if it was just something I'm over-looking, but it would be helpful if someone could point out where I'm going wrong...
Thanks for the assistance and I'm looking forward to an answer so I can finish this project.
-Ash
AshinoxVGs, on 11 December 2012 - 06:47 PM, said:
and unfortunately, I cannot move this project over to C++, C#, Java, python, etc...
because this is my computer science final project and we have to use VB.Net

New Topic/Question
Reply



MultiQuote




|