Autor Beitrag
Stinger47
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 102



BeitragVerfasst: Mi 22.02.06 16:10 
Hallo erstmal...
hab mal ne frage und zwar will ich ein Programm schreiben wo per TImage und nem Timer ein Mann von einer seite zur anderen schwimmt....
die Bewegung selber mach keine Probleme...
hab mit Const die Bilder zugewiesen und dann werden sie mit ganz vielen Timern immer wieder getauscht....
nur will ich jetzt nicht mehr so viele Timer haben und wollte es auf einen begrenzen...
dachte mir dann in etwa so etwas....
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Image1: TImage;
    Image2: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  bild: Integer;
  Pic: String;

const
  Bilder1= 'Bilder/bild1.bmp';
  Bilder2= 'Bilder/bild2.bmp';
  Bilder3= 'Bilder/bild3.bmp';
  Bilder4= 'Bilder/bild4.bmp';
  Bilder5= 'Bilder/bild5.bmp';
  Bilder6= 'Bilder/bild6.bmp';
  Bilder7= 'Bilder/bild7.bmp';
  Bilder8= 'Bilder/bild8.bmp';

implementation

{$R *.dfm}


procedure TForm1.Timer1Timer(Sender: TObject);
begin

  Inc(Bild);                                  //Soll Anzahl der Durchläufe zählen für das richtige Bild

  Pic:= 'Bilder'+IntToStr(Bild);              //Variable soll mit dem richtigen Bild belegt werden mit richtiger Nummer

  Image2.Picture.LoadFromFile(Pic);           //Bild soll eingefügt werden


end;

procedure TForm1.FormCreate(Sender: TObject);
begin

  doublebuffered:= True;
end;



procedure TForm1.Button1Click(Sender: TObject);
begin

  timer1.Enabled:= True;
end;

end.


allerdings hat das nicht so wirklich geklappt denke es liegt an Const und String...
wäre nett wenn ihr mir etwas helfen könntet..
danke schonmal!!


Moderiert von user profile iconraziel: Topic aus VCL (Visual Component Library) verschoben am Mi 22.02.2006 um 17:29
Moderiert von user profile iconraziel: Titel erweitert.
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Mi 22.02.06 16:14 
Du kannst ja einen "array of tbitmap" nutzen...
ist aber auch ne Variable...keine Konstante...

wenn das Programm erstellt wird lädst du die Bilder in den Array und nimmst dir die Bilder halt daraus...

_________________
GEIZ IST GEIL! - Ihr Sozialamt


Zuletzt bearbeitet von starsurfer am Mi 22.02.06 16:15, insgesamt 1-mal bearbeitet
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Mi 22.02.06 16:15 
und zwar ist der fehler in der zeile:
ausblenden Delphi-Quelltext
1:
Pic:= 'Bilder'+IntToStr(Bild);					

das geht so nicht, am besten wäre da ein array
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
Bilder: array[1..8] of String;
begin
Bilder[1]:= 'Bilder/bild1.bmp'; 
Bilder[2]:= 'Bilder/bild2.bmp'; 
...

Pic:= Bilder[(Bild)]; 
end;
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mi 22.02.06 16:16 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Timer1Timer(Sender: TObject);  
begin  

 
  Inc(Bild);                                  //Soll Anzahl der Durchläufe zählen für das richtige Bild  
 
  Pic:= 'Bilder\Bild'+IntToStr(Bild);              //Variable soll mit dem richtigen Bild belegt werden mit richtiger Nummer  
 
  Image2.Picture.LoadFromFile(Pic);           //Bild soll eingefügt werden  
 

 
end;


Probier mal so. Dann brauchste auch deine Konstanten nicht mehr. Wobei ichmir grad aber nicht sicher bin, ob loadfromfile nicht nen vollständigen Pfad braucht.

Beste Grüße
Tastaro
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mi 22.02.06 17:08 
Oder eventuell so.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
  Form1: TForm1;
  i:Integer;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  inc(i);
  if i = 9 then i:=1;
  Image1.Picture.LoadFromFile(ExtractFilePath(ParamStr(0))+'Bild'+InttoStr(i)+'.bmp');
end;
{Die Bilder müssen im selben Ordner wie die Exe liegen und den Namen Bild1 bis Bild8 haben}
Stinger47 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 102



BeitragVerfasst: Mi 22.02.06 17:19 
Danke habt mir sehr geholfen klappt jetzt auch alles....:)
also noch ma danke für eure hilfe!!