Autor Beitrag
somebody
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Do 31.05.07 15:50 
Hi, Leutz!!!

Ich wollte mal son kleines Spiel machen, wo sich son Heini bewegt und wenn ich enter drücke, das der dann springt. Soweit eigentlich kein problem, aber wie macht man dass, das etwas passirt wenn ich enter drücke. Wie der springt, das kann ich. Ich habe nur das problem dass ich nicht weiß wie man macht, dass etwas passiert, wenn man enter drückt.

danke jetzt schon mal für Antworten.

mfg:Somebody
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Do 31.05.07 16:39 
Hallo.

Am besten so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if GetAsyncKeystate(VK_RETURN) < 0 then
begin
  //Dein Code zum Springen hier einfügen =)
end;


Am besten du kontrollierst das mit nem Timer in 100er Abständen oder so.
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Do 31.05.07 16:53 
user profile iconJakob_Ullmann hat folgendes geschrieben:
Hallo.

Am besten so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if GetAsyncKeystate(VK_RETURN) < 0 then
begin
  //Dein Code zum Springen hier einfügen =)
end;


Am besten du kontrollierst das mit nem Timer in 100er Abständen oder so.

Also das würd ich so nicht machen, wozu gibts denn das OnKeyDown- bzw. OnKeyPress-Ereignis des Formulars? Wechsel im Objektinspektor auf den Reiter "Ereignisse", und klick doppelt auf das Feld neben OnKeyDown.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Form1KeyDown(Sender: TObject; Key: Word);
begin
  if Key = VK_RETURN then
  begin  
    //Dein Code zum Springen hier einfügen
  end; 
end;
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Fr 01.06.07 14:45 
Ah, thx!

mfg:somebody
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Fr 01.06.07 18:53 
Gut, nur wenn ich das bei OnKeyPress mache, dann steht da Inkompatible Typen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if Key = VK_RETURN then //hier sagt der das
           begin
                shape1.Brush.color := clred;
           end;


Was muss ich denn da schreiben, weil so scheint es ja falsch zu sein.
FSS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 83

Win 7 Professional 64Bit
Delphi 7 PE, Delphi 2005 PE, Turbo Delphi Explorer 2006
BeitragVerfasst: Fr 01.06.07 19:11 
Entweder du schreibst es in OnKeyDown oder du änderst VK_Return in #13 um:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  if Key = #13 then //hier sagt der das
           begin
                shape1.Brush.color := clred;
           end;
end;


Delphi erwartet in OnKeyPress einen Char:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

end;

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin

end;
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Fr 01.06.07 19:17 
Aso, thx.
1aa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47
Erhaltene Danke: 1

Win Vista, Win8
Delphi 2007
BeitragVerfasst: Fr 01.06.07 22:16 
andere möglichkeit währe die Procedure "onEnter"
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 01.06.07 22:40 
OnEnter hat nichts mit der Enter-taste zu tun!
aus der Delphi-Hilfe:
Das Ereignis OnEnter tritt auf, wenn ein Steuerelement den Eingabefokus erhält.

_________________
We are, we were and will not be.