Ako imas vise tela, pa trebas proveriti dodir izmedju bilo koja dva bolje resenje je da napravis funkciju koja proverava dodir:
x1 - x koordinata prvog tela
y1 - y koordinata prvog tela
s1 - x sirina prvog tela
v1 - x visina prvog tela
x2 - x koordinata II tela
y2 - y koordinata II tela
s2 - x sirina II tela
v2 - x visina II tela
Function Provera_Dodira(x1 as integer,y1 as integer,s1 as integer,v1 as integer,x2 as integer,y2 as integer,s2 as integer,v2 as integer) as Boolean
If (x1 >= x2 And x1 <= x2+s2 And y1 >= y2 And y1 <= y2+v2) Then
Provera_Dodira=True
Exit Function
End If
If (x1+s1 >= x2 And x1+s1 <= x2+s2 And y1 >= y2 And y1 <= y2+v2) Then
Provera_Dodira=True
Exit Function
End If
If (x1 >= x2 And x1 <= x2+s2 And y1+v1 >= y2 And y1+v1 <= y2+v2) Then
Provera_Dodira=True
Exit Function
End If
If (x1+s1 >= x2 And x1+s1 <= x2+s2 And y1+v1 >= y2 And y1+v1 <= y2+v2) Then
Provera_Dodira=True
Exit Function
End If
Provera_Dodira=False
End Function
Posle toga mozes na jednostavan nacin da proveravas da li postoji dodir izmedju bilo koja dva tela (slike) koja poseduju x,y koordinatu, sirinu i visinu.
If Postoji_Dodir (Image1.left, Image1.Top, Image1.Width, Image1.Height, Image2.left, Image2.Top, Image2.Width, Image2.Height)=True Then
"Uradi to i to"
End If
|