2 Replies Latest reply on Jul 5, 2007 1:47 AM by Newsgroup_User

    How do i set the locV and locH of a number of sprites using lingo?

    wgb14 Level 1
      Hi All,

      I am trying to set the locV and locH of a number of sprites on my stage using lingo, but i am unsucessull so far. Here is my code but it fails to work.

      sprite(9).locH = 26
      sprite(9).locV = 72
      sprite(2).locH = 53
      sprite(2).locV = 187
      sprite(4).locH = 53
      sprite(4).locV = 210
      sprite(5).locH = 318
      sprite(5).locV = 219

      I understand that I need some form of repeat to make it work, but i am not sure how to do that! Any ideas?
        • 1. Re: How do i set the locV and locH of a number of sprites using lingo?
          johnAq Level 1
          I don't think you need a repeat loop. There doesn't appear to be anything wrong with the individual lines of code, though they could be shortened to:

          sprite(9).loc = point(26, 72)
          sprite(2).loc = point(53, 187)
          sprite(4).loc = point(53, 210)
          sprite(5).loc = point(318, 219)

          However, how are you running these lines of code? If you run them straight from the message window when the movie isn't running you won't see any result unless you also issue an updateStage command to redraw the stage. But that is not recommended.

          Normally if the movie is running a frame redraw will perform the updateStage automatically. But you don't indicate how you are triggering this code.

          For example:

          on moveSprites
          sprite(9).loc = point(26, 72)
          sprite(2).loc = point(53, 187)
          sprite(4).loc = point(53, 210)
          sprite(5).loc = point(318, 219)
          end

          on startMovie
          moveSprites()
          end

          OR in frame script

          on exitFrame
          moveSprites()
          end

          hth

          johnAq
          • 2. Re: How do i set the locV and locH of a number of spritesusing lingo?
            Level 7
            Hi,

            Not sure exactly what you need to do, but here's an example that may help. Say I
            have 5 sprites that need to be moved vertically and horizontally. And say they
            have to move by the same amount - 100 pixels, I'd do the following. First, I'd
            make sure that all the sprites to be moved are grouped together in a range of
            channels (say 6 to 10). Then I'd use:

            repeat with x = 6 to 10
            sprite(x).locH = sprite(x).locH + 100
            sprite(x).locV = sprite(x).locV + 100
            end repeat

            Using a repeat loop, I get the statements to execute multiple times with x = 6,
            7, 8, 9, 10 (my various sprites)

            Hope that helps.

            regards
            Dean

            Director Lecturer / Consultant / Director Enthusiast
            http://www.fbe.unsw.edu.au/learning/director
            http://www.multimediacreative.com.au
            email: d.utian@unsw.edu.au