a customized drag command

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

a customized drag command

Post by Samuele » Wed Mar 16, 2022 12:39 am

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!
Attachments
DragSpeed.zip
(2.98 KiB) Downloaded 80 times
Samuele.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: a customized drag command

Post by SparkOut » Wed Mar 16, 2022 3:25 pm

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.

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: a customized drag command

Post by Samuele » Tue Mar 29, 2022 10:11 pm

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...
Samuele.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » Wed Mar 30, 2022 8:00 am

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.
Last edited by richmond62 on Wed Mar 30, 2022 11:56 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » Wed Mar 30, 2022 8:20 am

SlowBALL.png
-
Baby Mathematics, AGAIN!
Attachments
Slow_Down_Gradually.livecode.zip
Stack.
(1.78 KiB) Downloaded 73 times

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: a customized drag command

Post by Samuele » Thu Mar 31, 2022 6:09 pm

thank you i will try it when livecode will decide to work :x !
Samuele.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » Thu Mar 31, 2022 8:16 pm

livecode will decide to work
LiveCode cannot decide anything, that is entirely up to the person who works with LiveCode.

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: a customized drag command

Post by Samuele » Sun Apr 03, 2022 10:00 pm

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!
Attachments
DragSpeed_wannabe_gradually.zip
(3.46 KiB) Downloaded 67 times
Samuele.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » 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, 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

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: a customized drag command

Post by Samuele » Mon Apr 04, 2022 10:36 am

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!
Samuele.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » Mon Apr 04, 2022 10:58 am

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.

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: a customized drag command

Post by Samuele » Mon Apr 04, 2022 11:55 am

how? the line could be / going up OR / going down OR \ going up OR \ going down.
So i can't just add value
Samuele.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » Mon Apr 04, 2022 12:48 pm

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 . . .

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: a customized drag command

Post by richmond62 » Mon Apr 04, 2022 1:29 pm

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)
Attachments
MAGIC STUFF.livecode.zip
Stack.
(64.58 KiB) Downloaded 74 times

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: a customized drag command

Post by Samuele » Mon Apr 04, 2022 4:08 pm

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 69 times
Thanks!
Samuele.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”