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

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

Re: a customized drag command

Post by richmond62 » Mon Apr 04, 2022 5:57 pm

You are probably counting UPWARDS so your moveSpeed is increasing while you
should be counting DOWNWARDS.

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:05 pm

I'm not using the moveSpeed because it created some problems so I'm using "

Code: Select all

move me to LOKK in fastBALL ticks
"
Samuele.

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

Re: a customized drag command

Post by richmond62 » Tue Apr 05, 2022 6:21 am

Well the number of ticks between each location
on a trajectory needs to incrementally DECREASE.

This is very easy indeed.

Although, personally, I would use milliseconds instead of ticks.

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

Re: a customized drag command

Post by Samuele » Tue Apr 05, 2022 8:49 am

so this is the command that moves the button:

Code: Select all

command moveCircle pStartPoint,pEndPoint,pDragDurationTicks
   /*put the points of the line into a field*/
   put empty into fld "POINTS"
   put the points of graphic "Line" into fld "POINTS"
   
   //move gradually
   #set the moveSpeed to sDragDurationSeconds
   put sDragDurationTicks into fastBALL
   put 1 into POYNT
   put line POYNT of fld "POINTS" into LOKK
   repeat until line POYNT of fld "POINTS" is empty
      add 1 to POYNT
      put line POYNT of fld "POINTS" into LOKK
      move me to LOKK in fastBALL milliseconds
      subtract 0.1 from fastBALL
      #set the moveSpeed to fastBALL
   end repeat
   #move me to pEndPoint in pDragDurationTicks ticks
end moveCircle
I tried to change this line of the script

Code: Select all

subtract 0.1 from fastBALL
to

Code: Select all

add 0.1 to fastBALL
and strangely the result is the same, the button goes faster at each point instead of slowing down
Samuele.

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

Re: a customized drag command

Post by richmond62 » Tue Apr 05, 2022 10:12 am

Taking 0.1 off a load of milliseconds looks a bit odd,
and will probably have no noticeable result.

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

Re: a customized drag command

Post by richmond62 » Tue Apr 05, 2022 11:40 am

Screen Shot 2022-04-05 at 1.37.32 PM.png
-
This stack uses milliseconds.
Attachments
Slow Down.livecode.zip
Stack.
(3 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 » Tue Apr 05, 2022 5:15 pm

I don't get it, now it's even weirder, sometimes it moves at the same speed, sometimes it moves slowly then fast and sometimes it moves slow-fast-slow-fast :x :shock: :roll:
this is the script i changed

Code: Select all

command moveCircle pStartPoint,pEndPoint,pDragDurationTicks,pDragDurationSeconds
   //move gradually
   //set new variables
   put (pDragDurationSeconds / 5) into fastBALL
   put (fastBALL / 100) into slowDown
   
   /*put the points of the line into a field*/
   put empty into fld "POINTS"
   put the points of graphic "Line" into fld "POINTS"
   
   #set the moveSpeed to sDragDurationSeconds
   #put sDragDurationTicks into fastBALL
   put 1 into POYNT
   put line POYNT of fld "POINTS" into LOKK
   repeat until line POYNT of fld "POINTS" is empty
      add 1 to POYNT
      put line POYNT of fld "POINTS" into LOKK
      move me to LOKK in fastBALL milliseconds
      add slowDown to fastBALL
      #set the moveSpeed to fastBALL
   end repeat
   #move me to pEndPoint in pDragDurationTicks ticks
end moveCircle
this is the stack:
DragSpeed_weird.zip
(5.24 KiB) Downloaded 68 times
Thanks!
Samuele.

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

Re: a customized drag command

Post by richmond62 » Tue Apr 05, 2022 5:25 pm

Your code is too complicated for me to understand.

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

Re: a customized drag command

Post by Samuele » Tue Apr 05, 2022 10:17 pm

it's yours with little modifications :wink:
Samuele.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: a customized drag command

Post by Klaus » Wed Apr 06, 2022 10:03 am

Why not make it bit shorter and less cumbersome? 8)

Code: Select all

...
## put empty into fld "POINTS"
put the points of graphic "Line" into tPoints
repeat for each line tPoint in tPoints
     move me to tPoint in fastBALL millisecs
     add slowDown to fastBALL
end repeat
...

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

Re: a customized drag command

Post by Samuele » Wed Apr 06, 2022 2:29 pm

Klaus wrote:
Wed Apr 06, 2022 10:03 am
Why not make it bit shorter and less cumbersome? 8)

Code: Select all

...
## put empty into fld "POINTS"
put the points of graphic "Line" into tPoints
repeat for each line tPoint in tPoints
     move me to tPoint in fastBALL millisecs
     add slowDown to fastBALL
end repeat
...
Yes, thanks but the button still doesn't slow down gradually...
Samuele.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: a customized drag command

Post by Klaus » Wed Apr 06, 2022 2:37 pm

Sorry, no idea...

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

Re: a customized drag command

Post by richmond62 » Wed Apr 06, 2022 2:53 pm

Samuele, why do I feel that, while you are using bits of my code, you are using them "whole and undigested"?

You do need to understand my code, and you do need to understand how to change my code for
your own situation; otherwise you are not learning how to program at all, just connecting things together
and hoping they work.

I could have made your phone game for you very quickly: but I will not as you have informed me this is part of
course (University/School?) for which you will get marks . . . so the phone game MUST be your work, and you
should get marks NOT from connecting my bits of code, but for demonstrating your understanding of how
talking to a computer via a programming language works.

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

Re: a customized drag command

Post by Samuele » Thu Apr 07, 2022 11:19 pm

:lol: Yeah I would've liked that my school had programming in the school program, it's just a project I'm trying to make on my own after i finished last year a 2- year livecode course for kids (tekkie uni), and for the record I do try to understand the code before I ask here questions and actually i think i understood yours but I don't get why it doesn't work, I've been in front of the code for some time trying to figure out what's wrong but since it's not part of my school or my current programming course...
Thanks anyway
Samuele.

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

Re: a customized drag command

Post by SparkOut » Fri Apr 08, 2022 7:31 am

Richmond's example uses a straight line graphic so the points will be evenly spread. Therefore when the time taken to move between each set of points increases (the fastBALL value), the movement appears to slow down gradually.
I expect you have a complicated path to follow, where some straight sections have a large gap between the points, and some curves where the gaps are smaller. If the points are close together, then naturally the movement taking (say) 500 milliseconds will appear slower than where the points are further apart taking (eg) 510 milliseconds.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”