Click'n'Drag

BlitzMax Forums/BlitzMax Beginners Area/Click'n'Drag

KnupK(Posted 2007) [#1]
Help!

------------------------------------------
If ImagesCollide(sol.image,sol.x#,sol.y#,0,gfx_mouse,MouseX(),MouseY(),0) And MouseDown(1)
sol.x# = sol.x# + MouseXSpeed#
End If
------------------------------------------
MouseXSpeed dont works at BMX ='(
How to do Click'n'Drag without MouseXSpeed?


Derron(Posted 2007) [#2]
You don't need MouseXSpeed... just save the difference from sol.x to mouseX() and from sol.y to MouseY() to temporary values (so the click-point is saved) and draw the image at the Position MouseX()-SavedX, MouseY()-SavedY.


bye
MB


GfK(Posted 2007) [#3]
Just knocked this up. Seems to work.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1933


KnupK(Posted 2007) [#4]
Thanks MB and Gfk

Now i have MouseXSpeed,but my code is dont working ='(
Maybe you know some alternative ways?


tonyg(Posted 2007) [#5]
Post some runnable code which shows the problem.


KnupK(Posted 2007) [#6]
http://c0mrad.pochta.ru/Clikcdrag.rar


tonyg(Posted 2007) [#7]
I *think* the problem is...
If ImagesCollide(sol.image,sol.x#,sol.y#,0,gfx_mouse,MouseX(),MouseY(),0)
	If md			
		sol.x# = MouseX()
    EndIf 	
	End If

I'll try and write some code later but shouldn't you set a 'ispicked' flag when the imagescollide and the mouse is down and then check that flag to position sol.x. When the mouse is no longer held down the flag is reset.
This would probably need mousestatus to be held in the TMouse class and checked whether up or down each loop.
Hope that makes sense.
P.S. you should never check against mousedown/mousehit() etc. Instead assign them to a variable. Checking them directly resets the mouse/key hit.

<edit> Here is some .bb code but it shows a good method to hold mouse information.