How do I create a grid like the one in edit mode, then be able to drag images that snap. What im trying to create i somewhat like the diablo inventory.
Anyone??
Printable View
How do I create a grid like the one in edit mode, then be able to drag images that snap. What im trying to create i somewhat like the diablo inventory.
Anyone??
Here's some code that does it (image named Image1). When you release the mouse button the image snaps into place. You can change the grid size by altering the value of the constant.
VB Code:
Private Const GridSize As Single = 1200 Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Static mouseposx As Single, mouseposy As Single If Button = 1 Then Image1.Left = Image1.Left + X - mouseposx Image1.Top = Image1.Top + Y - mouseposy Else mouseposx = X mouseposy = Y End If End Sub Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Image1.Left = Round(Image1.Left / GridSize, 0) * GridSize Image1.Top = Round(Image1.Top / GridSize, 0) * GridSize End If End Sub