I think this is what is happening...

- If it is less than the destination you add to it, and then see if you 
added too much, in which case you try to set it to the final location.

- Eventually you will get to the destination.  The locH will be equal to 
the destination.

- Since it is EQUAL, it will fail the first 'if', which sees if it is <.

- Since it failed, it will go to your unconditional else, which 
automatically adds some pixels on.  Remember that you are ALREADY at the 
destination so you don't want to add pixels, but you are.

- The next line checks to see if you are <= the destination (which you are 
not, since you were adding).  It might have corrected, but it won't, since 
you are past the destination already.

You could probably correct this by changing the unconditional else to be a:

else if (sprite(me.spritenum).loch > pDestination)

which means that if it's < then you add, and if it's > then you subtract, 
but if it's = then you leave it alone.


At 08:07 PM 7/25/01 -0500, Locke Morgan wrote:
>Dear List,
>
>--Newbie here--
>           My behavior works great for sprites whose original location is
>greater than the destination (as far as stopping the animation at the
>destination), but when the original position is less than the destination
>the animation continues off the screen.  What am I missing?
>
>--script snip
>
>on exitframe me
>     Case (pControl) of
>       "Move horizontally"
>         if (sprite(me.spritenum).loch < pDestination) then
>           sprite(me.spritenum).loch = sprite(me.spritenum).loch + pRange
>           if (sprite(me.spritenum).loch >= pDestination) then
>             sprite(me.spritenum).loch = pDestination
>             updateStage
>           end if
>         else
>           sprite(me.spritenum).loch = sprite(me.spritenum).loch + pRange
>           if (sprite(me.spritenum).loch <= pDestination) then
>             sprite(me.spritenum).loch = pDestination
>             updateStage
>           end if
>         end if
>       "Move vertically"
>         if (sprite(me.spritenum).locv < pDestination) then
>           sprite(me.spritenum).locv = sprite(me.spritenum).locv + pRange
>           if (sprite(me.spritenum).locv >= pDestination) then
>             sprite(me.spritenum).locv = pDestination
>             updateStage
>           end if
>         else
>           sprite(me.spritenum).locv = sprite(me.spritenum).locv + pRange
>           if (sprite(me.spritenum).locv <= pDestination) then
>             sprite(me.spritenum).locv = pDestination
>             updateStage
>           end if
>         end if
>
>--end script snip
>
>W. Locke Morgan
>New Orleans, LA - USA
>
>
>[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!]


[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!]

Reply via email to