3 Replies Latest reply on Sep 25, 2006 3:55 PM by moshplant

    Sprites following a draggable sprite

    Level 7
      I have a draggable sprite that on exitFrame sets the loc of 2 other sprites.
      It is supposed to appear as a single image being moved around, but pieces 2
      and 3 take a fraction of second to 'catch up' with the actual sprite being
      dragged, resulting in a jerky motion.

      Is there a better way?


        • 1. Re: Sprites following a draggable sprite
          Level 7
          Instead of using exitFrame, try prepareFrame or startFrame (or whichever
          combination works best)
          • 2. Re: Sprites following a draggable sprite
            Level 7
            Actually, enterFrame is the place to put frame code as it's given the
            largest time slice. Also, make sure your frame rate is high enough -
            30fps is a good start.


            Dave
            • 3. Re: Sprites following a draggable sprite
              moshplant Level 1
              Grrr. I wrote a nicely detailed reply to this that seems to have been chewed up.

              In short. my own experience is that sprite organization (channel numbering) and messageordering is more important than which handler (prepareframe/exitframe) you use. If the leading sprite gets its position update after the following sprites have already checked to see if they should move, it really doesn't matter if you do it at the end of a frame or the beginning of a frame.

              I'm providing a simple pair of behaviors for a 3-sprite system that lets you click on any of the sprites to move the group. They're pretty much in lockstep with each other, And they do it on exitframe. The following behavior goes on two of the sprites; the leader behavior goes on the lowest-numbered sprite. Expand for more sprites and more flexibility.