Einzelnen Beitrag anzeigen

dominikkv

Registriert seit: 30. Sep 2006
Ort: Gundelfingen
1.109 Beiträge
 
Delphi 2007 Professional
 
#7

Re: Image darf nicht durch Image bewegt werden!

  Alt 2. Mär 2008, 17:55
Warum so umständlich über eine Klasse?
Delphi-Quellcode:
function IsCollision(obj1, obj2: TControl): Boolean;
begin
  if Assigned(obj1) and Assigned(obj2) then
    Result := (obj1.Left <= obj2.Left + obj2.Width) and (obj1.Left + obj1.Width >= obj2.Left)
          and (obj1.Top <= obj2.Top + obj2.Height) and (obj1.Top + obj2.Height >= obj2.Top);
end;
aufrufen einfach so:
Delphi-Quellcode:
if IsCollision(Image1, Shape2) then
  bla;
Dominik
Wer anderen eine Grube gräbt, hat ein Gruben-Grab-Gerät!
  Mit Zitat antworten Zitat