Einzelnen Beitrag anzeigen

Maurooon

Registriert seit: 7. Dez 2016
70 Beiträge
 
#6

AW: Procedure bei Mausklick ausführen

  Alt 1. Apr 2017, 12:27
mhmmmm... habe es so umgebaut wie Sie es vorgeschlagen haben. Das hier ist der Code:

Code:
function schussbahnberechnen(sx, sy, mx, my: Real):Integer;
begin
  result := round((my-sy) / (mx-sx));
end;

procedure TForm2.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = mbLeft then Form2.Timer1.Enabled := true;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
var
  sx, sy, mx, my: Real;
begin
  if (Form2.Image2.Visible = true) or (Form2.Image4.Visible = true) then begin//die anderen Fälle füge ich noch ein
   Form2.Shape1.Left := Form2.Image2.Left + 40;
   Form2.Shape1.Top := Form2.Image2.Top + 21;
   mx := Mouse.CursorPos.X;
   my := Mouse.CursorPos.Y;
   sx := Form2.Shape1.Left + 3;
   sy := Form2.Shape1.Top + 3;
  end;
  Form2.Shape1.Visible := true;
  if (mx > (Form2.Shape1.Left + 3)) then begin//die anderen Fälle füge ich noch ein
   Form2.Shape1.Left := Form2.Shape1.Left + 1;
   Form2.Shape1.Top := Form2.Shape1.Top + schussbahnberechnen(sx, sy, mx, my);
  end;
  Form2.Label1.caption := IntToStr(Form2.Shape1.Left);//zur Kontrolle-->ändert sich nicht
end;

Finden Sie einen Fehler? Der Timer scheint nicht enabled zu werden(enabled initial ist auf false).

LG
"One of the basic rules of the universe is that nothing is perfect. Perfection simply doesn't exist... Without imperfection, neither you nor I would exist." - Stephen Hawking
  Mit Zitat antworten Zitat