Help with ImpactJS Update( )
Posted: Fri Apr 06, 2012 7:20 pm
Alright well I'm trying to put together pitching in my Sim game.
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
Here's the update function
I'd like to get it to where it Runs one time until the pitch is done (At this point is when it has a collision with the catcher or wall).
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();
},