10 Replies Latest reply on Apr 5, 2008 8:23 PM by ßryD

    Two Random Points

    ßryD
      Hello Again,

      I would like to ask what the lingo would be if I were to have an line animation from one point to the other if the points were to appear on random/different positions on each event/time/click.

      Thank you.
        • 1. Re: Two Random Points
          robdillon Most Valuable Participant
          You can use the draw() method to create that line. Something like this might work for you:

          on drawLine
          _movie.stage.image.draw(0, 0, 128, 86, rgb(150,0,0))
          end

          0,0 is the starting point, and 128,86 is the end point. The rgb value is the color of the line. To have the line's length animate just use a series of draw() methods with new ending point values.
          • 2. Re: Two Random Points
            ßryD Level 1
            Thank you, it was very helpful

            another thing, can the thickness of the line be changed?
            • 3. Re: Two Random Points
              Lukewig Level 1
              Hi,

              Have a look at "atterns with lines" at http://www.lingoworkshop.com/examples/Vignettes.php for some ideas.

              To change the linethickness, specify a #lineSize property:

              colorObjOrParamList = [#lineSize: 4, #shapeType: #line]
              imageObjRef.draw(point(x, y), point(x, y), colorObjOrParamList)
              • 4. Two Random Points
                ßryD Level 1
                I can't connect to lingoworkshop, it always timed out. I'll try again later.

                tried this and had an error

                global Origin
                global PointA
                global PointB
                global End

                on mouseUp
                if Origin="Hill", PointA="Tree", PointB="Rock", End="River" then
                _movie.stage.image.draw(20, 10, 50, 40, rgb(150,0,0))
                _movie.stage.image.draw(50, 40, 60, 30, rgb(150,0,0))
                _movie.stage.image.draw(60, 30, 80, 50, rgb(150,0,0))
                _movie.stage.image.draw(80, 50, 90, 90, rgb(150,0,0))
                end if
                end

                I have other "else if" conditions but I just need to make this 1st one work properly.

                I couldn't test this because there are only 2 PC here that has director and we have to take turns in using it.

                Is there a more efficient way of doing it or do I have to make one "else if" condition for each combination?

                thank you

                Edit:
                Is it possible to use;
                _movie.stage.image.draw(Hill, Tree, rgb(150,0,0))
                with the "Hill" has the point (20, 10) an the "Tree" (50, 40)
                • 5. Re: Two Random Points
                  ßryD Level 1
                  Hello,

                  it's me again,

                  I would like to ask if you can draw a line between two sprites without using the coordinates of those sprites.

                  like;
                  a line sprite(10) and sprite(11)
                  • 6. Re: Two Random Points
                    Level 7
                    ?ryD wrote:
                    > if Origin="Hill", PointA="Tree", PointB="Rock", End="River" then

                    Director will not understand what you mean by the commas.

                    Presumably you mean

                    if Origin="Hill" and PointA="Tree" and PointB="Rock" and End="River" then

                    Andrew


                    • 7. Re: Two Random Points
                      Level 7
                      ?ryD wrote:
                      > Hello,
                      >
                      > it's me again,
                      >
                      > I would like to ask if you can draw a line between two sprites
                      > without using the coordinates of those sprites.
                      >
                      > like;
                      > a line sprite(10) and sprite(11)

                      You can use sprite(10).loc to avoid typing in the actual numbers.

                      See also .locH, .locV, .left, .top, .right, .bottom, .width, and .height.

                      Andrew


                      • 8. Two Random Points
                        ßryD Level 1
                        quote:

                        Originally posted by: Newsgroup User
                        You can use sprite(10).loc to avoid typing in the actual numbers.

                        See also .locH, .locV, .left, .top, .right, .bottom, .width, and .height.

                        Andrew





                        Thanks for the help about the sprite(#).loc script. I'll try that when I get a turn at the PC. I had to learn about that comma thing the hard way.

                        will the script look like this?
                        on enterframe
                        movie.stage.image.draw(sprite(#).loc, sprite(#).loc, rgb(150,0,0))
                        end
                        • 9. Re: Two Random Points
                          Level 7

                          > will the script look like this?
                          > on enterframe
                          > movie.stage.image.draw(sprite(#).loc, sprite(#).loc, rgb(150,0,0))
                          > end
                          >

                          That code will work. It will redraw the line on every enterFrame event,
                          and it will not remove it, so it will look like a whole lot of lines if
                          the things are moving. Instead of drawing directly onto the stage
                          image, you can put a backgroundtransparent image on the stage and draw
                          onto that. Then it can have code to make it blank before drawing on it.
                          That way you have more control over it. Also, you might want to use
                          this syntax to get a little more control over the rendering of the line:


                          movie.stage.image.draw(sprite(#).loc, sprite(#).loc,
                          [#color:rgb(150,0,0),#shapetype:#line,#linesize:1])

                          (watch for inadvertent line breaks... that should be a single line of code)

                          The point is that this way you can easily control the type of line drawn
                          and the width of it. as well as the color.
                          • 10. Re: Two Random Points
                            ßryD Level 1
                            Thank you very much.
                            I can't wait to try it.