On Thursday, August 15, 2002, at 07:20 PM, John Hart wrote:

> I need to move a sprite from off stage to a specific location on stage, 
> pH, using Lingo.  I've tried several ideas,but can't get it.  Need some 
> ideas, please.

First idea: Don't use repeat loops.
Second idea: Set a flag.
Third idea: Query that flag on exitFrame and move the sprite.

Something like this:

   PROPERTY pyMyMotion, pnMyTargetH

   on beginSprite me
     pyMyMotion = #none
   END beginSprite

   on exitFrame me
     if pyMyMotion <> #none then
       me.MoveIt()
     end if
   END exitFrame

   on Motion me, yDirection, pH
     pyMyMotion = yDirection
     pnMyTargetH = pH
   END Motion

   on MoveIt me
     if pyMyMotion = #left then
       if sprite(me.spriteNum).locH < pnMyTargetH then
         sprite(me.spriteNum).locH = sprite(me.spriteNum).locH + 1
       else
         pyMyMotion = #none
       end if
     else
       if sprite(me.spriteNum).locH > pnMyTargetH then
         sprite(me.spriteNum).locH = sprite(me.spriteNum).locH - 1
       else
         pyMyMotion = #none
       end if
     end if
   END MoveIt

You'd call it like this:

   sendSprite ( whatever, #motion, #left, 500 )

or

   sendSprite ( whatever, #motion, #right, 10 )

Should do it. It'll theoretically update as fast as your framerate.


              Warren Ockrassa | http://www.nightwares.com/
  Director help | Free files | Sample chapters | Freelance | Consulting
        Author | Director 8.5 Shockwave Studio: A Beginner's Guide
                    Published by Osborne/McGraw-Hill
        http://shop.osborne.com/cgi-bin/osborne/0072195622.html

[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