I'm having a problem with the update ( ) running this pitch function over and over, so the ball goes all over the place during the pitch.
Here's my pitch function
Code: Select all
pitch: function( ){
var pitchType = this.randomFromTo(1,10);
var accel = this.accelGround;
for (i=1;i<=2;i++){
if (pitchType <= 5){
while (this.accel.y <= 0){
var curveLeft = Math.random()*600;
this.accel.y = accel;
this.accel.x = -curveLeft;
this.flip = false;
}
this.messageBox = this.messageBox + "Curve Left \n";
}else if (pitchType > 5){
while (this.accel.y <= 0){
var curve = Math.random()*600;
this.accel.y = accel;
this.accel.x = curve;
this.flip = false;
}
this.messageBox = this.messageBox + "Curve Right \n";
}
}
},Code: Select all
update: function() {
this.pitch();
this.parent();
},