all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

Stuck with a bounce code


Stuck with a bounce code AnotherRandomFlasher
11/25/2006 7:37:19 AM
flash actionscript:
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;
}
};
Re: Stuck with a bounce code 2m
11/25/2006 5:37:45 PM
AddThis Social Bookmark Button