(2D) Selecting and dragging an object with mouse

Blitz3D Forums/Blitz3D Beginners Area/(2D) Selecting and dragging an object with mouse

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

hey all

I have created a few boxes on screen via a Type and I want to be able to select them with my mouse cursor and while my left mouse button is held down, be able to drag them to another location.

I have got this working to some extent by testing for a collision with my cursor image and my box image, and if True then setting the box X,Y to equal the cursor image X,Y until I release the mouse button. However if I move the mouse around at a reasonably quick pace, the mouse cursor breaks free from the box image and so the collision test fails.

After spending quite some time on this (real newbie here :op ) I have decided to ask for some help...Maybe there is a more elegant solution instead of using the image collision function?

I have tried avoiding the collision function call and just testing to see if...

mouseX() > imgBoX and (mouseX() < (imgBoX+imgSize)
mouseY() > imgBoY and (mouseY() < (imgBoY+imgSize)

but the result is much the same

then I tried to make sure the mouseX() and mouseY() never stray too far from the Box image centre by bringing them back a few pixels if the cursor image moves too far from the Box images centre.

I hope I am being clear.

Anyway, any help with this would be appreciated..cheers guys.