Touch for moving an object
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Touch for moving an object
Hi all, I'm following this tutoria <...lessons/m/4069/l/11493-how-do-i-use-multi-touch-to-move-more-than-one-object> and all works well, the only problem I found is that when you touch the object, it moves under the finger instead of remaining in the initial position. I think I could solve by subtracting the distance between the touch and the center of the object from the position to assign. Unfortunately I can not find an elegant way to capture this data. Has anyone solved a similar problem?
Re: Touch for moving an object
Hi Mag,
You can use something like that:
Best regards
Jean-Marc
You can use something like that:
Code: Select all
local sCurObj,sX,sY,sWork
on mousedown
put the short name of the target into sCurObj
put (the mouseH - item 1 of the loc of btn sCurObj) into sX
put (the mouseV - item 2 of the loc of btn sCurObj) into sY
put true into sWork
end mousedown
on mousemove x,y
if sWork and sCurObj <> empty then
put x-sX into tNewH
put y-sY into tNewV
set the loc of btn sCurObj to tNewH,tNewV
end if
end mousemove
on mouseup
put false into sWork
end mouseup
Jean-Marc
https://alternatic.ch
Re: Touch for moving an object
Thank you so much Jean-Marc! Elegant and efficent code.
Re: Touch for moving an object
Hi Mag,
Welcome.I'm glad when i can help and pass what I received
We are more clever when we share knowledge
Best
Jean-Marc
Welcome.I'm glad when i can help and pass what I received
We are more clever when we share knowledge
Best
Jean-Marc
https://alternatic.ch