Autor Beitrag
Beliar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Fr 27.02.04 21:00 
Kaum ist das eine Problem bewältigt, taucht ein neues auf :?
Was ich versuche ist, ein image eines arrays zu bewegen. Klappt fast. Aber statt dem einen Image verschiebt sich ALLES mit - das image bleibt also im bezug zum Untergrund auf der Stelle, nur die Form bewegt sich.
Hier die Stellen, an denen es liegen könnte:
ausblenden Delphi-Quelltext
1:
Kugel:array[1..28] of TImage;					


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.FormCreate(Sender: TObject);
var i,j:integer;
begin
 for i:=1 to 28 do
 begin
  Kugel[i]:=timage.create(self);
  with Kugel[i] do
  begin
   parent:=form1;
   onmousemove:=kugelpfeile;
   name:='Kugel'+inttostr(i);
   autosize:=true;
   transparent:=true;
   Kugel[i].tag:=i;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.PfeilNWClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
 end;
 Kugel[Bildnummer].top:=Kugel[Bildnummer].top-44;
 Kugel[Bildnummer].left:=Kugel[Bildnummer].left-25;


Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Fr 27.02.04 21:27 
Abend!,

[quote="Beliar"]
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.PfeilNWClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
 Kugel[Bildnummer].top:=Kugel[Bildnummer].top-44;
 Kugel[Bildnummer].left:=Kugel[Bildnummer].left-25;
 end;
[/code]


also ich würde das so schreiben denn wenn sender z.B eine tfrom ist wird das trotzdem ausgeführt!

rokdd

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Sa 28.02.04 22:10 
Hmmm... netter einfall aber das Problem bleibt bestehen, schade :(
Ich hab nicht so viel Ahnung davon aber kann es vielleicht an dem parent des images liegen?
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Sa 28.02.04 22:18 
probieren geht über studieren. aslo probiere mal das prent wegzunehmen. glaube aber eher dass du das parent falsch setzt...


rokdd
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Sa 28.02.04 22:39 
Wenn ich "parent:=form1" wegnehme, sehe ich aber meine erstellten images nicht mehr. Irgentein parent müssen die images doch haben, oder?
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Sa 28.02.04 22:42 
weiß ich nciht:
setze bitte mal immer:show:=true;
probieren! ;-)

rokdd
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Sa 28.02.04 22:52 
Probieren... das sagt sich so leicht. Ich kann nicht großartig etwas probieren mit meinen kenntnissen in delphi. Bei "show:=true" meckert der compiler, dass "show" nichts zugewiesen werden kann. Im objektinspektor finde ich ausserdem beim image die eigenschaft "show" garnicht.
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Sa 28.02.04 22:57 
soory! habe einen fehler gemcht:

dort wo du parent setzt setzt du statt parent;
einfach nur show; wie beim anzeigen einer form! okay???

rokdd
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Sa 28.02.04 22:57 
Nagut es gibt "showhint" und "parentshowhint" - ich werd mal damit ein bisschen rumspielen...
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Sa 28.02.04 23:04 
nee das ist nicht richtig...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  with Kugel[i] do
  begin
   onmousemove:=kugelpfeile;
   name:='Kugel'+inttostr(i);
   autosize:=true;
   transparent:=true;
   Kugel[i].tag:=i;
   show;
  end;


rokdd
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Sa 28.02.04 23:17 
Mein post von 22:57 war keine antwort auf deinen von 22:57, sondern auf den davor...egal.
Das mit dem show compiliert er zwar, meine images sehe ich trotzdem nicht. So wie ich das verstanden habe, muss ich nem image irgenteine form als parent zuweisen, damit sie auf dieser form angezeigt werden...bringt mich aber trotzdem nicht weiter, da ich ja genau in dieser zuweisung den fehler vermute :?
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Sa 28.02.04 23:21 
ich vermute dort auch den fehler. nimm das parent mit rein... und setze vorsichtshalber(mach eigtnlich show) visible:=true

Du verstehst??

rokdd
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Sa 28.02.04 23:31 
Verstehe. Da die images aber mit form1 als parent sichtbar sind, denke ich nicht, dass es an dieser eigenschaft liegt (habs auch ausprobiert).
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: Sa 28.02.04 23:38 
  Kugel[i]:=timage.create(self); createt doch durch das self eine timage ohne parent oder? habe leider keine delphi hilfe zu hand....

