1 Reply Latest reply on Nov 25, 2006 9:37 AM by 2m

    Stuck with a bounce code

    AnotherRandomFlasher Level 1
      Hi, if anyone out there is willing to help me with a problem i be very happy :)
      if u create an object named "userBall_mc" on the stage and then paste this code into the frame and play it you will see my problem, the ball doesnt stop correctly bouncing.
      I know what code is screwing up, but not how to fix it. THe bad bit of code is the last 2 lines "the if statement". if u can tell me why my code doesnt work i be very happy thank you
      _global.stage = this;
      _global.bottomEdge = 370;
      _global.accY = 0;
      _global.fallSpd = 1
      _global.bounceSpd = 1;
      _global.xPos = userBall_mc._x;
      _global.yPos = userBall_mc._y;
      _global.fall = true;
      _global.ballHeight = userBall_mc._height;

      stage.userBall_mc.onEnterFrame = function(){
      xPos = userBall_mc._x;
      yPos = userBall_mc._y;
      if(fall == true){
      accY -= fallSpd;
      userBall_mc._y -= accY;
      if(yPos > bottomEdge){
      if(accY > 0){
      accY *= bounceSpd;
      }
      else{
      accY *= -bounceSpd;
      }
      }
      }
      if(yPos > bottomEdge){
      fall = false;
      }
      };