Line Tracing
Jan Schenkel
janschenkel at yahoo.com
Fri Jan 31 22:52:01 EST 2003
--- Roger Guay <rogerguay at centurytel.net> wrote:
> Sarah, Jim
>
> What I'm trying to do is trace a line in time as a
> ball is moved across
> the screen. Near as I can tell, I want the screen
> to update but not
> redraw (if that makes any sense?) I've done this in
> ToolBook on the PC
> but I much prefer to stay on my Mac. Here is a
> description of my stack:
>
> Create a vertical line and label it "Yaxis" and an
> horizontal line and
> Label it "Xaxis" such that they intersect and
> define the origin
> somewhere near the lower left corner of your stack.
> Create a brightly
> colored circle graphic and name it "Ball." Create 2
> fields, one for
> Theta so labeled which defines the angle from the
> horizon that the ball
> is being fired, and one for V so labeled which
> defines the velocity of
> the ball when fired. Create a "Fire" button and
> insert the following
> script:
>
> on MouseUp
> global V, Xo, Yo, Theta, T, X
> --put item 1 of the rect of graphic "Yaxis" into
> Xo. Yaxis is a
> vertical line and Xo,Yo define the origin of motion
> --put item 4 of the rect of graphic "Yaxis" into
> Yo.
> put field "V" into V ---- try a value of about
> 27 in field "V"
> Put the value of field "Theta" into Theta
> ----try a value of 1.2 in
> field "Theta"
> set the loc of graphic "mortor" to Xo,Yo ----
> Graphic "mortor" is a
> small red round ball.
> show graphic "mortor"
> put 0 into T
> put xo into x
> put Yo into y
> play "Mortor.aiff"
> repeat while Y <= Yo + 1
> add 1 to T
> put the value of (Xo+V*cos(Theta)*T ) into
> x
> put the value of (Yo - V*sin(Theta)*T + .5*T^2
> ) into Y
> set the loc of graphic "mortor" to X,Y
> wait 1
> end repeat
> ---------- the rest of the script results in a
> silly explosion at the
> last location of the mortor -------
> play "Boom.aiff"
> hide graphic "mortor"
> set the loc of graphic "Burst" to x,Yo
> repeat 35
> show graphic "burst"
> wait 1
> hide graphic "burst"
> wait 1
> end repeat
> end MouseUp
>
>
>
> Jim has actually provided a solution for me that
> works well if I insert
> "wait .01" in his repeat loops. I can only assume
> it has something to
> do with processing speed of the computer (I'm using
> a high end iMac
> with OS X.) Without the "wait" command in the
> repeat loop, Jim's
> scripts are very choppy on my computer.
>
> Finally, as I say, Jim's solution works well but I
> think it would
> nevertheless be more "elegant" to do this as I have
> in ToolBook where
> one is able to stop the screen redraw.
>
> Thanks very much for joining in the fun, Roger
>
Hi Roger,
Have you had a look at the 'move' command? It's at the
heart of the RunRev Animation Manager, and you should
be able to create a smooth movement by setting a
series of points and letting the object travel along
those points with a 'move' statement.
Just a thought,
Jan Schenkel.
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
More information about the use-livecode
mailing list