• Viernes 29 de Marzo de 2024, 08:44

Autor Tema:  Como mover una imagen en tiempo de ejecucion en c++  (Leído 3160 veces)

pochi

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Como mover una imagen en tiempo de ejecucion en c++
« en: Martes 12 de Febrero de 2013, 21:30 »
0
Hola!!! de nuevo estoy buscando para mi juego de cartas en builder c++ el codigo para mover la carta en el turno del jugador he probado varias cosas y no me anda este es mi codigo:
Código: C++
  1. bool gbMover = false;
  2. ...
  3. void __fastcall TForm1::Image2MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
  4.                   int X, int Y)
  5. {
  6.    gbMover= true;
  7. }
  8. //---------------------------------------------------------------------------
  9.  
  10. void __fastcall TForm1::Image2MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift,
  11.           int X, int Y)
  12. {
  13.    gbMover= false;
  14. }
  15. //---------------------------------------------------------------------------
  16.  
  17. void __fastcall TForm1::Image2MouseMove(TObject *Sender, TShiftState Shift, int X,
  18.           int Y)
  19. {
  20.    if(gbMover == true){
  21.    TPoint *MyPoint;
  22.    GetCursorPos(MyPoint);
  23.    Image2-> Left = (MyPoint->x-Form1->Left)- Image2->Width/2;
  24.    Image2->Top = (MyPoint->y-Form1->Top)- Image2->Width/2;
  25.    }
  26. }
No manda error pero no mueve la imagen.
Desde ya muchas gracias  :ayuda: :gracias:

juanC2

  • Nuevo Miembro
  • *
  • Mensajes: 8
    • Ver Perfil
Re:Como mover una imagen en tiempo de ejecucion en c++
« Respuesta #1 en: Miércoles 8 de Enero de 2014, 13:10 »
0
Código: C++
  1. bool gbMover;
  2. int xini, yini;
  3.  
  4. void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button,
  5.       TShiftState Shift, int X, int Y)
  6. {
  7.    gbMover = false;
  8. }
  9. //---------------------------------------------------------------------------
  10.  
  11. void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
  12.       int X, int Y)
  13. {
  14.  if(gbMover == true){
  15.    Image1->Left += (X-xini);
  16.    Image1->Top += (Y-yini);
  17.    }
  18. }
  19. //---------------------------------------------------------------------------
  20.  
  21. void __fastcall TForm1::Image1MouseDown(TObject *Sender,
  22.       TMouseButton Button, TShiftState Shift, int X, int Y)
  23. {
  24.   if(Button == mbLeft){
  25.      xini = X;
  26.      yini = Y;
  27.      gbMover = true;
  28.     }
  29. }
  30.