2 Replies Latest reply on Mar 19, 2007 4:35 PM by rihaha

    Syntax Help

    rihaha
      Here is what I have for the parent script for my sprite object. I am trying to make the new instance that appears on the stage appear in a specific location or in the center of the stage. I am also trying to make the new instance draggable. I'm just not sure of how to write this, here is what I have so far:

      property pSprite
      property pMember

      on new me, aMember
      pMember = aMember
      return me
      end

      on SetUpSprite me

      pSprite = GetChannel(me)

      pSprite.puppet = TRUE

      pSprite.member = pMember
      pSprite.loc = point(((the stage).rect.width), \--Here I would like to set exact points or would even be happy with a "center"
      ((the stage).rect.height))

      --pSprite.spriteObjRef = moveableSprite --This is where I am trying to set the new stage instance so it is movable
      end

      on GetChannel me

      repeat with i = 1 to the lastChannel
      if sprite(i).member.memberNum <= 0 then
      return sprite(i)
      end if
      end repeat

      alert "No more beads available."
      halt
      end
        • 1. Re: Syntax Help
          Lukewig Level 1
          Hi,

          your pSprite variable points to a sprite object (eg sprite(1)), so the syntax to make it a moveable sprite is:

          pSprite.moveableSprite= true


          To position your new sprite, you could pass a parameter to your setup sprite:

          on SetUpSprite (me, aPnt)
          ....
          if aPnt.ilk <> #point then
          -- default to the centre?
          x = (the stage).image.width/2
          y = (the stage).image.height/2
          aPnt = point(x,y)
          end if
          pSprite.loc = aPnt
          ...
          end

          If your sprites aren't appearing where you are expecting them, then you need to either adjust their member regPoints or the above code to take into account the fact that the regPoints of the members is not centred.

          -- Luke
          • 2. Re: Syntax Help
            rihaha Level 1
            This works perfectly, thank you so much Luke!