i'm testing a collision with rectangule Intersection, but i get an error:
error message:
"A first chance exception of type 'System.NullReferenceException' occurred in WindowsApplication9.exe"
can anyone tell me what i'm doing wrong?
Code:
Private Sub Sprite2D_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
Dim Rec1 As New Rectangle(Me.Top, Me.Left, Me.Width, Me.Height)
Dim Rec2 As New Rectangle(Me.Top, Me.Left, Me.Width, Me.Height)
For Each ctlName As Control In Me.Parent.Controls
If ctlName.Name <> Me.Name Then
Rec2 = New Rectangle(ctlName.Left, ctlName.Top, ctlName.Width, ctlName.Height)
If Rec1.IntersectsWith(Rec2) Then
RaiseEvent Collision(ctlName)
End If
End If
Next
End Sub
"A first chance exception of type 'System.NullReferenceException' occurred in WindowsApplication9.exe"
can anyone tell me what i'm doing wrong?