Ask a Question related to Macromedia Director Lingo, Design and Development.
-
ScottE #1
Moving Randomly Moving Sprite To New Location on mouseEnter
Hi All,
This is way over my head. I am currently using Director 8.
I have a randomly moving sprite(call it X) on stage (I accomplished this random movement using the Random Movement and Rotation Behavior in the Library Palette).
I have a button on the stage. What I want to do is when the user's mouse enters the button I want Sprite X to move to a new location on the stage from where ever it is currently on the stage (remember it's randomly moving). I want the user to be able to see Sprite X move to it's new location from wherever it currently is on stage and then stay at this new location for as long as the user's mouse is within the button.
on mouseOut me I want Sprite X return to approximately where it was and continue it's random movement.
The net effect I hope to accomplish is this: Basically there will be serveral randomly moving sprites on the stage and when the mouse enters the buttom I want these sprites to move to a new location (each sprite is a letter) which will then spell a word. So each sprite will have a different locH value.
I'm somewhat of a newbie with Lingo so please be as specific as your time allows.
Many Thanks!
Scott Elkins
ScottE Guest
-
Moving the ASPNET directory location
Is there a way to reconfigure the C:\Documents and Settings\\ASPNET path or the temporary directory within the ASPNET folder from the C: drive to... -
mouseEnter / mouseLeave sprite error
I get the error "This shockwave movie has errors that have causes playback problems" when I repeated pass the mouse over a text sprite with a hilite... -
moving sprite behavior in a CALCULATED parabola
ive got a Behavior written which gets the start and ending coordinate (locH, locV) points of its sprite in the timeline. Let's call these points... -
moving a sprite when the x or y axes is equaled to an nth of a pixels
for exact motion one needs a flating point accumlator that is copied to interger location each iteration. my practical experience just uses rould... -
Moving to a location on a page
Hi I have several section headings on a page and would like to be able to click on a small menu at the top of the page which would take me to it.... -
ScottE #2
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Hi All,
Can someone please help me with this?
Many Thanks,
ScottE
ScottE Guest
-
Adam Royle #3
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
You would create a new behaviour, say called something like
"MoveOnMouseOver" a bit like this
I've done most of it, the rest is up to you.This is untested by the way, so
I hope it works. The only thing
left to do is to move it bit by bit on each enterFrame event. I have
included comments. I partly left it
cause i'm lazy, and I wasn't sure if you wanted linear tweening, or easing
in, etc.
Adam
property pMoved
property pMoving
property pDestLocH
property pDestLocV
on getPropertyDescriptionList
description = [:]
addProp description,#pDestLocH, [#default:1, #format:#integer,
#comment:"Destination locH"]
return description
end
on beginSprite me
pMoved = false
pMoving = false
-- change this to suit your movie
pDestLocV = 100
end
on mouseEnter me
if not pMoved then pMoving = true
end
on enterFrame me
if not pMoved and pMoving then
-- code to move the sprite closer to dest pos
myLocH = sprite(me.spriteNum).locH
myLocV = sprite(me.spriteNum).locV
myDiff = abs((myLocH+myLocV) - (pDestLocH+pDestLocV))
if myDiff < 5 then -- snap if we're close
-- set it to our destination
sprite(me.spriteNum).locH = pDestLocH
sprite(me.spriteNum).locV = pDestLocV
pMoved = true
pMoving = false
else
-- move it closer here bit by bit
-- no more than 5 pixels at a time if we're close to our dest
end if
end if
end
"ScottE" <elkinsms@aol.com> wrote in message
news:bo9q5k$si8$1@forums.macromedia.com...> Hi All,
>
> Can someone please help me with this?
>
> Many Thanks,
> ScottE
>
>
Adam Royle Guest
-
ScottE #4
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Hi Adam,
I appreciate your help on this. I'm not an expert on Lingo and could use some additional help if you are willing.
Can you help me with the code you left out for the behavior? I'd like to ease in the sprites to the new location and then have them ease back to random movement.
Many Thanks,
Scott
ScottE Guest
-
Adam Royle #5
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
I'm not an expert on Lingo either! I only started getting into it about 3
weeks ago. However, I do know flash pretty well. The thing I wrote for you
will only move them to the new location, not back again, you'd need to add
more events, and possibly set some more properties. Also, I just realised
you'll probably have to use setScriptList to disable the random movement
object (unless you want to hack up the behaviour).
Sorry I can't really help you any more than I have, but hopefully I have put
you in the right direction.
Adam
"ScottE" <elkinsms@aol.com> wrote in message
news:bobid9$19u$1@forums.macromedia.com...some additional help if you are willing.> Hi Adam,
>
> I appreciate your help on this. I'm not an expert on Lingo and could useease in the sprites to the new location and then have them ease back to>
> Can you help me with the code you left out for the behavior? I'd like to
random movement.>
> Many Thanks,
> Scott
>
>
>
Adam Royle Guest
-
ScottE #6
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Adam thanks but I'm not really getting any where on this.
Do you or does anyone else know of some web sites that might have examples of behaviors so I can try to put this together?
Many Thanks,
Scott
ScottE Guest
-
ScottE #7
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Hi Judy,
YES! Almost exactly what I need!!!!
The only thing I need to change is to define a rectangle that limits the random movement of the sprites. The example you gave me (and THANK YOU so much!) moves the spirtes all over the stage.
Any ideas on how to define the rectangle?
MANY THANKS!
Scott
ScottE Guest
-
JPrice #8
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Just look at the exitFrame handler. That's where the limits are set:
If (pCurrentLoc.locH) >= (the stage).rect.width and pRandomVector.locH>=0
then
pCurrentLoc.locH=0
....
That's just simply saying that if the locH goes off the stage to the right,
then force it back to the left edge of the stage.
The next line in the handler does the same, but checks to see if your locH
is off to the left (< 0).
Set your own boundaries in that handler.
Judy
"ScottE" <elkinsms@aol.com> wrote in message
news:bogj7h$a8f$1@forums.macromedia.com...random movement of the sprites. The example you gave me (and THANK YOU so> Hi Judy,
>
> YES! Almost exactly what I need!!!!
>
> The only thing I need to change is to define a rectangle that limits the
much!) moves the spirtes all over the stage.>
> Any ideas on how to define the rectangle?
>
> MANY THANKS!
>
> Scott
>
>
JPrice Guest
-
ScottE #9
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Hi Judy,
Well this is embarrassing. I've tried to set the rectangle limits so the sprites move within a defined area rather than all over the stage. No luck.
The rectangle is 812W and 334H and I've tried those values and variations thereof and just simply can't get it to work.
Can you or anyone else help with this?
Many Thanks!
Scott
ScottE Guest
-
JPrice #10
Re: Moving Randomly Moving Sprite To New Location on mouseEnter
Scott,
You have to consider the location of the rectangle as well as the size.
How big is your stage, and where is the rectangle located within the stage?
Instead of using (the stage).rect.width, you might consider using your
rectangle's sprite's rect coordinates: (x is your rectangle's spriteNum)
If (pCurrentLoc.locH) >= sprite(x).right and pRandomVector.locH>=0 then
pCurrentLoc.locH=sprite(x).left
....
Judy
"ScottE" <elkinsms@aol.com> wrote in message
news:boideb$cki$1@forums.macromedia.com...sprites move within a defined area rather than all over the stage. No luck.> Hi Judy,
>
> Well this is embarrassing. I've tried to set the rectangle limits so thethereof and just simply can't get it to work.>
> The rectangle is 812W and 334H and I've tried those values and variations>
> Can you or anyone else help with this?
>
> Many Thanks!
> Scott
>
>
JPrice Guest



Reply With Quote

