Scrolling sprites in multiple channels

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

  1. #1

    Default Scrolling sprites in multiple channels

    Hi there,

    I have sprites in 3 channels that need to scroll together. I was hoping I could use the script I used below for a simple 1 channel scroll.

    --------------------------------------------------------------------------------------------------------------------
    on mouseWithin
    if sprite(3).locV < 545 then -- constraint for sprite(7)
    sprite(3).locV = sprite(3).locV + 6 -- sets speed for scrolling down
    end if

    updateStage -- redraws the Stage immediately showing the new location of sprites
    end mouseWithin
    --------------------------------------------------------------------------------------------------------------------

    I need to know if its possible to define the 3 channels in a group somehow in the above script?

    Please Please HELP! :)

    Thanks


    Hardcore Guest

  2. Similar Questions and Discussions

    1. Streaming multiple audio channels
      Hello all. I am a software developer for a major metropolitan fire department and we are investigating adding streaming audio to our intranet site....
    2. Please - need help using multiple sound channels
      Hello Users. I am a complete newbie when it comes to Director. I want to create a simple project with sound. I have 3 small sound clips: tecno.wav,...
    3. Using Lingo to stop sprites from scrolling at a certain point.
      Hi All, I have a project I'm working on. Basically, I have 10 sprites that move horizontally left or right when moused over. The problem I have...
    4. Merging Multiple Channels
      I have received a file with 8 alpha channels. I need to convert this to a jpg. There is only 1 background layer. When I convert to cmyk or rgb, the...
    5. manipulating Flash in multiple channels
      I feel a complete fool. This seems so simple. In channel 1, I have a .swf entitled "puzzle" In channel 2, I have a .swf entitled "menu-bar" ...
  3. #2

    Default Re: Scrolling sprites in multiple channels

    U cannot group objects in Lingo. That would be an awesome feature.

    Are u trying to scroll a text member??? an image, a Flash object???

    Arturo




    "Hardcore" <insane@netactive.co.za> escribió en el mensaje
    news:bqg5sk$gso$1@forums.macromedia.com...
    > Hi there,
    >
    > I have sprites in 3 channels that need to scroll together. I was hoping I
    could use the script I used below for a simple 1 channel scroll.
    >
    > --------------------------------------------------------------------------
    ------------------------------------------
    > on mouseWithin
    > if sprite(3).locV < 545 then -- constraint for sprite(7)
    > sprite(3).locV = sprite(3).locV + 6 -- sets speed for scrolling
    down
    > end if
    >
    > updateStage -- redraws the Stage immediately showing the new location of
    sprites
    > end mouseWithin
    > --------------------------------------------------------------------------
    ------------------------------------------
    >
    > I need to know if its possible to define the 3 channels in a group somehow
    in the above script?
    >
    > Please Please HELP! :)
    >
    > Thanks
    >
    >

    Arturo Toledo Guest

  4. #3

    Default Re: Scrolling sprites in multiple channels

    Hi Arturo,

    Thanks for the reply...

    I guess we have another item to add to the next version wish list! :)

    The sprites I want to move are images. I would have made them all one image, but I have 2 buttons that need to be active as well!

    Any other ideas that may help me?

    Thanks
    M


    Hardcore Guest

  5. #4

    Default Odp: Scrolling sprites in multiple channels

    Instead of using groups... we can use the same script for all those sprites
    and use me.SpriteNum

    don't ya think ?

    regards
    lukpcn



    Użytkownik Hardcore <insane@netactive.co.za> w wiadomooci do grup
    dyskusyjnych napisał:bqhgsn$eg5$1@forums.macromedia.com...
    > Hi Arturo,
    >
    > Thanks for the reply...
    >
    > I guess we have another item to add to the next version wish list! :)
    >
    > The sprites I want to move are images. I would have made them all one
    image, but I have 2 buttons that need to be active as well!
    >
    > Any other ideas that may help me?
    >
    > Thanks
    > M
    >
    >

    luk Guest

  6. #5

    Default Re: Scrolling sprites in multiple channels

    You have a number of options. You can just add the other two sprites to
    the same function:

    --------
    on mouseWithin
    if sprite(3).locV < 545 then -- constraint for sprite(7)
    sprite(3).locV = sprite(3).locV + 6 -- sets speed for scrolling
    down
    sprite(X).locV = sprite(X).locV + 6
    sprite(Y).locV = sprite(Y).locV + 6
    end if
    end mouseWithin
    ---------

    You don't need to use updateStage with a mouseWithin function,
    mouseWithin sends messages at the frame rate and so the state will be
    updated at the frame rate in any case.

    or:

    ---------
    property spritesToMove

    on beginSprite me
    spritesToMove = [3,4,5]
    end

    on mouseWithin
    if sprite(spritesToMove[1]).locV < 545 then
    repeat with i in spritesToMove
    sprite(i).locV = sprite(i).locV + 6
    end repeat
    end if
    end
    ---------

    I would do this sort of thing by creating a property to hold a boolean
    value and then set that boolean value in a mouseEnter and mouseLeave
    function. Then I would use a prepareFrame function to change the locV
    of each of the sprites. Something like this:

    ---------

    property thisSprite
    property animateMe
    property spritesToMove
    property maxDistance
    property eachStep

    on getPropertyDescriptionList
    myPropList = [:]
    myPropList[#spritesToMove] = [#comment:"enter the sprite numbers to
    be animated, separate with commas:",#format:#string,#default:"1,2,3"]
    myPropList[#maxDistance] = [#comment:"enter the maximum distance for
    sprite's locV:",#format:#integer,#default:545]
    myPropList[#eachStep] = [#comment:"select a step distance to
    move:",#range:[#min:1,#max:20],#format:#integer,#default:6]
    return myPropList
    end

    on beginSprite me
    thisSprite = me.spriteNum
    animateMe = 0
    spritesToMove = stringToList(spritesToMove)
    end

    on mouseEnter me
    animateMe = 1
    end

    on mouseLeave me
    animateMe = 0
    end

    on prepareFrame me
    if animateMe then
    if sprite(spritesToMove[1]).locV < maxDistance then
    repeat with i in spritesToMove
    sprite(i).locV = sprite(i).locV + eachStep
    end repeat
    end if
    end if
    end

    on stringToList theString
    tempList = []
    oldDelim = the itemDelimiter
    the itemDelimiter = ","
    thisManyItems = theString.item.count
    repeat with i = 1 to thisManyItems
    tempList[i] = value(theString.item[i])
    end repeat
    the itemDelimiter = oldDelim
    return tempList
    end
    -------

    Now you can adjust every aspect of your animation: the sprites that are
    moved, the distance and the starting point.

    --
    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

  7. #6

    Default Re: Scrolling sprites in multiple channels

    Hey Rob,

    Thanks... worked like a charm!

    M


    Hardcore Guest

  8. #7

    Default Re: Scrolling sprites in multiple channels

    On 01 Dec 2003, "Hardcore" <insane@netactive.co.za> wrote:
    > I have sprites in 3 channels that need to scroll together. I was
    > hoping I could use the script I used below for a simple 1 channel
    > scroll.
    Just to add another solution, "Follow the leader", based on sprite.loc
    positions.

    Here's a behavior you can drop on as many "follower" sprites as you wish.
    It's easiest if you select all those sprites in the score and drop this
    behavior on them all at once. Just point it to the "Leader" sprite.

    -- Follow the Leader behavior
    property pLeadSprite
    property pLeadLoc
    property pOffSet
    property pSprite

    on beginSprite me
    pSprite = sprite(me.spriteNum)
    myLoc = pSprite.loc
    pOffSet = myLoc - sprite(pLeadSprite).loc
    pLeadLoc = sprite(pLeadSprite).loc
    end

    on prepareFrame me
    if sprite(pLeadSprite).loc <> pLeadLoc then
    pSprite.loc = sprite(pLeadSprite).loc + pOffSet
    pLeadLoc = sprite(pLeadSprite).loc
    end if
    end

    on getPropertyDescriptionList me
    sprList = getSprites(me)
    pList = [:]

    pList[#pLeadSprite] = [#comment:"Which sprite do I follow?"]
    pList[#pLeadSprite][#format] = #integer
    pList[#pLeadSprite][#default] = 10
    pList[#pLeadSprite][#range] = sprList
    return pList
    end

    on getSprites me
    sprList = []
    repeat with i = 1 to the lastChannel
    if sprite(i).member.type <> #EMPTY then
    add (sprList, i)
    end if
    end repeat
    return sprList
    end

    There have also been suggestions using sendSprite messages to inform any
    "follower" sprites that it's time to move and where to move.


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd 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