Re: Stop-Start: animation along a path
Posted: Mon Jul 04, 2016 4:26 pm
Well, you can use the same code also with the points of any graphic. It works better and smoother, because it uses the send loop. Look here:
########CODE#######
on mouseUp
if the label of me is "GO" then
set the label of me to "STOP"
else
set the label of me to "GO"
end if
moveSun
end mouseUp
on moveSun
if the label of me is "STOP" then
put the points of graphic 1 into mypoints
put the angolo of me into temp
if temp is empty then put 1 into temp #this is useful for the first launch
put line temp of mypoints into newloc
set the loc of button "Sun" to newLoc
add 1 to temp
if temp > the number of lines of mypoints then
put empty into temp
end if
set the angolo of me to temp
send "movesun" to me in 0.01 sec
end if
end moveSun
#####END OF CODE#####
Moreover you can also edit the graphic during sun movement!!!
########CODE#######
on mouseUp
if the label of me is "GO" then
set the label of me to "STOP"
else
set the label of me to "GO"
end if
moveSun
end mouseUp
on moveSun
if the label of me is "STOP" then
put the points of graphic 1 into mypoints
put the angolo of me into temp
if temp is empty then put 1 into temp #this is useful for the first launch
put line temp of mypoints into newloc
set the loc of button "Sun" to newLoc
add 1 to temp
if temp > the number of lines of mypoints then
put empty into temp
end if
set the angolo of me to temp
send "movesun" to me in 0.01 sec
end if
end moveSun
#####END OF CODE#####
Moreover you can also edit the graphic during sun movement!!!