1 Reply Latest reply on Sep 9, 2006 5:26 PM by mirianam

    Vector shape to scale with text

    mirianam Level 1
      Hello
      I am needing some help with vector shape and text.
      The vector shape is a cartoon/comic book like box ( a rectangle with rounded corners and a spike pointing to persons mouth - sort of like a thought bubble) and I want to have changing text inside this vector shape.

      I am having trouble aligning the two.

      I am using the height property to change the height of the vector according to the amount of text but I can't work out how to calculate the offset (or whatever). I'm guessing that as text has reg point at top left and vector shape not. Can someone please give me some guidance.

      Here is the code for chaging the text. I'm using an empty text sprite as the text placeholderwhich is on top of my vector box

      property pTargetSprite --placeholder sprite
      property pMyTextMember --text which goes into the placeholder sprite postion
      property pMySprite

      on getPropertyDescriptionList me
      set pdList = [:]
      addprop pdList, #pTargetSprite, [#comment: "Which sprite is target?", #format: #integer, #default: 26]
      addprop pdList, #pMyTextMember, [#comment: "Which cast member?", #format: #text, #default: "placeholder"]
      return pdList
      end getPropertyDescriptionList

      on beginSprite me
      pMySprite = sprite(me.spriteNum)
      end

      on mouseUp me
      sprite(pTargetSprite).member = member(pMyTextMember)

      sprite(17).height = member(pMyTextMember).height + 50 --sprite(17) is the vector shape "cartoon speech box"
      end


      Thank you
        • 1. Re: Vector shape to scale with text
          mirianam Level 1
          In case anyone is interested this is what I have done. This moves the text down by half it's height and keeps it in the vector shape. It's not perfect.

          I tried to use rect.bottom but made no progress.

          Thanks


          property pTargetSprite --placeholder sprite
          property pMyTextMember --text which goes into the placeholder sprite postion
          property pMySprite


          property pMyAdjustment --amount to reposition the text member loc
          property pMyStartLoc --for text member

          on getPropertyDescriptionList me
          set pdList = [:]
          addprop pdList, #pTargetSprite, [#comment: "Which sprite is target?", #format: #integer, #default: 26]
          addprop pdList, #pMyTextMember, [#comment: "Which cast member?", #format: #text, #default: "placeholder"]

          return pdList
          end getPropertyDescriptionList

          on beginSprite me
          pMySprite = sprite(me.spriteNum)
          pMyStartLoc = sprite(pTargetSprite).locV -- the empty text placeholder

          end

          on mouseUp me
          go to "started"

          sprite(pTargetSprite).member = member(pMyTextMember)





          pMyAdjustment = pMyTextMember.height

          sprite(pTargetSprite).locV = pMyStartLoc - pMyAdjustment/2 -- text placeholder's new loc according to it's height

          sprite(17).height = member(pMyTextMember).height + pMyAdjustment --sprite(17) is the vector shape "cartoon


          end