>In an application I have a form in which you can move shapes around.
>I need to know when two shape was in contact to each other.
>
OK, I have the solution :-)
I added a IsCollision Method in the shape class and this method was called from the MouseUp event.
The method use a revert logic (?) to detect cases when the collision can NOT occur and return .F. in that case.
Only 4 small test by shape in the parent.
x1=this.Left
x2=this.Left+this.Width
y1=this.Top
y2=this.Top+this.Height
FOR i=1 TO this.parent.ControlCount
lTouch=.F.
oPan=this.parent.Controls(i)
IF oPan.Class=this.Class AND oPan <> this
lTouch=.T.
DO CASE
CASE oPan.Top>=y2
lTouch=.F.
CASE oPan.Left>=x2
lTouch=.F.
CASE oPan.Top+oPan.Height<=y1
lTouch=.F.
CASE oPan.Left+oPan.Width<=x1
lTouch=.F.
ENDCASE
ENDIF
oPan=.NULL.
IF lTouch
RETURN .T.
ENDIF
ENDFOR
RETURN .F.
:-)
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca