Autor Beitrag
Toxic
Hält's aus hier
Beiträge: 7

WIN98SE
D6 Pers
BeitragVerfasst: Mi 10.03.04 23:31 
Hi! Ich bin ziemlich neu hier und hab mich auch erst zwei Monate in Delphi eingearbeitet.
Kann mir jemand sagen, wie ich ein image per Tastatursteuerung bewegen kann.
z.B. mit image.Top und image.Left, aber ich nehm gern auch andere Lösungsvorschläge an.
Mit Buttons klappts schonmal, aber halt auch nur Stück für Stück. D.h. es wäre nicht schlecht, wenn ich ein image z.B. wie im Handy-Klassiker "Snake" in eine Richtung laufen lassen könnte, bis dann mit einer anderen Pfeiltaste eine andere Richtung vorgegeben wird. :?: :!:

_________________
Ich stehe Statistiken etwas skeptisch gegenüber. Denn laut Statistik haben ein Millionär und ein armer Kerl jeder eine halbe Million. (Franklin Delano Roosevelt)
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 10.03.04 23:38 
Schau dir mal in der OnlineHilfe das Ereignis OnKeyDown an.. das sollte dir weiterhelfen... (vielleicht auch noch die virtuellen Tastencodes, damit du die Cursor-Tasten auswerten kannst...)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Toxic Threadstarter
Hält's aus hier
Beiträge: 7

WIN98SE
D6 Pers
BeitragVerfasst: Do 11.03.04 14:00 
Ich blick des doch net so... Wo find ich die Onlinehilfe?
Gruß, ToXXic

_________________
Ich stehe Statistiken etwas skeptisch gegenüber. Denn laut Statistik haben ein Millionär und ein armer Kerl jeder eine halbe Million. (Franklin Delano Roosevelt)
Anfänger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP
D3 Prof
BeitragVerfasst: Do 11.03.04 14:59 
Guck doch einfach in der Delphi-Hilfe.
Dort findest du die Erklärung für die Prozedur.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 11.03.04 16:07 
Toxic hat folgendes geschrieben:
Wo find ich die Onlinehilfe?

F1 ;)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
iGoA
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 103

Alle Win´s
D5 Prof
BeitragVerfasst: Fr 12.03.04 11:53 
Muss im Prinzip so gehen:

Du baust einen Timer mit aufs Form. Intervall je nach Geschmack (und "Schwierigkeitsgrad", hehe)

Beim Ereignis OnTimer tust Du folgendes:

ausblenden Quelltext
1:
2:
image.left := image.left + xbewegung;
image.top := image.top + ybewegung;


xbewegung und ybewegung müssen globale integer-variablen sein.

Beim OnKeyDown-Ereignis des Forms machst Du sooo:

ausblenden Quelltext
1:
2:
3:
4:
if key = VK_RIGHT then xbewegung := 1;
if key = VK_LEFT then xbewegung := -1;
if key = VK_UP then ybewegung := -1;
if key = VK_DOWN then ybewegung := 1;