1 decade ago by Mike
Sorry if this is a pretty dumb question, I'm new with Impact and very new to javascript in general.
I'm making a baseball game.
I made the ball it's own entity, and I need to check on the Catcher entity what direction that ball is moving on the X-Axis (Left or Right) so the catcher can position himself accordingly.
This is what I have in the catcher's update function, obviously it doesn't work correctly.
update: function() {
var ball = ig.game.getEntitiesByType( EntityBall );
var accel = this.accelGround;
if ( ball.accel.y > 0 ){
if (ball.accel.x > 0){
this.accel.x = accel;
}
}
this.parent();
},
I'm making a baseball game.
I made the ball it's own entity, and I need to check on the Catcher entity what direction that ball is moving on the X-Axis (Left or Right) so the catcher can position himself accordingly.
This is what I have in the catcher's update function, obviously it doesn't work correctly.
update: function() {
var ball = ig.game.getEntitiesByType( EntityBall );
var accel = this.accelGround;
if ( ball.accel.y > 0 ){
if (ball.accel.x > 0){
this.accel.x = accel;
}
}
this.parent();
},