4 Replies Latest reply on Sep 15, 2006 12:57 AM by Newsgroup_User

    Rotate CastMember

    Joselito2409 Level 1
      How can I rotate a castmember via lingo.

      Jota
        • 1. Re: Rotate CastMember
          Level 7
          Hi Jota,

          I'm guessing that you mean rotate a sprite.

          sprite(X).rotation = 60

          will rotate sprite x to 60 degrees. The value of the rotation property
          is absolute, not cumulative. So using the line above more than once
          won't move the sprite more than 60 degrees.

          The sprites that rotate, will rotate around their registration point, so
          a toolbox sprite, if it rotated, would rotate around it's upper left
          corner. But then toolbox sprites don't have a rotation property.

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: Rotate CastMember
            Scotty T.H. Level 1
            Hey Jota
            I have found that graphics you create using the Director Tools however if you are trying to rotate graphics that you have imported ... no probs.

            I was unsure if you simply wanted to set a sprite on an angle or have a sprite rotate until it reaches a particular angle.
            If this is the case try:

            -- only works while mouse is over that sprite

            on mouseWithin
            if sprite rotation < 45 then
            sprite(?).rotation = sprite(?).rotation + 1
            end

            or

            -- works when sprite is clicked on

            on mouseUp
            repeat while sprite(?).rotation < 45
            sprite(?).rotation = sprite(?).rotation + 1
            updatestage
            end repeat

            • 3. Re: Rotate CastMember
              Scotty T.H. Level 1
              oops! I meant ...

              on mouseWithin
              if sprite(?) rotation < 45 then
              sprite(?).rotation = sprite(?).rotation + 1
              end

              or

              -- works when sprite is clicked on

              on mouseUp
              repeat while sprite(?).rotation < 45
              sprite(?).rotation = sprite(?).rotation + 1
              updatestage
              end repeat
              • 4. Re: Rotate CastMember
                Level 7
                Scotty T.H. wrote:
                > oops! I meant ...
                >
                > on mouseWithin
                > if sprite(?) rotation < 45 then
                > sprite(?).rotation = sprite(?).rotation + 1
                > end
                >
                > or
                >
                > -- works when sprite is clicked on
                >
                > on mouseUp
                > repeat while sprite(?).rotation < 45
                > sprite(?).rotation = sprite(?).rotation + 1
                > updatestage
                > end repeat

                UpdateStage is (almost always) Bad. Using updateStage "short circuits" the
                normal flow in Director. Always try to avoid updateStage.

                This behaviour, applied to a sprite, will rotate that sprite:-
                ----------------------------------------------
                property spriteNum, self, active

                on mouseDown
                active=true
                end mouseDown

                on enterFrame
                if not(the mouseDown) then active=false
                if active then self.rotation=(self.rotation+1) mod 360
                end enterFrame

                on beginSprite
                self=sprite(spriteNum)
                active=false
                end beginSprite
                ----------------------------------------------

                Add a sprinkling of mouseUp, mouseUpOutside, etc. to adjust behaviour as
                required. Did I mention avoiding updateStage?

                Andrew