Hi,
At 09:12 22/01/01 -0000, Matt wrote:
>I'd like to know how to make a sprite move in from one side of the screen
>to the centre, pause for 5 seconds, maybe jump up slightly, then move back
>to the side of the screen and stay there until clicked on again.
The simplest thing that comes in mind is allocating three timers.
Supposing that your sprite, say the sprite number n, is initially
located at prevLoc, that's on one side of the screen (or anywhere)
and your code is able to call the handler jumpToCenter upon some
mouse action (or whatever else), you could write:
global prevLoc
on jumpToCenter
-- add her some code to inhibit the action that got this handler
-- called, in order to avoid multiple timeout objects allocated.
-- Or else, redirect the effects of that action elsewhere by
-- making the program aware that the sprite is actually located
-- in the center of the stage.
prevLoc = sprite(n).loc
sprite(n).loc = point(0.5 * (the stageRight - the stageLeft), /
0.5 * (the stageBottom - the stageTop))
-- move back after a 5 secs pause
timeOut("MoveBack").new(5000, #moveBack, VOID)
-- jump up after 2.5 secs from the pause start
timeOut("JumpUp").new(2500, #jumpUp, VOID)
-- jump down after 3.0 secs from the pause start
timeOut("JumpDn").new(3000, #jumpDn, VOID)
end
on jumpUp
sprite(n).locV = sprite(n).locV - k -- k is the jump's up range in pixels
timeOut("JumpUp").forget()
end
on jumpDn
sprite(n).locV = sprite(n).locV + k
timeOut("JumpDn").forget()
end
on moveBack
sprite(n).loc = prevLoc
timeOut("MoveBack").forget()
end
Using timers you get asyncronous events in respect with the exitFrame
events and in a sense you set yourself free of them upon the point of
view of timing. Though the screen is redrawn on the exit frame events
only, so you may wish to set the movie rate properly higher than the
timer events.
Due to the long intervals of time requested between the 'jump' events
of your sprite, also an FPS as slow as 10 should be sufficient in this
case.
Notice also that in some circumstances a timeout objects created with
a timeout value of 5000 milliseconds (5 secs) seems sending its events
a little before than the wanted time has elapsed. So base on tries to
fine tune timeout values.
I could not test the code above. It should work, but consider it as
an example from which to get started.
HTH,
Franco
IFC Programming Consultant
http://www.chnexus.com/main.htm
Private mailto:[EMAIL PROTECTED]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]