ďťż

Ładny brzuch

Jak w Delphi zrobić ruch po skosie np.(shape)??



Zwiekszaj parametry Left i Top. Dla przykładu, w zdarezniu OnTimer komponentu Timer z Intervałem na 100:

Shape1.SetBounds(Shape1.Left + 10, Shape1.Top + 10, Shape1.Width, Shape1.Height);

Oczywiście dobierz sobie dowolne wartości zamiast tych 10 i interwał też wybierz właćciwości dla siebie. Aby uniknąć migania komponentu w zdarzeniu OnCreate Form1 daj:

Form1.DoubleBuffered := True;

... to tylko jedna z metod.
Użytkownik programista1101 edytował ten post 21 maj 2005, 14:00
Dajesz Timera, Shape.
Między uses a type dajesz:
type zbior=(m_left,m_right,m_up,m_down);

Dalej deklarujesz:
var move:set of zbior;

W onkeydown Formy:
case key of 37:include(move, m_left); 38:include(move, m_up); 39:include(move,m_right); 40:include(move, m_down) end;

W onkeyup Formy:
case key of 37:exclude(move, m_left); 38:exclude(move, m_up); 39:exclude(move,m_right); 40:exclude(move, m_down); end;

W OnTimer Timera:
if m_up in move then shape1.top:=shape1.top-1; if m_down in move then shape1.top:=shape1.top+1; if m_left in move then shape1.left:=shape1.left-1; if m_right in move then shape1.left:=shape1.left+1;

P.S Interval Timera lepiej ustawić na 1.

Ups, sory. Zapomniałem dopisać, że za pomocą strzałek :mellow: ;) :(




Ups, sory. Zapomniałem dopisać, że za pomocą strzałek :mellow:  ;)  :(

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • zsf.htw.pl
  •