Autor Beitrag
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: Do 16.03.06 12:14 
Hi Community! Ich möchte mir eine Art Quiz programmieren. Nur mein Problem ich möchte dabei ganz gerne einen Timer haben der auf 30 steht und dann bei Start beginnt auf 0 runterzulaufen. Wie gehe ich am besten vor ? thx für die Hilfe =)
counterto
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 123

Win XP
Delphi 2005 Prof., Visual Basic 2005, PHP, My Sql, Visual Basic 6
BeitragVerfasst: Do 16.03.06 12:28 
also erst mal ein Label für die zahlen azuzeigen. dann ein Timmer der auf einen bestimmten Intervall festgelegt ist. (zB 1sec => intervall: 1000) Startbeschriftung des Labels : 30. Wen du zB von 5 auf 1 runterzählen willst dann mach das doch so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm.Timer1Timer(Sender: TObject);
begin
Label1.Caption:='5';
Timer1.Enabled:=False;Timer2.Enabled:=True;
end;
procedure TForm.Timer2Timer(Sender: TObject);
begin
Label1.Caption:='4';
Timer2.Enabled:=Flase;Timer3.Enabled:=True;
end;
procedure TForm.Timer3Timer(Sender: TObject);
begin
label1.Caption:='3';
Timer3.enabled:=Flase;Timer4.Enabled:=True;
end;


Kurz zum Prinzip dieses Codes:
Der Timer1 schreibt in das label '5' und schaltet sich dannach aus und den 2. Timer ein, der das Label mit der Beschriftung '4' füllt usw.
Ich hoffe ich konnte dir Helfen.

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: Do 16.03.06 12:40 
Besten dank;) bist halt schon nen Tag länger dabei(wenn du verstehst was ich meine ^^)
tobiaskr
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 16.03.06 13:04 
Find ich als Lösung nicht so besonders .... ;)
Nimm dir einen Timer, und stelle das Intervall auf 1000 (= 1 Sekunde) und erzeuge eine private Variable vom Typ Integer die du "AnzahlDurchlauf" nennst. Im FormCreate setzt du "AnzahlDurchlauf" auf "30". Schreib dann in das OnTimer - Event:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm.Timer1Timer(Sender: TObject);
begin
  Label1.Caption:= IntToStr(AnzahlDurchlauf);
  Dec(AnzahlDurchlauf);
  
  if AnzahlDurchlauf < 0 then
  begin
    Timer1.Enabled:= False;
    
    // Irgendwas das passieren soll, wenn bis 30 gezählt wurde
  end;
end;


Sollte funktionieren und braucht nur einen Timer. Leider habe ich momentan keinen Delphi-Compiler hier und konnte es nicht testen.

Gruß
Tobias
counterto
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 123

Win XP
Delphi 2005 Prof., Visual Basic 2005, PHP, My Sql, Visual Basic 6
BeitragVerfasst: Do 16.03.06 13:39 
ja die lösung ist eleganter ;) aber wenn jmd viel schreiben will is meine lösung besser ;) und von der kann ich dir auch sagen, dass sie funktioniert.
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: Do 16.03.06 15:05 
ihr beide habt mein Herz erobert, ;D
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 18.03.06 13:51 
user profile iconcounterto hat folgendes geschrieben:
ja die lösung ist eleganter ;) aber wenn jmd viel schreiben will is meine lösung besser ;) und von der kann ich dir auch sagen, dass sie funktioniert.

Viel Spaß, wenn der Timer von 1000 auf 0 zählen soll... :roll:

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: Sa 18.03.06 14:52 
wir reden vom intervall ;)
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: Sa 18.03.06 14:57 
user profile iconFlorian.K hat folgendes geschrieben:
Nimm dir einen Timer, und stelle das Intervall auf 1000 (= 1 Sekunde)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 18.03.06 15:11 
Und ich red über die Methode von counterto. Wenn du von 1000 auf 0 zählen willst, bräuchtest du bei seiner Methode 1000 Timer.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
counterto
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 123

Win XP
Delphi 2005 Prof., Visual Basic 2005, PHP, My Sql, Visual Basic 6
BeitragVerfasst: Sa 18.03.06 15:35 
user profile iconGTA-Place hat folgendes geschrieben:

Viel Spaß, wenn der Timer von 1000 auf 0 zählen soll... :roll:


Stell ich mir geil vor^^ ellenlanger code :D

_________________
Computer werden den Menschen immer ähnlicher - sie können bald alles, außer denken.