Private Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
If Action = Panel1.TOUCH_ACTION_DOWN Then
Dim p As B2Vec2 = X2.ScreenPointToWorld(X, Y)
'cast a ray from the kid to the point
RaycastBody = Null
RaycastPoint = p
world.RayCast(mKid.bw.Body.Position, p)
If RaycastBody <> Null And RaycastBody.IsDeleted = False Then
'ray hit a body
RaycastBody.TimeToLiveMs = 1
End If
CreateLaser
End If
End Sub
Private Sub World_RaycastCallback (Fixture As B2Fixture, Point As B2Vec2, Normal As B2Vec2, Fraction As Float) As Float
Dim bw As X2BodyWrapper = Fixture.Body.Tag
'ignore static bodies
If bw.Body.BodyType = bw.Body.TYPE_STATIC Then Return -1
RaycastBody = bw
RaycastPoint = Point.CreateCopy
'return fraction to limit the ray up to the current fixture.
'The result is that the last event will be the closest body.
Return Fraction
End Sub