Autor Beitrag
-delphin-
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 200



BeitragVerfasst: Di 31.05.05 21:37 
Hallo, ich hab ein Würfelspiel gemacht und jetzt hat das Spiel 5 Würfel, die im Moment noch Labels sind, aber Images werden sollen. Die Images heißen wuerfel_1.bmp, wuerfel_2.bmp usw. und entsprechen dann der Eins, der Zwei etc.
Nun möchte ich Delphi sagen, dass Delphi das Bild entsprechend dem Ausfall meiner Variablen (Zahl1, Zahl2 etc.) von 1-6 ändern soll.
ausblenden Delphi-Quelltext
1:
2:
If Zahl1=1 then
   image2.Picture:=wuerfel_1.bmp;

Bloß gibt diese Zeile einen Fehler, wahrscheinlich, weil der Picture-Befehl nicht stimmt.
Kann mir da einer helfen??
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Di 31.05.05 21:55 
ausblenden Delphi-Quelltext
1:
If Zahl1=1 then image2.Picture.loadfromfile('wuerfel_1.bmp');					


so muss das aussehen
-delphin- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 200



BeitragVerfasst: Di 31.05.05 22:04 
Hm geht annähernd wunderbar, jetz brauch ich aber noch den Befehl, der mir das Ding wieder wegmacht, sobald Zahl1 ungleich 1 ist.
ausblenden Delphi-Quelltext
1:
If Zahl1<>1 then image2.Picture.LoadFromFile('None');					


None müsste irgendwie ersetzt werden oO
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Di 31.05.05 22:13 
ausblenden Delphi-Quelltext
1:
if ... then (load) else Zeig im Label an...					
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Di 31.05.05 22:14 
dh das das image leer wird?
entweder du lädst ein leeres bild darein, also mit der hintergrundfarbe deines programms
ausblenden Delphi-Quelltext
1:
image2.Picture.LoadFromFile('leer.bmp');					

oder du zeichnest mit canvas ein rechteck drüber
ausblenden Delphi-Quelltext
1:
image2.Picture.canvas.rectagle(-1,-1,image2.width+1,mage2.height+1;					
-delphin- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 200



BeitragVerfasst: Di 31.05.05 22:17 
Bei der nil-Möglichkeit kommt Inkomatible Typen String und Pointer. Das Prob ist halt, dass sich hinter dem Image ein Label befindet, daß die Zahl angibt. Somit kann ich kein leeres Bild drüber legen (;
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Di 31.05.05 22:18 
user profile icon[Delphi]N hat folgendes geschrieben:
Bei der nil-Möglichkeit kommt Inkomatible Typen String und Pointer. Das Prob ist halt, dass sich hinter dem Image ein Label befindet, daß die Zahl angibt. Somit kann ich kein leeres Bild drüber legen (;


das mit dem nil habe ich auch gerade festgestellt, hab es deswegen gelöscht
wie meinst du das mit dem label
poste am besten mal ein bild davon
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Di 31.05.05 22:20 
ausblenden Delphi-Quelltext
1:
if ... then Image1.Visible:=false;					
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Di 31.05.05 22:22 
user profile iconBlackheart hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
if ... then Image1.Visible:=false;					


so geht es natürlich auch, nur dann muss man es danach auch wieder sichtbar machen
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Di 31.05.05 22:31 
Wo liegt den nun das Problem ?
Beim Würfeln je nach Zahl soll das entsprechende Bild geladen
werden also...

ausblenden Delphi-Quelltext
1:
2:
if Zahl=1 then load Bild1...
if Zahl=2 then load Bild2...//Bild1 ist weg
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Di 31.05.05 22:44 
Oder Ich komm nicht mit....
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var
Wuerfel:Integer;
begin
  Randomize;
  Wuerfel:=Random(5)+1;
  If Wuerfel = 1 then  image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + 'Wuerfel1.bmp');
  If Wuerfel = 2 then  image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + 'Wuerfel2.bmp');
  If Wuerfel = 3 then  image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + 'Wuerfel3.bmp');
  If Wuerfel = 4 then  image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + 'Wuerfel4.bmp');
  If Wuerfel = 5 then  image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + 'Wuerfel5.bmp');
end;
-delphin- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 200



BeitragVerfasst: Mi 01.06.05 21:29 
so gehts natürlich, aber ich hab halt 5 Würfel und jedesmal 6 mögliche Ausfälle sind 30 Befehle.. Das ganze dann noch bei 3 Würfen, sind 90 Zeilen mehr Text oO -> gehts nicht kürzer?? Trotzdem danke ;)