Autor Beitrag
Jelox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Fr 04.03.05 18:57 
hi.
ich stell mal wieder so ne noob frage.
also wir programmieren uns gerade in der schule so n fangspiel.
das soll eigentlich ganz simpel laufen.
also es soll ein panel auf einem panel in einem bestimmten raum bewegt werden.
und wenn man auf das eine panel draufklickt, dann gibt es nen punkt.
nun find ich den befehl aber nicht raus, mit dem ich das panel in dem bestimmten raum bewegen kann.
wäre wirklich nett, wenn mir einer helfen würd :)


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Mo 07.03.2005 um 01:08
Moderiert von user profile iconTino: Titel geändert.
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: Fr 04.03.05 19:01 
Timer nehmen, z.B. Interval = 500:

ausblenden Delphi-Quelltext
1:
Panel2.Left := Panel2.Left-1;					


Würde das Panel, alle 500 Milisekunden um einen Pixel nach links bewegen.

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



BeitragVerfasst: Fr 04.03.05 19:41 
ja bloß, dann bewegt sich das ja auch aus dem panel raus :(
ich wollt das eigentlich gerne haben, dass sich das in einem bestimmten raum von selbst bewegt ;)
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 04.03.05 19:53 
2 globale Variablen (oder private in TForm1):
ausblenden Delphi-Quelltext
1:
2:
3:
var
 dx : Integer = 1;
 dy : Integer = 1;


Im Timer dann:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Panel2.Left := Panel2.Left + dx;
Panel2.Top := Panel2.Top + dy;
if (Panel2.Left <= 0) or (Panel2.Left + Panel2.Width >= Panel1.Width) then
 dx := -dx;
if (Panel2.Top <= 0) or (Panel2.Top  + Panel2.Height >= Panel1.Height) then
 dy := -dy;


Dabei ist Panel1 der Parent von Panel2.