Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Gráficos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 23-02-2005
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is online now
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.437
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por estebanx
...pero solo logro que dicha imagen se mueva de izquierda a derecha con un procedimiento.
Bueno es llógico que sólo se mueva con la X, porque no modificas para nada la Y. Otra cosa, es mejor que en lugar de utilizar Sleep, utilices un Timer.
Prueba con lo siguiente; coloca un Timer en el form y utiliza lo siguiente:

Código Delphi [-]
 
 ... en la parte privada
   private
 
     _PosXInicial, _PosYInicial, _PosXFinal, _PosYFinal:Integer;
     _DeltaX, _DeltaY:Integer;
 
     { Private declarations }
     procedure caminar2(x, y:integer);
 
 ... antes de la implementación
 const
   NUM_MOV = 20;
 
 ... en la implementacion
 
 procedure TForm1.caminar2(x, y: integer);
 begin
 
   // Deinimos posiciones
   _PosXInicial := img.Left;
   _PosYInicial := img.Top;
   _PosXFinal := X;
   _PosYFinal := y;
   // debfinimos Deltas de "avance"
   _DeltaX := (_PosXFinal - _PosXInicial) div NUM_MOV;
   _DeltaY := (_PosYFinal - _PosYInicial) div NUM_MOV;
   // Actibvamos el movimiento
   Timer1.Enabled := True;
 
 end;
 
 
 procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
   Shift: TShiftState; X, Y: Integer);
 begin
   Caminar2(x,y);
 end;
 
 
 procedure TForm1.Timer1Timer(Sender: TObject);
 var
   XFin, YFin:Boolean;
 begin
 
   // X positiva
   if (_DeltaX > 0) then begin
     if ((img.Left + _DeltaX) >= _PosXFinal) then begin
       XFin := True;
     end
     else begin
       img.Left := img.Left + _DeltaX;
     end;
   end
   else begin  // X negaiva
     if ((img.Left + _DeltaX) <= _PosXFinal) then begin
       XFin := True;
     end
     else begin
       img.Left := img.Left + _DeltaX;
     end;
   end;
 
   // Y positiva
   if (_DeltaY > 0) then begin
     if ((img.Top + _Deltay) >= _PosYFinal) then begin
       YFin := True;
     end
     else begin
       img.tOP := img.Top + _DeltaY;
     end;
   end
   else begin  // Y negaiva
     if ((img.Top + _DeltaY) <= _PosYFinal) then begin
       YFin := True;
     end
     else begin
       img.Top := img.Top + _DeltaY;
     end;
   end;
 
   if (XFin and YFin) then begin
     Timer1.Enabled := False;
   end;
 end;
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 08:38:31.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi