a customized drag command
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: a customized drag command
You are probably counting UPWARDS so your moveSpeed is increasing while you
should be counting DOWNWARDS.
should be counting DOWNWARDS.
Re: a customized drag command
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.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: a customized drag command
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.
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
so this is the command that moves the button:
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
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
Code: Select all
subtract 0.1 from fastBALL
Code: Select all
add 0.1 to fastBALL
Samuele.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: a customized drag command
Taking 0.1 off a load of milliseconds looks a bit odd,
and will probably have no noticeable result.
and will probably have no noticeable result.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: a customized drag command
This stack uses milliseconds.
- Attachments
-
- Slow Down.livecode.zip
- Stack.
- (3 KiB) Downloaded 73 times
Re: a customized drag command
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
this is the stack:
Thanks!
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
Samuele.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: a customized drag command
Your code is too complicated for me to understand.
Re: a customized drag command
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
Yes, thanks but the button still doesn't slow down gradually...Klaus wrote: ↑Wed Apr 06, 2022 10:03 amWhy 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 ...
Samuele.
Re: a customized drag command
Sorry, no idea...
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: a customized drag command
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.
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
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
Thanks anyway
Samuele.
Re: a customized drag command
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.
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.