Page 2 of 3
Re: a customized drag command
Posted: Mon Apr 04, 2022 5:57 pm
by richmond62
You are probably counting UPWARDS so your moveSpeed is increasing while you
should be counting DOWNWARDS.
Re: a customized drag command
Posted: Mon Apr 04, 2022 10:05 pm
by Samuele
I'm not using the
moveSpeed because it created some problems so I'm using "
"
Re: a customized drag command
Posted: Tue Apr 05, 2022 6:21 am
by richmond62
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.
Re: a customized drag command
Posted: Tue Apr 05, 2022 8:49 am
by Samuele
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
to
and strangely the result is the same, the button goes faster at each point instead of slowing down
Re: a customized drag command
Posted: Tue Apr 05, 2022 10:12 am
by richmond62
Taking 0.1 off a load of milliseconds looks a bit odd,
and will probably have no noticeable result.
Re: a customized drag command
Posted: Tue Apr 05, 2022 11:40 am
by richmond62
-
This stack uses milliseconds.
Re: a customized drag command
Posted: Tue Apr 05, 2022 5:15 pm
by Samuele
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
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:
Thanks!
Re: a customized drag command
Posted: Tue Apr 05, 2022 5:25 pm
by richmond62
Your code is too complicated for me to understand.
Re: a customized drag command
Posted: Tue Apr 05, 2022 10:17 pm
by Samuele
it's yours with little modifications

Re: a customized drag command
Posted: Wed Apr 06, 2022 10:03 am
by Klaus
Why not make it bit shorter and less cumbersome?
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
...
Re: a customized drag command
Posted: Wed Apr 06, 2022 2:29 pm
by Samuele
Klaus wrote: Wed Apr 06, 2022 10:03 am
Why not make it bit shorter and less cumbersome?
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...
Re: a customized drag command
Posted: Wed Apr 06, 2022 2:37 pm
by Klaus
Sorry, no idea...
Re: a customized drag command
Posted: Wed Apr 06, 2022 2:53 pm
by richmond62
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.
Re: a customized drag command
Posted: Thu Apr 07, 2022 11:19 pm
by Samuele

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
Re: a customized drag command
Posted: Fri Apr 08, 2022 7:31 am
by SparkOut
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.