rokdd
Ich Bins
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 197

Win XP Prof
D5 Prof
BeitragVerfasst: So 29.02.04 09:55 
probiers mal mit Parent:=Self;

_________________
Diese Nachricht wurde mit einer Taschenlampe in das offenliegende Ende eines Glasfaserkabels gemorst!
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: So 29.02.04 12:47 
Auch mit parent:=self bleibt das problem ich versteh das nicht.
Ich poste einfach mal die ganze unit vielleicht liegt der fehler ganz woanders:
ausblenden volle Höhe 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:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
unit Unit3;

interface

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

type
  TForm1 = class(TForm)
    Spielbrett: TImage;
    PfeilNO: TImage;
    PfeilNW: TImage;
    PFeilO: TImage;
    PfeilSO: TImage;
    PfeilSW: TImage;
    PfeilW: TImage;
    Knopf: TImage;
    procedure Kugelpfeile(Sender: TObject; Shift: TShiftState; X,Y: Integer);
    procedure PfeilNOClick(Sender: TObject);
    procedure PfeilNWClick(Sender: TObject);
    procedure PFeilOClick(Sender: TObject);
    procedure SpielbrettMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure PfeilSOClick(Sender: TObject);
    procedure PfeilSWClick(Sender: TObject);
    procedure PfeilWClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Kugel:array[1..28] of TImage;

implementation

{$R *.dfm}


procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
 for i:=1 to 28 do
 begin
  Kugel[i]:=timage.create(self);
  with Kugel[i] do
  begin
   parent:=self;
   onmousemove:=kugelpfeile;
   name:='Kugel'+inttostr(i);
   autosize:=true;
   transparent:=true;
   Kugel[i].tag:=i;
   if i<=14 then
   begin
    Kugel[i].Picture.LoadFromFile('.\WBall.bmp');
   end;
   if i>14 then
   begin
    Kugel[i].Picture.LoadFromFile('.\SBall.bmp');
   end;

   if i<=5 then
   begin
    left:=205+i*50;
    top:=148;
   end;
   if (i>5) and (i<=11) then
   begin
    left:=-70+i*50;
    top:=192;
   end;
   if (i>11) and (i<=14) then
   begin
    left:=-295+i*50;
    top:=236;
   end;

   if (i>14) and (i<=19) then
   begin
    left:=205+(i-14)*50;
    top:=495;
   end;
   if (i>19) and (i<=25) then
   begin
    left:=-70+(i-14)*50;
    top:=451;
   end;
   if i>=26 then
   begin
    left:=-295+(i-14)*50;
    top:=407;
   end;

  end;
 end;
end;

procedure TForm1.KugelPfeile(Sender: TObject; Shift: TShiftState; X,Y: Integer);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  PfeilNO.Top:=Kugel[bildnummer].Top-15;PfeilNO.Left:=Kugel[bildnummer].left+25;
  PfeilNW.Top:=Kugel[bildnummer].Top-14;PfeilNW.Left:=Kugel[bildnummer].left-2;
  PfeilO.Top:=Kugel[bildnummer].Top+12;PfeilO.Left:=Kugel[bildnummer].left+30;
  PfeilSO.Top:=Kugel[bildnummer].Top+26;PfeilSO.Left:=Kugel[bildnummer].left+26;
  PfeilSW.Top:=Kugel[bildnummer].Top+26;PfeilSW.Left:=Kugel[bildnummer].left+1;
  PfeilW.Top:=Kugel[bildnummer].Top+12;PfeilW.Left:=Kugel[bildnummer].left-18;
  Knopf.Top:=Kugel[bildnummer].Top+12;Knopf.Left:=Kugel[bildnummer].Left+14;
  PfeilNO.visible:=true;
  PfeilNW.Visible:=true;
  PfeilO.Visible:=true;
  PfeilSO.visible:=true;
  PfeilSW.Visible:=true;
  PfeilW.Visible:=true;
  Knopf.Visible:=true;
 end;
end;

