Thanks!! a lot Adam, I'll try it.

-----Original Message-----
From: Adam [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 27, 2003 7:39 PM
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l> wait

on 3/27/03 7:09 PM, DT-Rene Vazquez at [EMAIL PROTECTED] wrote:

> Hi, I'm trying to animate a sprite by script code with lingo. I move
the
> sprite with a while loop sprite by increasing its locV property, but I
> want to introduce some delay between each change in position in order
to
> see the animation. Can someone give me some guide to achieve this
effect
> or something similar?

Generally, I don't use repeat or while loops for animation, since they
make
the animation dependent on the speed of the CPU rather than the
framerate or
any user-defined speed setting, and they tie up the CPU preventing
frames
from advancing normally for everything else in the movie. When I do
animations that are all lingo driven, I usually set the movie framerate
high
and govern the speed of sprites using "the ticks" or "the milliseconds".

For example, make a movie with a high framerate (like 999) and give a
sprite
this behavior:

----- Code starts here

property pNextMoveTime, pInterval

on beginsprite me
  pNextMoveTime = the ticks
  pInterval = 20 -- move no faster than every 3 ticks
end

on enterframe me
  if (the ticks>=pNextMoveTime) then
    sprite(me.spritenum).locH = sprite(me.spritenum).locH + 1
    pNextMoveTime = the ticks + pInterval
  end if
end

----- Code snip ends here

Setting pInterval to 0 will move the sprite on everyframe, as fast as
your
framerate or as fast as your computer can do it. But setting pInterval
to 1
will give you a movement of 60fps so long as your movie framerate is set
significantly higher than 60 and your machine is keeping up. Bump
pInterval
to 2 and you get movement 30 times a second and so on. If you have a
very
fast machine and need finer control than 1/60th of a second chunks, you
can
also use the milliseconds global in the same manner.

-Adam
[EMAIL PROTECTED]

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]).
Lingo-L is for learning and helping with programming Lingo.  Thanks!]
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email [EMAIL 
PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping 
with programming Lingo.  Thanks!]

Reply via email to