7 Replies Latest reply on Dec 15, 2008 10:37 PM by JonnyHilly

    Generating Text Sprites in Lingo ?

    JonnyHilly
      Hi, I'm trying to generate a bunch of text sprites via Lingo.
      I can generate regular bitmap sprites just fine this way.... e.g. for a bunch of particles in an explosion.
      But I'm having trouble figuring out how to do the same thing in order to generate 'N' text sprites as the movie is running. (pre making them by hand in the editor is not an option)

      So if I found a free sprite slot, how do I turn it into a text sprite, and set the font/point size etc... ?

      any help appreciated.
      Thanks
        • 1. Re: Generating Text Sprites in Lingo ?
          Level 7
          > So if I found a free sprite slot, how do I turn it into a text sprite, and set
          > the font/point size etc... ?

          -- first you create a #text member with:
          tTextMember = _movie.newMember(#text)
          -- and set its properties like:
          tTextMember.font = "Arial"
          tTextMember.fontSize = 36
          -- whatever other props:
          tTextMember.text = "test"
          tTextMember.color = color(255, 0, 0)
          -- display it on the stage:
          sprite(n).member = tTextMember
          • 2. Re: Generating Text Sprites in Lingo ?
            JonnyHilly Level 1
            thanks that works great.

            Just one new problem now...
            How do I determine the width of the character or string I am printing in pixels ?
            So that I can correctly center them inside my text boxes ?
            The help documentation doesn't offer any clues that I can find.

            thanks again
            • 3. Re: Generating Text Sprites in Lingo ?
              Level 7
              JonnyHilly wrote:
              > How do I determine the width of the character or string I am printing
              > in pixels ?
              > So that I can correctly center them inside my text boxes ?
              > The help documentation doesn't offer any clues that I can find.

              Would changing its alignment help?

              tTextMember.alignment="center"

              Andrew


              • 4. Re: Generating Text Sprites in Lingo ?
                James Newton, ACP Level 3
                You have cross-posted this question to the Director Online forum, and perhaps also elsewhere. Once you have a satisfactory answer to your question, please collate all replies and post them to all the places where you asked the question, so that others with a similar question can find the solution.

                Thanks.
                • 5. Generating Text Sprites in Lingo ?
                  JonnyHilly Level 1
                  yep the answer to the first part was already poseted in both forums. I'll continue to do do this, thanks for the tip.

                  thanks Andrew
                  for the second part... I had to use #center instead of "center" as it was a run-time created member text sprite.
                  But this moved my printed character about 200 or 300 pixels away from where it was supposed to be.
                  Probably because the text sprite co-ordinates and size do not match the size of the graphic sprite text box below it, so it doesnt know how to center it properly.
                  It would still be nice if there was a way to get the pixel width of a string, word or character that it is going to print.
                  • 6. Re: Generating Text Sprites in Lingo ?
                    Level 7
                    JonnyHilly wrote:
                    > for the second part... I had to use #center instead of "center" as it

                    That's what I get for checking in the help file...

                    > It would still be nice if there was a way to get the pixel width of a
                    > string, word or character that it is going to print.

                    member("textMember").charPosToLoc(length(member("textMember").text) + 1))

                    Andrew


                    • 7. Re: Generating Text Sprites in Lingo ?
                      JonnyHilly Level 1
                      thanks Andrew that did the trick..
                      the final line is..
                      charWid = tTextMember.charPosToLoc(length(tTextMember.text) + 1).locH