hello all im creating a game where user can drag and drop pictureboxes.I managed to do it but i dont like how it behaves when you drag n drop a picturebox. With this code
private void myPictureBox_MouseDown(object sender, MouseEventArgs e)
{
isDragging = true;
currentX = e.X;
currentY = e.Y;
}
private void myPictureBox_MouseMove(object sender, MouseEventArgs e)
{
Control control = (Control)sender;
if (isDragging)
{
control.Top = control.Top + (e.Y - currentY);
control.Left = control.Left +(e.X - currentX);
}
}
private void myPictureBox_MouseUp(object sender, MouseEventArgs e)
{
isDragging = false;
}
it behaves like this (video 1) So i put a .update() to it
private void myPictureBox_MouseDown(object sender, MouseEventArgs e)
{
isDragging = true;
currentX = e.X;
currentY = e.Y;
}
private void myPictureBox_MouseMove(object sender, MouseEventArgs e)
{
Control control = (Control)sender;
if (isDragging)
{
control.Top = control.Top + (e.Y - currentY);
control.Left = control.Left +(e.X - currentX);
control.update();
}
}
private void myPictureBox_MouseUp(object sender, MouseEventArgs e)
{
isDragging = false;
}
But because its in the if loop its behave like this (video 2) .Do you have any suggestion? thanks in advance.