1 Reply Latest reply on Oct 4, 2008 11:32 PM by kglad

    y position always on top of an object!

    Malborojones Level 1
      Riiiight heyyyyy, my new question is... how do you make the y position of an object always be just above another object, e.g. on most games on the internet an object or "player" can move over other objects like "ground" and obstacles, in my quite simple game, I've been trying to get the ball to roll over a simple "floor" Mc using hitTest using
      _y -- or _y -= 1 to get the object to stay over the floor, this works fine on horizontal "floor" but on parts where the floor raises it moves straight through it and goes up slowly if the ball remains inside the Mc until it reaches the top of it,
      Is there a way to keep the ball constantly 1px above the Mc?
      Thaaaaaaaanks in advanceeee!
        • 1. Re: y position always on top of an object!
          kglad Adobe Community Professional & MVP
          there's no easy fix. you'll need to code for that.

          if you have a simple shaped ground, just code directly.

          if you have a complex irregularly shaped ground, you can use the bitmapdata class to record the "height" of your ground as a function of _x and in your loop that's used to change the ball's _x property, check the corresponding "height" of the ground and adjust your ball accordingly.