the grabbing (pick up an item and move it to a different slot) part of my inventory system is as follows:
the problem is that when i run this, and try to grab an item using the left click and hold, most of the times it will not grab. On rare occasions it will grab the item, and everything will work, but most of the times this does not happen. ideas?
any help = thank you
For item.genericitem = Each genericitem Select item\slot Case 1 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)-159, (displayheight/2)-233, 160, 160) And MouseHit(1) Then hold = True Case 2 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)+1, (displayheight/2)-233, 160, 160) And MouseHit(1) Then hold = True Case 3 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)-159, (displayheight/2)-73, 160, 160) And MouseHit(1) Then hold = True Case 4 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)+1, (displayheight/2)-73, 160, 160) And MouseHit(1) Then hold = True Case 5 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)-159, (displayheight/2)+87, 160, 160) And MouseHit(1) Then hold = True Case 6 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)+1, (displayheight/2)+87, 160, 160) And MouseHit(1) Then hold = True End Select If hold = True Then item\held = True hold = False EndIf If item\held = True Then DrawImage item\image, MouseX(), MouseY() If Not MouseDown(1) Then item\held = False If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)-159, (displayheight/2)-233, 160, 160) Then item\slot = 1 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)+1, (displayheight/2)-233, 160, 160) Then item\slot = 2 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)-159, (displayheight/2)-73, 160, 160) Then item\slot = 3 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)+1, (displayheight/2)-73, 160, 160) Then item\slot = 4 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)-159, (displayheight/2)+87, 160, 160) Then item\slot = 5 If RectsOverlap (MouseX(), MouseY(), 1, 1, (displaywidth/2)+1, (displayheight/2)+87, 160, 160) Then item\slot = 6 EndIf EndIf Next
the problem is that when i run this, and try to grab an item using the left click and hold, most of the times it will not grab. On rare occasions it will grab the item, and everything will work, but most of the times this does not happen. ideas?
any help = thank you