Page 1 of 3

a customized drag command

Posted: Wed Mar 16, 2022 12:39 am
by Samuele
Hi, I'm trying to write a script that:
1) determines the speed of a drag movement (already did, I think :) )
2) determines for how much time and space after the drag movement the computer/phone should keep moving the dragged object.
3) the speed of the Computer "after movement" will slow down gradually
this is in general, in the stack attached you can see and understand better.
Thanks!

Re: a customized drag command

Posted: Wed Mar 16, 2022 3:25 pm
by SparkOut
I'm not sure what you've achieved (using phone so not downloaded your stack) but if you open the "bouncy" stack sample from the "Resources" menu, at the bottom of the list in "Sample Projects", then you can pick this apart. It bounces around according to the initial speed of mouse drag, and slows down gradually.

Re: a customized drag command

Posted: Tue Mar 29, 2022 10:11 pm
by Samuele
Hi, I took a look at it, and the stack doesn't quite go in the direction I intended... or maybe it is but in a complicated way that it seems useless for only the thing I'm trying to achieve...

Re: a customized drag command

Posted: Wed Mar 30, 2022 8:00 am
by richmond62
I think it would be a good idea if one of the list administrators
merged this posting with the previous one on the same topic by
the same OP.

Re: a customized drag command

Posted: Wed Mar 30, 2022 8:20 am
by richmond62
SlowBALL.png
-
Baby Mathematics, AGAIN!

Re: a customized drag command

Posted: Thu Mar 31, 2022 6:09 pm
by Samuele
thank you i will try it when livecode will decide to work :x !

Re: a customized drag command

Posted: Thu Mar 31, 2022 8:16 pm
by richmond62
livecode will decide to work
LiveCode cannot decide anything, that is entirely up to the person who works with LiveCode.

Re: a customized drag command

Posted: Sun Apr 03, 2022 10:00 pm
by Samuele
Thank you for the stack, but when i put that code on my original stack it doesn't work because the line created has only 2 points
Thanks!

Re: a customized drag command

Posted: Mon Apr 04, 2022 10:03 am
by richmond62
the line created has only 2 points
Very, very funny indeed.

The line in my stack has 50 points.

Make an effort to understand the code inside the GENERATE DOTTY LINE button, find where the field "POINTZ" is,
and then do some work instead of expecting to have everything delivered to you on a plate.

Code: Select all

on mouseUp
   put empty into fld "POINTZ"
   put 20 into LR
   put 100 into UD
   repeat until LR > 1000
      put (LR & "," & UD & cr) after fld "POINTZ"
      add 20 to LR
      add 10 to UD
   end repeat
   set the points of grc "pp" to fld "POINTZ"
end mouseUp
If you look at the code in button "MOVE IT BABY!" you will see the line is completely irrelevant
(and it is just 'there' to look pretty):

Code: Select all

on mouseUp
   set the moveSpeed to 2000
   put 2000 into fastBALL
   put 1 into POYNT
   put line POYNT of fld "POINTZ" into LOKK
   set the loc of grc "TOPKA" to LOKK
   repeat until line POYNT of fld "POINTZ" is empty
      add 1 to POYNT
      put line POYNT of fld "POINTZ" into LOKK
      move grc "TOPKA" to LOKK
      subtract 40 from fastBALL
      set the moveSpeed to fastBALL
   end repeat
end mouseUp

Re: a customized drag command

Posted: Mon Apr 04, 2022 10:36 am
by Samuele
richmond62 wrote:
Mon Apr 04, 2022 10:03 am
the line created has only 2 points
Very, very funny indeed.

The line in my stack has 50 points.

Make an effort to understand the code inside the GENERATE DOTTY LINE button
hi, I understand the code of your stack, but the problem is that you create a line that goes in a random direction and therefore you can afford to create it with many points, but I in my stack am not trying to move the ball in a random direction but in the direction that the user dragged the ball and what I cannot understand is why the line created in my stack has only 2 points and therefore the trick you use in your stack to decrease the speed in every point of the line is not possible to do it in my ... :roll:
Thanks for the patience!

Re: a customized drag command

Posted: Mon Apr 04, 2022 10:58 am
by richmond62
If you know your start point and your end point it is relatively easy to generate a multi-point line (or list of intermediate points)
between them.

Re: a customized drag command

Posted: Mon Apr 04, 2022 11:55 am
by Samuele
how? the line could be / going up OR / going down OR \ going up OR \ going down.
So i can't just add value

Re: a customized drag command

Posted: Mon Apr 04, 2022 12:48 pm
by richmond62
It's a lovely Spring day here, so just got back from 90 minutes walk & a think as have to sort out 10 Ukrainian children tomorrow (i.e. integrate them into existing EFL classes), and am slightly nervous.

Going upstairs to mess around with LiveCode in about 45 minutes . . .

Re: a customized drag command

Posted: Mon Apr 04, 2022 1:29 pm
by richmond62
SShot 2022-04-04 at 15.27.28.png
-
There's a lot to be said for a walk . . .

ALL the code that matters is in the MAGIC button. 8)

Re: a customized drag command

Posted: Mon Apr 04, 2022 4:08 pm
by Samuele
Hi , thanks, there is only a little thing, i don't understand why in my stack the Button i want to move goes from moving slowly to fast instead of the reverse as in your stack.
DragSpeed_Almost_Gradually.zip
(4.27 KiB) Downloaded 139 times
Thanks!