I have a sprite that has a Random Movement behavior.
While the mouse is down, I want it to stop this behavior and initialize a Follow Sprite behavior instead.
When the mouse is lifted, I want to stop the Follow Sprite behavior and reset/restart the Random Movement behavior.
Openspark helped me out with a different version of a very similar behavior a long while back, which worked. It switched between Random Movement and Draggable. I tried to edit the code so that it would apply to Follow Sprite instead of Draggable, but it isn't working the way I thought it would.
The order of behaviors on my sprite is as such:
followSprite (Follow Sprite)
moveToward (The behavior described above)
randomMove (Random Movement)
turnTowardsMouse (sprite faces mouse when it is clicked)
Face Destination (if not facing mouse, sprite faces toward the randomized endpoints generated by randomMove)
This is the moveToward behavior - the middleman that's supposed to be swapping between the two:
pSprite = sprite(me.spriteNum)
-- Overrule the Random Movement and Rotation behavior until the mouse
-- is released. See the on prepareFrame() handler for the effect.
pTouching = TRUE
if pTouching then
-- Block the event from reaching the Random Movement and Rotation
-- behavior, so that only the Draggable behavior will work.
if the mouseDown then
-- The user has released the mouse.
-- Start a new movement in the Random Movement and Rotation behavior.
pSprite.pPath = VOID
pSprite.pRotate = VOID
pTouching = 0
Can anyone help me figure this out?
If you want to imagine a visual, it's essentially a touchscreen fish tank. Fish swim around randomly, but when someone is touching the screen, they approach the point of contact (which is defined by a tiny invisible sprite centered on the cursor).
Once again, thank you so much to anyone who can help me out. This is part of a capstone undergraduate art project I am doing - and I am far more experienced in making the visuals than I am in coding. I am having to mostly tackle Lingo on my own. Any coding help I've received will be recognized (with permission) on my artist website as well as a thesis paper I am writing that will be published in May.