procedure TForm1.SpielbrettMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
 PfeilNO.visible:=false;
 PfeilNW.Visible:=false;
 PfeilO.Visible:=false;
 PfeilSO.visible:=false;
 PfeilSW.Visible:=false;
 PfeilW.Visible:=false;
 Knopf.Visible:=false;
end;

procedure TForm1.PfeilNWClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  Kugel[Bildnummer].top:=Kugel[Bildnummer].top-44;
  Kugel[Bildnummer].left:=Kugel[Bildnummer].left-25;
  PfeilNO.visible:=false;
  PfeilNW.Visible:=false;
  PfeilO.Visible:=false;
  PfeilSO.visible:=false;
  PfeilSW.Visible:=false;
  PfeilW.Visible:=false;
  Knopf.Visible:=false;
 end;
end;

procedure TForm1.PfeilSOClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  Kugel[Bildnummer].top:=Kugel[Bildnummer].top+44;
  Kugel[Bildnummer].left:=Kugel[Bildnummer].left+25;
  PfeilNO.visible:=false;
  PfeilNW.Visible:=false;
  PfeilO.Visible:=false;
  PfeilSO.visible:=false;
  PfeilSW.Visible:=false;
  PfeilW.Visible:=false;
  Knopf.Visible:=false;
 end;
end;

procedure TForm1.PfeilSWClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  Kugel[Bildnummer].top:=Kugel[Bildnummer].top+44;
  Kugel[Bildnummer].left:=Kugel[Bildnummer].left-25;
  PfeilNO.visible:=false;
  PfeilNW.Visible:=false;
  PfeilO.Visible:=false;
  PfeilSO.visible:=false;
  PfeilSW.Visible:=false;
  PfeilW.Visible:=false;
  Knopf.Visible:=false;
 end;
end;

procedure TForm1.PfeilNOClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  Kugel[Bildnummer].top:=Kugel[Bildnummer].top-44;
  Kugel[Bildnummer].left:=Kugel[Bildnummer].left+25;
  PfeilNO.visible:=false;
  PfeilNW.Visible:=false;
  PfeilO.Visible:=false;
  PfeilSO.visible:=false;
  PfeilSW.Visible:=false;
  PfeilW.Visible:=false;
  Knopf.Visible:=false;
 end;
end;

procedure TForm1.PfeilWClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  Kugel[Bildnummer].left:=Kugel[Bildnummer].left-50;
  PfeilNO.visible:=false;
  PfeilNW.Visible:=false;
  PfeilO.Visible:=false;
  PfeilSO.visible:=false;
  PfeilSW.Visible:=false;
  PfeilW.Visible:=false;
  Knopf.Visible:=false;
 end;
end;

procedure TForm1.PFeilOClick(Sender: TObject);
var bildnummer:integer;
begin
 if sender is timage then
 begin
  bildnummer:=timage(sender).Tag;
  Kugel[Bildnummer].left:=Kugel[Bildnummer].left+50;
  PfeilNO.visible:=false;
  PfeilNW.Visible:=false;
  PfeilO.Visible:=false;
  PfeilSO.visible:=false;
  PfeilSW.Visible:=false;
  PfeilW.Visible:=false;
  Knopf.Visible:=false;
 end;
end;

end.
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: So 29.02.04 16:58 
hallo,
erstmal ein hiwneis für den code: diesen ganzen visible:=false;
anweisungen kannst du auch in eine procedure schreiben und dann aufrufen. ist damit weniger fehleranfällig und übersichtlicher! okay???

Schau mir den source gelich nochmal an...
rokdd
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: So 29.02.04 17:03 
Könntest du mir vielleicht per mail mal die projektdateien+bilder zuschicken? könnte dann mal besser schauen...

rokdd
Beliar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: So 29.02.04 17:21 
Deine idee mit der visible:=false prozedur klingt nicht schlecht, hab mir auch schon überlegt, ob ich das kürze.
Ich hab dir mein komplettes programm geschickt. Die pfadangaben für "SBall" und "WBall" sind natürlich sehr ungenau, vielleicht musst du die noch abändern.
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: So 29.02.04 17:23 
bei mir ist folgendes beim starten zu sehen:
Hintergrund
Kugeln
bei on ouseover: Die pfeile....

was ist da jetzt falsch??