Autor Beitrag
Daniel_100
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 03.08.03 19:48 
Hallo!

Mein Programm soll eine Meldung ausspuken, wenn sich zwei Images an irgendeiner Stelle überschneiden. Geht das?

Danke

Daniel
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 03.08.03 19:54 
Hi,

klar... einfach überprüfen ob:

ausblenden Delphi-Quelltext
1:
((Image1.Left + Image1.Width > Image2.Left) and (Image1.Left < Image2.Left + Image2.Width)) or ((Image1.Top + Image1.Height > Image2.Top) and (Image1.Top < Image2.Top + Image2.Height))					


Ist jetzt einfach so aus dem kopf geschrieben, kann sein das tippfehler oder so drin sind ;)

Ist allerdings nur die überprüfung für die obere + linke kante.. die anderen beiden kannste aber leicht selber dazubasteln ;)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 03.08.03 20:12 
Sorry, aber irgendwie funktioniert das nicht (mit if-then). Ich hab jetzt versucht, den Rest hinzuzufügen: nix. Vielleicht bin ich einfach nur zu blöd :oops: . Könntest du (oder jemand anders) dann den gesamten Code aufschreiben...

Danke
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 03.08.03 20:43 
Hi,

na gut... hier mal nen ganzer Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function TForm1.CollisionTest: Boolean;
begin
  Result:=
    (((Image1.Left > Image2.Left) and (Image1.Left < Image2.Left + Image2.Width)) or
    ((Image1.Left + Image1.Width > Image2.Left) and (Image1.Left + Image1.Width < Image2.Left + Image2.Width))) and
    (((Image1.Top > Image2.Top) and (Image1.Top < Image2.Top + Image2.Height)) or
    ((Image1.Top + Image1.Height > Image2.Top) and (Image1.Top + Image1.Height < Image2.Top + Image2.Height)));
end;


Au'revoir,
Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: So 03.08.03 23:39 
wahlweise könnte die funktion...

ausblenden Delphi-Quelltext
1:
function IntersectRect(out Rect: TRect; const R1, R2: TRect): Boolean;					


... auch weiterhelfen! Ist aber im prinzip das selbe :wink:

_________________
mfg.
mâximôv