VB.Net question

Dec 6, 2009 at 7:28 AM

I am trying to write a Farseer game using VB.Net.  How do you wire up the OnCollision and OnSeperate events in VB.Net?  Normally, I do it like this.


AddHandler MyGeom.OnCollison, AddressOf MyOnCollision
...
Private Function MyOnCollision()
...
End Function

But, when I tried this, the compiler said that OnCollision was not an event of MyGeom.

Thanks,

Mike

Coordinator
Dec 6, 2009 at 3:15 PM

I have no idea on how to do it in VB.net, but the OnCollision is not an event, it is a delegate. Does that make any difference in VB.net? in C# you subscribe to it the exact same way.

Dec 7, 2009 at 1:20 AM

Appearantly it does.  When I tried to add the code

AddHandler MyGeom.OnCollison, AddressOf MyOnCollision

I got a compiler error that said OnCollision was not an event.  So, it looks like it is handled differently.  But, I don't know what the syntax is.  Any help with that would be appreciated.

Thanks,

Mike

Dec 7, 2009 at 3:37 AM

I figured it out.  The syntax should look like this.

objGeom.OnCollision = System.Delegate.Combine(objGeom.OnCollision, New CollisionEventHandler(AddressOf OnCollision))

Thanks,

Mike