Ask a Question related to Macromedia Director Lingo, Design and Development.
-
Gon2001 webforumsuser@macromedia.com #1
Sprite Interaction
Okay, I've tried here once, and I'm going to try again. I'm trying to create interaction between two different sprites. For instance, I have a lever that moves vertically and there is a "pressure gauge needle" that needs to correspond with the levers vertical position. So, if the lever moves x-amount of pixels, the needle rotates x-amount of degrees.
Anyone? Lingo? Tutorials? Examples?
Gon2001 webforumsuser@macromedia.com Guest
-
Overlay of 2d sprite over a 3d sprite
Hey; I am having a heck of a time getting a 2D sprit to show abouve a 3D scean. Is it even possible? if so how...? -
making bumpers for sprite interaction
I have two boxes. One has it's location tied to the mouse, and the other can be pushed by the box attached to the mouse. I am doing collision... -
sprite interaction question
I have two boxes, a black one and a brown one. The position of the black box is that of the mouse. The black box can move the brown one by pushing... -
Sprite detecting sprite
Hi All, I'm trying to get a sprite to recognise when another sprite is wholly within its boundary, any suggestions? Regards AJJA17 "I can... -
Search text in sprite and play the sprite
Hi I am working on a project having many text cast, placed sequentially in chapters on the time line. Most of the access is sequential like... -
JB #2
Re: Sprite Interaction
Saw your earlier post, it tough to address the multiple issues involved
in a short responce.
As far as the communication between sprites, say you wanted 1 pixel of
bar movement to translate to 1 degree of rotation.
-- bar script
on barOffset me, pixelsFromBaseValue
sendSprite 10, #angleOffset, pixelsFromBaseValue -- talk to gauge
-- gauge handler (sprite 10)
on angleOffset, me, newAngle -- called by external sprite
sprite(me.spriteNum).rotation = newAngle
end
JB Guest
-
Rob Dillon #3
Re: Sprite Interaction
That lever control will just be a variation on a slider control. A
vertical slider control uses the position of the sliding element
against the full distance to be moved to create a ratio. You then use
that ratio to represent something else, usually sound volume or sprite
movement.
In your case you want to change the rotation property value of a dial
sprite. To do that you will need to set a minimum and maximum value for
that rotation value and then use another sprite to describe the full
distance that the "lever" sprite can be moved.
It might look something like this:
--------
property thisSprite -- the lever, or slider
property constraintSprite -- the sprite that constrains the movement of
the lever
property dialSprite --the sprite that shows the result
property minRotation -- the minimum rotation value
property maxRotation -- the maximum rotation value
property zeroPoint -- the bottom of the constrainer sprite
property constraintHeight -- the height of the constrainer sprite
property animateMe
on getPropertyDescriptionList
myPropList = [#constraintSprite:[#comment:"enter the constraint
sprite number:",#format:#integer,#default:5],
#dialSprite:[#comment:"enter the dial sprite
number",#format:#integer,#default:10],#minRotation:[#comment:"select
the minimum dial rotation value:",#range:[#min:0,#max:90],#default:0],
#maxRotation:[#comment:"select the maximum dial rotation
value:",#range:[#min:180,#max:270],#default:180] ]
return myPropList
end
on beginSprite me
thisSprite = me.spriteNum
zeroPoint = sprite(constrainerSprite).bottom
constraintHeight = sprite(constrainerSprite).height
animateMe = 0
end
on mouseDown me
animateMe = 1
end
on mouseUp me
animateMe = 0
end
on mouseUpOutside me
animateMe = 0
end
on prepareFrame me
if animateMe then
sprite(thisSprite).locV = constrainV(constrainSprite,the mouseV)
sprite(dialSprite).rotation = ((zeroPoint -
sprite(thisSprite).locV)/float(constrainerHeight) * (maxRotation -
minRotation)) + minRotation
end if
end
-----------
the function that gives the rotation value looks a little complex. The
first part finds the distance of the moving control from the bottom of
the constrainer sprite. Then you divide that number by the total
distance that it can move. This gives you a ratio. You need to use the
float() function to convert one of those numbers to a floating point
number so that you'll get a decimal value back. Then you subtract the
minimum rotation value from the maximum to get the full range and
multiply that by the ratio value. Finally you add the minimum value to
the result. This will give you a new rotation value to use to move the
dial sprite.
This is a very simple example, but it should get you started.
--
Rob
_______
Rob Dillon
Team Macromedia
[url]http://www.ddg-designs.com[/url]
412-243-9119
[url]http://www.macromedia.com/software/trial/[/url]
Rob Dillon Guest
-
Gon2001 webforumsuser@macromedia.com #4
Re: Sprite Interaction
Rob,
I sent you an e-mail about this response. If you received it, could you let me know? I'm a bit lost in the parameters of the Lingo and my professor is trying to help as much as she can.
Thanks,
Chris
[email]ctst@att.net[/email]
Gon2001 webforumsuser@macromedia.com Guest



Reply With Quote

