3 Replies Latest reply: Sep 14, 2009 6:38 AM by Edithson Abelard RSS

    keeping one object above another...

    polatkanfatih Community Member

      i am doing a mario game with flash, as3. i want to mario stay above box when jump above it or i dont want mario to pass through box while walking. mario should crash box like wall. what do you suggest?

        • 1. Re: keeping one object above another...
          Edithson Abelard

          Set Mario to have the highest depth at all time, you can set each

          object added to the screen to a depth of 0 and that will always force

          Mario to be at the highest depth.

           

          checkout methods like setChildIndex and swapChildAt

           

          Best Regards,

           

          Edithson Abelard

          Founder / Chief Interactive Developer and Multimedia Designer

           

           

          Passion 47, Inc

          www.passion47.com

          • 2. Re: keeping one object above another...
            polatkanfatih Community Member

            it is not what i mean....

             

            i mean that, mario should be at top of the box when jump on it in terms of y coordinate not z-index

            • 3. Re: keeping one object above another...
              Edithson Abelard Community Member

              In that case it depends on how your collision detection is setup as

              well as where the registration points for both the boxes and Mario are

              located.

               

              If you already detected the collision that Mario is on top of the box

              then setting Mario's y to the boxes y will have Mario standing on the

              box. That is, if Mario's y registration point is center bottom, and

              the box is top center.

               

              I don't know if you have a gravity constant, if you do then disabling

              it while Mario is on the box will save some system resources .

               

              Best Regards,

               

              Edithson Abelard

              Founder / Chief Interactive Developer and Multimedia Designer

               

               

              Passion 47, Inc

              www.passion47.com