Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...?
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139