Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

[RESOLVED] [VB2010] - how use the rectangule Intersection?

$
0
0
i'm testing a collision with rectangule Intersection, but i get an error:
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

error message:
"A first chance exception of type 'System.NullReferenceException' occurred in WindowsApplication9.exe"
can anyone tell me what i'm doing wrong?

Viewing all articles
Browse latest Browse all 27353

Trending Articles