1 Reply Latest reply on Sep 26, 2008 8:58 PM by kglad

    bounce

    Malborojones
      Hello again, I had been making a simple game to practice my actionscripting,
      It's a ball that moves with the direction keys,
      What I did was make 4 separate Mc's as walls; top bottom left and right,
      I was able to make the ball bounce from these Mc's by using hitTest and x / yspeed - x / yspeed*2,
      that worked by making the ball "bounce" in the opposite direction at the same speed as when it hit,

      I've now changed the walls into one wall, I've changed the code to x / y *= -1,
      That inverts the direction BUT...
      When it hits it goes literally opposite direction so x and y is inverted not creating the "bounce" effect.
      Is there another way that this could be achieved?
      Thank you in advance!
        • 1. Re: bounce
          kglad Adobe Community Professional & MVP
          you were better off keeping your walls distinct. then you could have redirected the ball from the top and bottom walls by keeping xspeed unchanged and using the opposite for yspeed. analogously for the left and right walls.